-
-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle AT_EMPTY_PATH for fstatat64 #1812
base: master
Are you sure you want to change the base?
Conversation
This is used by newer glibc when loading shared objects. AT_EMPTY_PATH (since Linux 2.6.39) If pathname is an empty string, operate on the file referred to by dirfd (which may have been ob‐ tained using the open(2) O_PATH flag). In this case, dirfd can refer to any type of file, not just a directory, and the behavior of fstatat() is similar to that of fstat(). If dirfd is AT_FDCWD, the call operates on the current working directory. This flag is Linux-specific; de‐ fine _GNU_SOURCE to obtain its definition.
…engli-master Merging upstream PR ish-app#1812
Merge upstream PR ish-app#1812
Thank |
Thk |
zhaofengli:fstat-empty-path |
nix on iSH? 👀 |
@@ -49,17 +69,18 @@ static struct fd *at_fd(fd_t f) { | |||
return f_get(f); | |||
} | |||
|
|||
static dword_t sys_stat_path(fd_t at_f, addr_t path_addr, addr_t statbuf_addr, bool follow_links) { | |||
// The `flags` parameter accepts AT_ flags | |||
static dword_t sys_stat_path(fd_t at_f, addr_t path_addr, addr_t statbuf_addr, int flags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function now has the exact signature of sys_fstatat64 so maybe rename to sys_fstatat64
at = current->fs->pwd; | ||
} | ||
|
||
err = generic_getpath(at, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this should be calling fstat instead
This PR adds correct handling for the
AT_EMPTY_PATH
flag infstatat64
.AT_EMPTY_PATH
allows an empty string to be specified as the path, in which casefstatat
should operate on the file pointed at by the fd itself:This behavior is relied on by newer glibc when loading shared objects. Currently we return
-ENOENT
for empty paths, leading to behavior like:With the fix:
Note that many glibc programs are still broken. I'm playing around with getting a Nix-based environment running in iSH and while I was able to start bash and run some small programs, Nix itself still doesn't run:
getcontext()
andsetcontext()
save and restorefs
(racket needs fs register #370)5 illegal instruction at 0xf749e35f: 66 8c e2 89 50 18 8d 88
(mov dx, fs
)