home: hub: mkinitfs

Download patch

ref: cb3bc06f5ae4a9c3e706babd0a2c009058c0940f
parent: cd8e5008f3d91d432558de0798ff3a8ad32b965d
author: Natanael Copa <ncopa@alpinelinux.org>
date: Mon Oct 19 02:52:27 CDT 2015

nlplug-findfs: use DT_UNKNOWN to detect if lstat is to be used

--- a/nlplug-findfs.c
+++ b/nlplug-findfs.c
@@ -265,7 +265,6 @@
 	const char *searchname;
 	void (*callback)(const char *, const void *);
 	void *userdata;
-	int fastdir;	/* avoid lstat on sysfs which we know support d_type */
 };
 
 /* pathbuf needs hold PATH_MAX chars */
@@ -278,7 +277,6 @@
 		return;
 
 	while ((entry = readdir(d)) != NULL) {
-		struct stat st;
 		size_t pathlen = strlen(pathbuf);
 		size_t namelen = strlen(entry->d_name);
 		int is_dir;
@@ -293,19 +291,17 @@
 		pathbuf[pathlen] = '/';
 		strcpy(&pathbuf[pathlen+1], entry->d_name);
 
-		if (opts->fastdir) {
-			/* avoid the lstat syscall for sysfs which we know
-			   support the d_type field. */
-			is_dir = entry->d_type & DT_DIR;
-		} else {
+		if (entry->d_type == DT_UNKNOWN) {
 			/* some filesystems like iso9660 does not support
 			   the d_type so we use lstat */
+			struct stat st;
 			if (lstat(pathbuf, &st) < 0) {
 				dbg("%s: %s", pathbuf, strerror(errno));
 				goto next;
 			}
 			is_dir = S_ISDIR(st.st_mode);
-		}
+		else
+			is_dir = entry->d_type & DT_DIR;
 
 		if (is_dir) {
 			if (entry->d_name[0] == '.')
@@ -387,7 +383,6 @@
 		.searchname = ".boot_repository",
 		.callback = bootrepo_cb,
 		.userdata = &repos,
-		.fastdir = 0,
 	};
 
 
@@ -603,7 +598,6 @@
 		.searchname = "uevent",
 		.callback = trigger_uevent_cb,
 		.userdata = NULL,
-		.fastdir = 1,
 	};
 	char path[PATH_MAX] = "/sys/bus";