svn commit: trunk/busybox: testsuite util-linux

vda at busybox.net vda at busybox.net
Fri May 2 13:21:25 UTC 2008


Author: vda
Date: 2008-05-02 06:21:24 -0700 (Fri, 02 May 2008)
New Revision: 21921

Log:
mdev: fix a bug where we were eating argv[0] of helper



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


Changeset:
Modified: trunk/busybox/testsuite/mdev.tests
===================================================================
--- trunk/busybox/testsuite/mdev.tests	2008-05-02 12:34:59 UTC (rev 21920)
+++ trunk/busybox/testsuite/mdev.tests	2008-05-02 13:21:24 UTC (rev 21921)
@@ -18,6 +18,8 @@
 # We need mdev executable to be in chroot jail!
 # (will still fail with dynamically linked one, though...)
 cp ../busybox mdev.testdir/mdev
+mkdir mdev.testdir/bin
+cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature
 mkdir mdev.testdir/etc
 mkdir mdev.testdir/dev
 mkdir -p mdev.testdir/sys/block/sda
@@ -93,6 +95,20 @@
 " \
 	"" ""
 
+# continuing to use directory structure from prev test
+rm -rf mdev.testdir/dev/*
+# here we complicate things by having non-matching group 1 and using %0
+echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf
+testing "mdev command" \
+	"env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
+	ls -lnR mdev.testdir/dev | $FILTER_LS" \
+"\
+ at echo TEST
+mdev.testdir/dev:
+brw-r--r-- 1 0 0 8,0 sda
+" \
+	"" ""
+
 # clean up
 rm -rf mdev.testdir
 

Modified: trunk/busybox/util-linux/mdev.c
===================================================================
--- trunk/busybox/util-linux/mdev.c	2008-05-02 12:34:59 UTC (rev 21920)
+++ trunk/busybox/util-linux/mdev.c	2008-05-02 13:21:24 UTC (rev 21921)
@@ -156,43 +156,45 @@
 			mode = strtoul(val, NULL, 8);
 
 			/* 4th field (opt): >alias */
-			if (ENABLE_FEATURE_MDEV_RENAME) {
-				if (!next)
-					break;
+#if ENABLE_FEATURE_MDEV_RENAME
+			if (!next)
+				break;
+			if (*next == '>') {
+#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
+				char *s, *p;
+				unsigned i, n;
+
 				val = next;
 				next = next_field(val);
-				if (*val == '>') {
-#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
-					/* substitute %1..9 with off[1..9], if any */
-					char *s, *p;
-					unsigned i, n;
+				/* substitute %1..9 with off[1..9], if any */
+				n = 0;
+				s = val;
+				while (*s && *s++ == '%')
+					n++;
 
-					n = 0;
-					s = val;
-					while (*s && *s++ == '%')
-						n++;
-
-					p = alias = xzalloc(strlen(val) + n * strlen(device_name));
-					s = val + 1;
-					while (*s) {
-						*p = *s;
-						if ('%' == *s) {
-							i = (s[1] - '0');
-							if (i <= 9 && off[i].rm_so >= 0) {
-								n = off[i].rm_eo - off[i].rm_so;
-								strncpy(p, device_name + off[i].rm_so, n);
-								p += n - 1;
-								s++;
-							}
+				p = alias = xzalloc(strlen(val) + n * strlen(device_name));
+				s = val + 1;
+				while (*s) {
+					*p = *s;
+					if ('%' == *s) {
+						i = (s[1] - '0');
+						if (i <= 9 && off[i].rm_so >= 0) {
+							n = off[i].rm_eo - off[i].rm_so;
+							strncpy(p, device_name + off[i].rm_so, n);
+							p += n - 1;
+							s++;
 						}
-						p++;
-						s++;
 					}
+					p++;
+					s++;
+				}
 #else
-					alias = xstrdup(val + 1);
+				val = next;
+				next = next_field(val);
+				alias = xstrdup(val + 1);
 #endif
-				}
 			}
+#endif /* ENABLE_FEATURE_MDEV_RENAME */
 
 			/* The rest (opt): command to run */
 			if (!next)




More information about the busybox-cvs mailing list