diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-10-19 07:52:27 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-10-19 07:53:57 +0000 |
commit | cb3bc06f5ae4a9c3e706babd0a2c009058c0940f (patch) | |
tree | 3d54d54e60541a225961dcb6f2b1e0811dcf3956 | |
parent | cd8e5008f3d91d432558de0798ff3a8ad32b965d (diff) | |
download | mkinitfs-cb3bc06f5ae4a9c3e706babd0a2c009058c0940f.tar.bz2 mkinitfs-cb3bc06f5ae4a9c3e706babd0a2c009058c0940f.tar.xz |
nlplug-findfs: use DT_UNKNOWN to detect if lstat is to be used
-rw-r--r-- | nlplug-findfs.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/nlplug-findfs.c b/nlplug-findfs.c index a016b23..ceaafab 100644 --- a/nlplug-findfs.c +++ b/nlplug-findfs.c @@ -265,7 +265,6 @@ struct recurse_opts { 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 @@ void recurse_dir(char *pathbuf, struct recurse_opts *opts) 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 @@ void recurse_dir(char *pathbuf, struct recurse_opts *opts) 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 @@ static int find_bootrepos(const char *devnode, const char *type, .searchname = ".boot_repository", .callback = bootrepo_cb, .userdata = &repos, - .fastdir = 0, }; @@ -603,7 +598,6 @@ void *trigger_thread(void *data) .searchname = "uevent", .callback = trigger_uevent_cb, .userdata = NULL, - .fastdir = 1, }; char path[PATH_MAX] = "/sys/bus"; |