[PATCH] ifupdown: Support "source-directory" stanza
Denys Vlasenko
vda.linux at googlemail.com
Sun Sep 30 12:21:00 UTC 2018
applied, thanks
On Fri, Sep 21, 2018 at 7:55 PM Brandon Maier
<brandon.maier at rockwellcollins.com> wrote:
>
> Support the "source-directory" stanza from ifupdown[1]. source-directory
> will include all files in the named directory. Similar to the Busybox
> version of the "source" stanza, this version of source-directory does
> not currently support shell wildcards.
>
> We only check that the stanza starts with "source-dir" as ifupdown does[2].
>
> [1] https://manpages.debian.org/stretch/ifupdown/interfaces.5.en.html#INCLUDING_OTHER_FILES
> [2] https://salsa.debian.org/debian/ifupdown/blob/0.8.33/config.c#L498
>
> Signed-off-by: Brandon Maier <brandon.maier at rockwellcollins.com>
> ---
> networking/ifupdown.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/networking/ifupdown.c b/networking/ifupdown.c
> index a76fe10..7dd7881 100644
> --- a/networking/ifupdown.c
> +++ b/networking/ifupdown.c
> @@ -1017,6 +1017,26 @@ static struct interfaces_file_t *read_interfaces(const char *filename, struct in
> currently_processing = NONE;
> } else if (strcmp(first_word, "source") == 0) {
> read_interfaces(next_word(&rest_of_line), defn);
> + } else if (is_prefixed_with(first_word, "source-dir")) {
> + const char *dirpath;
> + char path[NAME_MAX];
> + struct dirent *entry;
> + DIR *dir;
> +
> + dirpath = next_word(&rest_of_line);
> +
> + dir = xopendir(dirpath);
> + while ((entry = readdir(dir)) != NULL) {
> + if (entry->d_name[0] == '.')
> + continue;
> +
> + snprintf(path, NAME_MAX, "%s/%s",
> + dirpath, entry->d_name);
> +
> + read_interfaces(path, defn);
> + }
> +
> + closedir(dir);
> } else {
> switch (currently_processing) {
> case IFACE:
> --
> 1.9.1
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list