[BusyBox-cvs] svn commit: trunk/busybox/libbb

landley at busybox.net landley at busybox.net
Tue May 3 21:30:27 UTC 2005


Author: landley
Date: 2005-05-03 15:30:26 -0600 (Tue, 03 May 2005)
New Revision: 10241

Log:
Shaun Jackman said:

This patch adds a CONFIG_FEATURE_CLEAN_UP stanza, and also adds an
ifdef around the SIOCGIFMAP call.



Modified:
   trunk/busybox/libbb/interface.c


Changeset:
Modified: trunk/busybox/libbb/interface.c
===================================================================
--- trunk/busybox/libbb/interface.c	2005-05-03 14:20:47 UTC (rev 10240)
+++ trunk/busybox/libbb/interface.c	2005-05-03 21:30:26 UTC (rev 10241)
@@ -888,6 +888,20 @@
 	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 @@
 	}
 #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 @@
 
 	/* 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);
 }




More information about the busybox-cvs mailing list