Skip to content

Commit a1176ff

Browse files
committed
Simplified the approach by making a wrapper and did spelling fixes
1 parent 0611e8c commit a1176ff

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/uucore/src/lib/features/safe_traversal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ impl From<SafeTraversalError> for io::Error {
8181
}
8282

8383
/// Clear errno and return any error that was set after an operation
84-
/// This is used because the nix library does not propogate folder reading errors correctly
84+
/// This is used because the nix library does not propagate folder reading errors correctly
8585
pub fn take_errno() -> Option<io::Error> {
8686
let errno = Errno::last();
8787
Errno::clear();
8888
(errno != Errno::from_raw(0)).then(|| io::Error::from_raw_os_error(errno as i32))
8989
}
9090

91-
/// Clear errno before an operation, required to read error messages not propogated by nix from reading folders
91+
/// Clear errno before an operation, required to read error messages not propagated by nix from reading folders
9292
pub fn clear_errno() {
9393
Errno::clear();
9494
}

util/build-gnu.sh

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW
66
# spell-checker:ignore baddecode submodules xstrtol distros ; (vars/env) SRCDIR vdir rcexp xpart dired OSTYPE ; (utils) greadlink gsed multihardlink texinfo CARGOFLAGS
77
# spell-checker:ignore openat TOCTOU CFLAGS tmpfs gnproc
8+
# spell-checker:ignore hfsplus casefold chattr dirp
89

910
set -e
1011

@@ -358,17 +359,13 @@ test \$n_stat1 -ge \$n_stat2 \\' tests/ls/stat-free-color.sh
358359
# * the test says "maybe we should not fail when no context available"
359360
"${SED}" -i -e "s|returns_ 1||g" tests/cp/no-ctx.sh
360361

361-
# The rm-readdir-fail.sh test hooks readdir() but uutils rm uses nix library which calls readdir64_r().
362-
# readdir64_r has a different signature: int readdir64_r(DIR*, struct dirent64*, struct dirent64**)
363-
"${SED}" -i \
364-
-e 's/struct dirent \*readdir (DIR \*dirp)/int readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)/' \
365-
-e 's/struct dirent \*(\*real_readdir)(DIR \*dirp)/int (*real_func)(DIR *, struct dirent64 *, struct dirent64 **)/' \
366-
-e 's/real_readdir/real_func/g' \
367-
-e 's/dlsym (RTLD_NEXT, "readdir")/dlsym(RTLD_NEXT, "readdir64_r")/' \
368-
-e 's/struct dirent\* d;/int ret;/' \
369-
-e 's/! (d = real_func (dirp))/(ret = real_func(dirp, entry, result)) != 0 || !*result/' \
370-
-e 's/d->d_name/entry->d_name/g' \
371-
-e 's/d->d_namlen/entry->d_namlen/g' \
372-
-e 's/return d;/return 0;/' \
373-
-e 's/return NULL;/*result = NULL; return EIO;/' \
374-
tests/rm/rm-readdir-fail.sh
362+
# uutils rm uses nix which calls readdir64_r, so add a wrapper that delegates to the readdir hook
363+
"${SED}" -i '/^struct dirent \*readdir/i\
364+
int readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result) {\
365+
struct dirent *d = readdir(dirp);\
366+
if (!d) { *result = NULL; return errno ? EIO : 0; }\
367+
memcpy(entry, d, sizeof(*d));\
368+
*result = entry;\
369+
return 0;\
370+
}
371+
' tests/rm/rm-readdir-fail.sh

0 commit comments

Comments
 (0)