home: hub: mkinitfs

Download patch

ref: 4d213b31b890011f120146f0d760d7ffd70f75b9
parent: 17b72a447b7524e66729d31d598ba473bbda7324
author: Natanael Copa <ncopa@alpinelinux.org>
date: Thu Oct 8 11:39:49 CDT 2015

nlplug-findfs: fix recursing dirs on isofs

the dirent d_type is not supported on isofs apparently. Use lstat
instead.

--- a/nlplug-findfs.c
+++ b/nlplug-findfs.c
@@ -274,7 +274,17 @@
 
 	while ((entry = readdir(d)) != NULL) {
 		char path[PATH_MAX];
-		if (entry->d_type & DT_DIR) {
+		struct stat st;
+
+		/* d_type is not supported by all filesystems so we need
+		   lstat */
+		snprintf(path, sizeof(path), "%s/%s", dir, entry->d_name);
+		if (lstat(path, &st) < 0) {
+			dbg("%s: %s", path, strerror(errno));
+			continue;
+		}
+
+		if (S_ISDIR(st.st_mode)) {
 			if (entry->d_name[0] == '.')
 				continue;
 		} else if (opts->searchname
@@ -282,8 +292,7 @@
 			continue;
 		}
 
-		snprintf(path, sizeof(path), "%s/%s", dir, entry->d_name);
-		if (entry->d_type & DT_DIR)
+		if (S_ISDIR(st.st_mode))
 			recurse_dir(path, opts);
 		else
 			opts->callback(path, opts->userdata);