-
Notifications
You must be signed in to change notification settings - Fork 137
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
Syscalls: add support for memfd_create #2005
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change moves the call to filesystem_update_mtime() from the truncate callback of filesystem drivers to the generic filesystem code that invokes the callback. Beside removing duplicated code, this change will allow building filesystem drivers as klibs (which cannot call the now() function directly because it references the __vdso_vdso_dat hidden symbol).
This change allows creating temporary files (i.e. files that are not associated to a directory entry and are deleted when closed) on filesystems other than TFS. The create callback of existing filesystem drivers has been amended to be able to create temporary files (or return FS_STATUS_INVAL if this feature is not supported). This change will be needed when support for memfd_create() is added.
This function undoes what filesystem_init() does; it is used in the TFS code when destroying a filesystem, instead of calling directly pagecache_dealloc_volume().
Code that uses a file table to enumerate file metadata tuples and to establish a correspondence between metadata tuples and fsfile structs has been moved from tfs.c to fs.c and fs.h. It will be reused when implementing tmpfs.
The body of this new function has been extracted from open_internal(). This change will allow userspace to open regular files via syscalls other than open() and similar, i.e. syscalls that do not reference a filesystem path, such as memfd_create(). The file struct has been modified to embed all fdesc closures, so that individual allocations and deallocations for each closure when opening and closing a file are no longer necessary.
This macro is a more lightweight version of register_syscall(), and can be used to initialize the name and flags of a syscall without configuring a handler. It is now used for all non-supported syscalls. If a klib implementing additional syscalls is loaded, it can call swap_syscall_handler() instead of register_syscall().
This dependency is already listed in the run targets of the top- level Makefile; having this dependency also in the platform Makefiles causes the disk image to be created twice at each execution of a runtime test.
This syscall creates an anonymous file that behaves like a regular file, and so can be modified, truncated, memory-mapped, and so on, but, unlike a regular file, lives in RAM and has a volatile backing storage. This syscall is implemented in a new "shmem" klib, which is meant to contain the implementation of all shared-memory features in the kernel. The memfd implementation relies on an underlying tmpfs filesystem, which is implemented in another new klib named "tmpfs" (which in the future can be used to create arbitrary RAM-backed filesystems and mount them at arbitrary locations in the root filesystem). Closes #1986.
francescolavra
force-pushed
the
feature/memfd
branch
from
March 7, 2024 15:31
3c44474
to
b869f60
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This syscall creates an anonymous file that behaves like a regular file, and so can be modified, truncated, memory-mapped, and so on, but, unlike a regular file, lives in RAM and has a volatile backing storage.
This syscall is implemented in a new "shmem" klib, which is meant to contain the implementation of all shared-memory features in the kernel. The memfd implementation relies on an underlying tmpfs filesystem, which is implemented in another new klib named "tmpfs" (which in the future can be used to create arbitrary RAM-backed filesystems and mount them at arbitrary locations in the root filesystem).
Closes #1986.