[git commit master 1/1] mdev: fix non-working device deletion, add a test for that

Denys Vlasenko vda.linux at googlemail.com
Mon Aug 16 12:26:15 UTC 2010


commit: http://git.busybox.net/busybox/commit/?id=f2860bf6d332cbbfd2d4d9afadb0148cf061fad2
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 testsuite/mdev.tests |   10 ++++++++++
 util-linux/mdev.c    |    5 +++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/testsuite/mdev.tests b/testsuite/mdev.tests
index c375fc7..a46929b 100755
--- a/testsuite/mdev.tests
+++ b/testsuite/mdev.tests
@@ -38,6 +38,16 @@ brw-rw---- 1 0 0 8,0 sda
 SKIP=
 
 # continuing to use directory structure from prev test
+optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME
+testing "mdev deletes /block/sda" \
+	"env - PATH=$PATH ACTION=remove DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
+	ls -ln mdev.testdir/dev | $FILTER_LS" \
+"\
+" \
+	"" ""
+SKIP=
+
+# continuing to use directory structure from prev test
 rm -rf mdev.testdir/dev/*
 echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf
 echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index b4042c0..cd6c1a8 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -132,6 +132,7 @@ static void make_device(char *path, int delete)
 			major = -1;
 		}
 	}
+	/* else: for delete, -1 still deletes the node, but < -1 suppresses that */
 
 	/* Determine device name, type, major and minor */
 	device_name = (char*) bb_basename(path);
@@ -279,7 +280,7 @@ static void make_device(char *path, int delete)
 				if (aliaslink == '!' && s == a+1) {
 					val = st;
 					/* "!": suppress node creation/deletion */
-					major = -1;
+					major = -2;
 				}
 				else if (aliaslink == '>' || aliaslink == '=') {
 					val = st;
@@ -379,7 +380,7 @@ static void make_device(char *path, int delete)
 				free(command);
 			}
 
-			if (delete && major >= 0) {
+			if (delete && major >= -1) {
 				if (ENABLE_FEATURE_MDEV_RENAME && alias) {
 					if (aliaslink == '>')
 						unlink(device_name);
-- 
1.7.1



More information about the busybox-cvs mailing list