diff options
author | Rob Landley | 2005-05-03 21:30:26 +0000 |
---|---|---|
committer | Rob Landley | 2005-05-03 21:30:26 +0000 |
commit | 93983040c51ccbb2a19fc53f50498148edf98f65 (patch) | |
tree | 4b9e42e5b1afc817ea4ac853b4010d67ceb3cf43 | |
parent | 60158cb93eb0b3207dd1084cdf5bdd9226bd9e89 (diff) | |
download | busybox-93983040c51ccbb2a19fc53f50498148edf98f65.zip busybox-93983040c51ccbb2a19fc53f50498148edf98f65.tar.gz |
Shaun Jackman said:
This patch adds a CONFIG_FEATURE_CLEAN_UP stanza, and also adds an
ifdef around the SIOCGIFMAP call.
-rw-r--r-- | libbb/interface.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/libbb/interface.c b/libbb/interface.c index 37a5f64..65d7c4e 100644 --- a/libbb/interface.c +++ b/libbb/interface.c @@ -888,6 +888,20 @@ static int sockets_open(int family) return sfd; } +#ifdef CONFIG_FEATURE_CLEAN_UP +static void sockets_close(void) +{ + struct aftype **aft; + for (aft = aftypes; *aft != NULL; aft++) { + struct aftype *af = *aft; + if( af->fd != -1 ) { + close(af->fd); + af->fd = -1; + } + } +} +#endif + /* like strcmp(), but knows about numbers */ static int nstrcmp(const char *a, const char *b) { @@ -1223,17 +1237,13 @@ static int if_fetch(struct interface *ife) } #endif +#ifdef SIOCGIFMAP strcpy(ifr.ifr_name, ifname); - if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) - memset(&ife->map, 0, sizeof(struct ifmap)); + if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0) + ife->map = ifr.ifr_map; else - memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap)); - - strcpy(ifr.ifr_name, ifname); - if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) +#endif memset(&ife->map, 0, sizeof(struct ifmap)); - else - ife->map = ifr.ifr_map; #ifdef HAVE_TXQUEUELEN strcpy(ifr.ifr_name, ifname); @@ -2078,6 +2088,8 @@ int display_interfaces(char *ifname) /* Do we have to show the current setup? */ status = if_print(ifname); - close(skfd); +#ifdef CONFIG_FEATURE_CLEAN_UP + sockets_close(); +#endif exit(status < 0); } |