[PATCH] Support for running mdev from rootfs

Jason Schoon floydpink at gmail.com
Thu Jun 8 19:22:21 UTC 2006


I wanted to use mdev from a rootfs, but the opendir calls fail in that
filesystem.  This patch falls back to using stat when that occurs.

--- busybox/util-linux/mdev.c	2006-06-07 11:28:06.000000000 -0500
+++ busybox/util-linux/mdev.c.mod	2006-06-07 11:27:37.000000000 -0500
@@ -192,6 +192,7 @@
 	DIR *dir;
 	size_t len = strlen(path);
 	struct dirent *entry;
+	struct stat st;

 	if ((dir = opendir(path)) == NULL)
 		return;
@@ -202,12 +203,14 @@

 		if (entry->d_name[0] == '.')
 			continue;
-
-		if (entry->d_type == DT_DIR) {
-			snprintf(path+len, PATH_MAX-len, "/%s", entry->d_name);
+	
+		snprintf(path+len, PATH_MAX-len, "/%s", entry->d_name);
+		if (entry->d_type == DT_DIR ||
+			(entry->d_type == DT_UNKNOWN && !lstat(path, &st) && S_ISDIR(st.st_mode)))
+		{
 			find_dev(path);
-			path[len] = 0;
 		}
+		path[len] = 0;

 		/* If there's a dev entry, mknod it */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox_mdev_rootfs.patch
Type: text/x-patch
Size: 746 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060608/5c00e743/attachment.bin 


More information about the busybox mailing list