svn commit: trunk/busybox/util-linux

landley at busybox.net landley at busybox.net
Thu Aug 10 01:09:37 UTC 2006


Author: landley
Date: 2006-08-09 18:09:37 -0700 (Wed, 09 Aug 2006)
New Revision: 15795

Log:
Patch from Chris Steel to fix mdev deleting device nodes.


Modified:
   trunk/busybox/util-linux/mdev.c


Changeset:
Modified: trunk/busybox/util-linux/mdev.c
===================================================================
--- trunk/busybox/util-linux/mdev.c	2006-08-10 01:08:41 UTC (rev 15794)
+++ trunk/busybox/util-linux/mdev.c	2006-08-10 01:09:37 UTC (rev 15795)
@@ -37,18 +37,19 @@
 	 * because sscanf() will stop at the first nondigit, which \n is.  We
 	 * also depend on path having writeable space after it. */
 
-	strcat(path, "/dev");
-	fd = open(path, O_RDONLY);
-	len = read(fd, temp + 1, 64);
-	*temp++ = 0;
-	close(fd);
-	if (len < 1) return;
+	if (!delete) {
+		strcat(path, "/dev");
+		fd = open(path, O_RDONLY);
+		len = read(fd, temp + 1, 64);
+		*temp++ = 0;
+		close(fd);
+		if (len < 1) return;
+	}
 
 	/* Determine device name, type, major and minor */
 
 	device_name = strrchr(path, '/') + 1;
 	type = path[5]=='c' ? S_IFCHR : S_IFBLK;
-	if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
 
 	/* If we have a config file, look up permissions for this device */
 
@@ -164,6 +165,7 @@
 
 	umask(0);
 	if (!delete) {
+		if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
 		if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
 			bb_perror_msg_and_die("mknod %s failed", device_name);
 




More information about the busybox-cvs mailing list