mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-08-27 10:55:55 +00:00
Resort to lstat for FS not supporting dirent.d_type
According to POSIX.1 only d_name and d_ino fields of struct dirent are standardized. d_type isn't always correctly set on file systems like XFS. In such cases it makes sense to resort to lstat(). Otherwise a user has hard time figuring out what's wrong with her setup. Also remove redundant populate_file_struct() as it's called again in parallel threads. Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
This commit is contained in:
+14
-5
@@ -321,7 +321,6 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
|
||||
while (dir) {
|
||||
struct file *file;
|
||||
char *sub_filename;
|
||||
char *fullname;
|
||||
|
||||
entry = readdir(dir);
|
||||
if (!entry) {
|
||||
@@ -349,12 +348,22 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
|
||||
file->last_change = manifest->version;
|
||||
file->filename = sub_filename;
|
||||
|
||||
string_or_die(&fullname, "%s/%s", fullpath, entry->d_name);
|
||||
populate_file_struct(file, fullname);
|
||||
free(fullname);
|
||||
|
||||
if (entry->d_type == DT_DIR) {
|
||||
iterate_directory(manifest, pathprefix, file->filename, do_hash);
|
||||
} else if (entry->d_type == DT_UNKNOWN) { /* fall back to lstat() */
|
||||
struct stat sb;
|
||||
char *fullname;
|
||||
|
||||
string_or_die(&fullname, "%s/%s", fullpath, entry->d_name);
|
||||
if (lstat(fullname, &sb) == -1) {
|
||||
perror("lstat");
|
||||
assert(0);
|
||||
}
|
||||
free(fullname);
|
||||
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
iterate_directory(manifest, pathprefix, file->filename, do_hash);
|
||||
}
|
||||
}
|
||||
|
||||
/* if for some reason there is a file in the official build
|
||||
|
||||
Reference in New Issue
Block a user