-
Notifications
You must be signed in to change notification settings - Fork 161
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
fs: using -EBADF as a dirfd argument #1187
Comments
sunfishcode
added a commit
that referenced
this issue
Oct 17, 2024
Add a `rustix::fs::ABS` constant, which corresponds to the undocumented but commonly used convention of using `-EBADF` as the file descriptor in `openat` and similar calls. This makes them fail if the path is not absolute. Fixes #1187.
Interesting, I hadn't heard of that convention before. I think defining a new |
sunfishcode
added a commit
that referenced
this issue
Oct 18, 2024
Add a `rustix::fs::ABS` constant, which corresponds to the undocumented but commonly used convention of using `-EBADF` as the file descriptor in `openat` and similar calls. This makes them fail if the path is not absolute. Fixes #1187.
sunfishcode
added a commit
that referenced
this issue
Oct 27, 2024
Add a `rustix::fs::ABS` constant, which corresponds to the undocumented but commonly used convention of using `-EBADF` as the file descriptor in `openat` and similar calls. This makes them fail if the path is not absolute. Fixes #1187.
sunfishcode
added a commit
that referenced
this issue
Oct 27, 2024
Add a `rustix::fs::ABS` constant, which corresponds to the undocumented but commonly used convention of using `-EBADF` as the file descriptor in `openat` and similar calls. This makes them fail if the path is not absolute. Fixes #1187.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some programs want to ensure that no paths are resolved relative to the current directory, and so use
-EBADF
as a file descriptor argument so that an error is returned if the path is not absolute. This is a fairly common pattern, but unfortunately rustix does not allow it:The one-line patch for this is fairly straightforward (only disallow
-1
since that's an invalidBorrowedFd
value) but I wanted to make sure that there wasn't a nicer solution (maybe we should just define a newCWD
-like constant akin tono_fd
so users can just re-use that).The text was updated successfully, but these errors were encountered: