busybox: mount: don't pass option "auto" to kernel
[opendreambox.git] / meta-opendreambox / recipes-core / busybox / busybox-1.19.4 / 0005-ifupdown-improve-compatibility-with-Debian.patch
1 From 7ec30bf273cbdf5f0ae335684939a883182e493e Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Mon, 23 Apr 2012 22:08:39 +0200
4 Subject: [PATCH 05/11] ifupdown: improve compatibility with Debian
5
6 Set environment variable 'PHASE'.
7 Treat post-up and pre-down as aliases for up and down.
8 Uses the same logic as ifupdown.nw from ifupdown-0.6.16.
9 Makes it possible to execute Debian's ifupdown script for
10 wpa-supplicant.
11
12 Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
14 ---
15  networking/ifupdown.c |   20 ++++++++++++--------
16  1 file changed, 12 insertions(+), 8 deletions(-)
17
18 diff --git a/networking/ifupdown.c b/networking/ifupdown.c
19 index 9f49619..5c3dcec 100644
20 --- a/networking/ifupdown.c
21 +++ b/networking/ifupdown.c
22 @@ -140,8 +140,6 @@ static const char keywords_up_down[] ALIGN1 =
23         "up\0"
24         "down\0"
25         "pre-up\0"
26 -       "pre-down\0"
27 -       "post-up\0"
28         "post-down\0"
29  ;
30  
31 @@ -895,6 +893,11 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
32                                 if (rest_of_line[0] == '\0')
33                                         bb_error_msg_and_die("option with empty value \"%s\"", buf);
34  
35 +                               if (strcmp(first_word, "post-up") == 0)
36 +                                       first_word += 5; /* "up" */
37 +                               else if (strcmp(first_word, "pre-down") == 0)
38 +                                       first_word += 4; /* "down" */
39 +
40                                 /* If not one of "up", "down",... words... */
41                                 if (index_in_strings(keywords_up_down, first_word) < 0) {
42                                         int i;
43 @@ -963,7 +966,7 @@ static char *setlocalenv(const char *format, const char *name, const char *value
44         return result;
45  }
46  
47 -static void set_environ(struct interface_defn_t *iface, const char *mode)
48 +static void set_environ(struct interface_defn_t *iface, const char *mode, const char *opt)
49  {
50         int i;
51         char **pp;
52 @@ -976,7 +979,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
53         }
54  
55         /* note: last element will stay NULL: */
56 -       G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 6));
57 +       G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 7));
58         pp = G.my_environ;
59  
60         for (i = 0; i < iface->n_options; i++) {
61 @@ -990,6 +993,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
62         *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name);
63         *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name);
64         *pp++ = setlocalenv("%s=%s", "MODE", mode);
65 +       *pp++ = setlocalenv("%s=%s", "PHASE", opt);
66         if (G.startup_PATH)
67                 *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH);
68  }
69 @@ -1044,21 +1048,21 @@ static int check(char *str)
70  static int iface_up(struct interface_defn_t *iface)
71  {
72         if (!iface->method->up(iface, check)) return -1;
73 -       set_environ(iface, "start");
74 +       set_environ(iface, "start", "pre-up");
75         if (!execute_all(iface, "pre-up")) return 0;
76         if (!iface->method->up(iface, doit)) return 0;
77 +       set_environ(iface, "start", "post-up");
78         if (!execute_all(iface, "up")) return 0;
79 -       if (!execute_all(iface, "post-up")) return 0;
80         return 1;
81  }
82  
83  static int iface_down(struct interface_defn_t *iface)
84  {
85         if (!iface->method->down(iface,check)) return -1;
86 -       set_environ(iface, "stop");
87 -       if (!execute_all(iface, "pre-down")) return 0;
88 +       set_environ(iface, "stop", "pre-down");
89         if (!execute_all(iface, "down")) return 0;
90         if (!iface->method->down(iface, doit)) return 0;
91 +       set_environ(iface, "stop", "post-down");
92         if (!execute_all(iface, "post-down")) return 0;
93         return 1;
94  }
95 -- 
96 1.7.10.4
97