From b826045d0427db2c18eedda7e02f21acfc2ce62e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 21 Apr 2023 21:11:18 +0200 Subject: libutil: unix: simplify/unify directory iterator error handling Instead of printing out error messages, return an errro ID and match the behavior with the Windows implementation. Also, don't check first if the struct stat says it is a link, the readlinkat() system call will fail if it isn't. Avoid confusing the deputy. Signed-off-by: David Oberhollenzer --- bin/gensquashfs/src/fstree_from_dir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bin/gensquashfs/src') diff --git a/bin/gensquashfs/src/fstree_from_dir.c b/bin/gensquashfs/src/fstree_from_dir.c index 85381f9..6200ea3 100644 --- a/bin/gensquashfs/src/fstree_from_dir.c +++ b/bin/gensquashfs/src/fstree_from_dir.c @@ -80,8 +80,10 @@ static int scan_dir(fstree_t *fs, tree_node_t *root, dir_iterator_t *dir, int ret = dir->next(dir, &ent); if (ret > 0) break; - if (ret < 0) + if (ret < 0) { + sqfs_perror("readdir", NULL, ret); return -1; + } if (should_skip(dir, ent, flags)) { free(ent); @@ -89,8 +91,10 @@ static int scan_dir(fstree_t *fs, tree_node_t *root, dir_iterator_t *dir, } if (S_ISLNK(ent->mode)) { - if (dir->read_link(dir, &extra)) { + ret = dir->read_link(dir, &extra); + if (ret) { free(ent); + sqfs_perror("readlink", ent->name, ret); return -1; } } -- cgit v1.2.3