busybox/udhcpc: set DHCP hostname
[opendreambox.git] / meta-opendreambox / recipes-core / busybox / busybox-1.19.4 / 0001-ifupdown-support-post-up-pre-down-hooks.patch
1 From b58a1a06ca695aed6a4f6e5039e2de0e5a3df111 Mon Sep 17 00:00:00 2001
2 From: Peter Korsgaard <jacmet@sunsite.dk>
3 Date: Wed, 19 Oct 2011 02:35:54 +0200
4 Subject: [PATCH 01/10] ifupdown: support post-up / pre-down hooks
5
6 function                                             old     new   delta
7 set_environ                                          330     371     +41
8 ifupdown_main                                       2156    2194     +38
9 iface_up                                              97     113     +16
10 iface_down                                            97     113     +16
11 ------------------------------------------------------------------------------
12 (add/remove: 0/0 grow/shrink: 4/0 up/down: 111/0)             Total: 111 bytes
13
14 Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
16 ---
17  networking/ifupdown.c |    6 ++++++
18  1 file changed, 6 insertions(+)
19
20 diff --git a/networking/ifupdown.c b/networking/ifupdown.c
21 index 3820330..abc6b58 100644
22 --- a/networking/ifupdown.c
23 +++ b/networking/ifupdown.c
24 @@ -891,6 +891,8 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
25                                 if (strcmp(first_word, "up") != 0
26                                  && strcmp(first_word, "down") != 0
27                                  && strcmp(first_word, "pre-up") != 0
28 +                                && strcmp(first_word, "pre-down") != 0
29 +                                && strcmp(first_word, "post-up") != 0
30                                  && strcmp(first_word, "post-down") != 0
31                                 ) {
32                                         int i;
33 @@ -987,6 +989,8 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
34                 if (strcmp(iface->option[i].name, "up") == 0
35                  || strcmp(iface->option[i].name, "down") == 0
36                  || strcmp(iface->option[i].name, "pre-up") == 0
37 +                || strcmp(iface->option[i].name, "pre-down") == 0
38 +                || strcmp(iface->option[i].name, "post-up") == 0
39                  || strcmp(iface->option[i].name, "post-down") == 0
40                 ) {
41                         continue;
42 @@ -1056,6 +1060,7 @@ static int iface_up(struct interface_defn_t *iface)
43         if (!execute_all(iface, "pre-up")) return 0;
44         if (!iface->method->up(iface, doit)) return 0;
45         if (!execute_all(iface, "up")) return 0;
46 +       if (!execute_all(iface, "post-up")) return 0;
47         return 1;
48  }
49  
50 @@ -1063,6 +1068,7 @@ static int iface_down(struct interface_defn_t *iface)
51  {
52         if (!iface->method->down(iface,check)) return -1;
53         set_environ(iface, "stop");
54 +       if (!execute_all(iface, "pre-down")) return 0;
55         if (!execute_all(iface, "down")) return 0;
56         if (!iface->method->down(iface, doit)) return 0;
57         if (!execute_all(iface, "post-down")) return 0;
58 -- 
59 1.7.10.4
60