diff options
author | 2021-11-05 06:23:34 -0400 | |
---|---|---|
committer | 2021-11-05 06:23:34 -0400 | |
commit | 382f70b8d93d012648edc7a42087a6d4d5a103eb (patch) | |
tree | 90bfa31ce787e83fac74dbd6dd74c34fc7e54e9d /libsbutil | |
parent | Revert "Force sandbox-internal functions to use 64bit file interface" (diff) | |
download | sandbox-382f70b8d93d012648edc7a42087a6d4d5a103eb.tar.gz sandbox-382f70b8d93d012648edc7a42087a6d4d5a103eb.tar.bz2 sandbox-382f70b8d93d012648edc7a42087a6d4d5a103eb.zip |
libsandbox/libsbutil: use faccessat for file-existence tests
This is faster than using stat since it doesn't have to gather all
the metadata, and should avoid LFS issues as a result.
Bug: https://bugs.gentoo.org/583282
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r-- | libsbutil/src/file.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/libsbutil/src/file.c b/libsbutil/src/file.c index 4542ae5..a1a4a0e 100644 --- a/libsbutil/src/file.c +++ b/libsbutil/src/file.c @@ -15,19 +15,7 @@ bool rc_file_exists (const char *pathname) { - struct stat buf; - int retval; - - if (!check_str (pathname)) - return false; - - retval = lstat (pathname, &buf); - if (-1 != retval) - retval = true; - else - retval = false; - - return retval; + return faccessat(AT_FDCWD, pathname, F_OK, AT_SYMLINK_NOFOLLOW) == 0; } bool |