ifupdown keeps information on which interfaces are up in a file
called ifstate. Typically it is located in /var/run/ifstate,
however some distributions tend to put it in different places
(like debian, for example, uses /etc/network/run/ifstate). This
patch adds a config option that defines the location of ifstate.

Signed-off-by: Alexander Shishkin <[EMAIL PROTECTED]>
---
 networking/Config.in  |   10 ++++++++++
 networking/ifupdown.c |    8 +++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/networking/Config.in b/networking/Config.in
index 77b5d25..b80d5ab 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -209,6 +209,16 @@ config FEATURE_IFCONFIG_BROADCAST_PLUS
          Setting this will make ifconfig attempt to find the broadcast
          automatically if the value '+' is used.
 
+config IFSTATE_PATH
+       string "Absolute path to ifstate file"
+       default "/var/run/ifstate"
+       help
+         ifupdown keeps information on which interfaces are up in a file
+         called ifstate. Typically it is located in /var/run/ifstate,
+         however some distributions tend to put it in different places
+         (like debian, for example, uses /etc/network/run/ifstate). This
+         config option defines the location of ifstate.
+
 config IFUPDOWN
        bool "ifupdown"
        default n
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index e9f0a64..5c7771a 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -10,7 +10,9 @@
  *  Changes to upstream version
  *  Remove checks for kernel version, assume kernel version 2.2.0 or better.
  *  Lines in the interfaces file cannot wrap.
- *  To adhere to the FHS, the default state file is /var/run/ifstate.
+ *  To adhere to the FHS, the default state file is /var/run/ifstate
+ *  (defined via CONFIG_IFSTATE_PATH) and can be overridden by build
+ *  configuration.
  *
  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  */
@@ -1105,7 +1107,7 @@ static llist_t *find_iface_state(llist_t *state_list, 
const char *iface)
 static llist_t *read_iface_state(void)
 {
        llist_t *state_list = NULL;
-       FILE *state_fp = fopen("/var/run/ifstate", "r");
+       FILE *state_fp = fopen(CONFIG_IFSTATE_PATH, "r");
 
        if (state_fp) {
                char *start, *end_ptr;
@@ -1275,7 +1277,7 @@ int ifupdown_main(int argc, char **argv)
                        }
 
                        /* Actually write the new state */
-                       state_fp = xfopen("/var/run/ifstate", "w");
+                       state_fp = xfopen(CONFIG_IFSTATE_PATH, "w");
                        state = state_list;
                        while (state) {
                                if (state->data) {
-- 
1.5.1.2

_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to