-
Notifications
You must be signed in to change notification settings - Fork 666
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
refactor: change name arg of memfd_create() to &NixPath #2431
refactor: change name arg of memfd_create() to &NixPath #2431
Conversation
libc::memfd_create(cstr.as_ptr(), flags.bits()) | ||
} else { | ||
libc::syscall(libc::SYS_memfd_create, name.as_ptr(), flags.bits()) | ||
libc::syscall(libc::SYS_memfd_create, cstr.as_ptr(), flags.bits()) |
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.
Is it possible we always use the else
branch? Or does it have any drawback?
From tokio-rs/tracing#1879 I'm afraid that using libc::memfd_create
may fail on some old GNU toolchain.
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.
Right, because the glibc wrapper may only be available since a specific version, and if you are using an older glibc and this Nix wrapper, the code won't compile. But raw syscalls are inherently unsafe, Nix tries to avoid it if possible.
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.
Honestly, this kind of thing has always been bothering me. I just created a tracking issue #2538 for these interfaces. May I ask about the issue you encountered with this?
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.
the issue you encountered with this?
Not in real-world, but a blocker I don't use nix at fast/logforth#80 (memfd.rs)
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.
Perhaps we should wrap the raw syscall. 😪
If we want to discuss this further, let's discuss it there #2538.
What does this PR do
name
argument ofmemfd_create()
from&CStr
to&NixPath
.Add a test for(Update: The test was removed because the symbolmemfd_create()
.memfd_create
is not available under our QEMU test and I cannot find a way to stop the linker from involving it)Checklist:
CONTRIBUTING.md
Breaking changes
This is not a breaking change, since
CStr
hasNixPath
implemented.