Skip to content

Commit

Permalink
options/linux: Handle statx-specific flags when emulating it with stat
Browse files Browse the repository at this point in the history
  • Loading branch information
qookei committed May 2, 2024
1 parent f43ff70 commit d7b897b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions options/linux/generic/sys-statx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ int statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct
if(!mlibc::sys_statx) {
struct stat statbuf;
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_stat, -1);

if (!(flags & AT_NO_AUTOMOUNT)) {
mlibc::infoLogger()
<< "mlibc: sys_statx is unavailable, and stat does not support not specifying AT_NO_MOUNTPOINT"
<< frg::endlog;
}

// AT_STATX_SYNC_AS_STAT is the default and behaves like good old stat
if ((flags & AT_STATX_FORCE_SYNC) || (flags & AT_STATX_DONT_SYNC)) {
mlibc::infoLogger()
<< "mlibc: sys_statx is unavailable, and stat does not support modes other than AT_STATX_SYNC_AS_STAT"
<< frg::endlog;
}

// Mask out flags not appropriate for regular stat
flags &= ~(AT_NO_AUTOMOUNT | AT_STATX_SYNC_AS_STAT | AT_STATX_FORCE_SYNC | AT_STATX_DONT_SYNC);

if(int e = mlibc::sys_stat(mlibc::fsfd_target::fd_path, dirfd, pathname, flags, &statbuf); e) {
errno = e;
return -1;
Expand Down

0 comments on commit d7b897b

Please sign in to comment.