Skip to content
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

Support syscall mmap2 #47

Closed
rick-masters opened this issue Nov 7, 2023 · 2 comments · Fixed by #48
Closed

Support syscall mmap2 #47

rick-masters opened this issue Nov 7, 2023 · 2 comments · Fixed by #48
Labels
enhancement New feature or request

Comments

@rick-masters
Copy link
Contributor

Please support syscall mmap2.
mmap2 is similar to mmap except that the offset argument is multiplied by 4096 to compute the effective offset.
This supports very large offsets for very large files.
The mmap2 system call is used by the musl C library to implement mmap, so mmap2 is needed for musl even if large offsets are not needed.

mmap2 takes 6 arguments which requires CONFIG_SYSCALL_6TH_ARG to be set.
For this reason, mmap2 is defined behind CONFIG_MMAP2.

For testing, both CONFIG_SYSCALL_6TH_ARG and CONFIG_MMAP2 should be set.
A custom_config.h can be used for this purpose like so:

echo '#define CONFIG_SYSCALL_6TH_ARG' > include/fiwix/custom_config.h
echo '#define CONFIG_MMAP2' >> include/fiwix/custom_config.h
make clean
make CONFFLAGS="-DCUSTOM_CONFIG_H"

A test program for mmap2 and a test script to build and run the test program is attached.
The test script produces an input file with random data and the runs the test program.
The test program mmap's the input file and output file with an offset of 4096.
The test program then copies data from the input file to the output file using memory.

The test script then extracts the contents of the input and output file starting with offset 4096 and verifies that they are the same.
mmap2-test.c.gz
mmap2.sh.gz

@mikaku
Copy link
Owner

mikaku commented Nov 7, 2023

I can't believe that instead of a whole new system call. they didn't create a new flag for this simple change.

@mikaku mikaku closed this as completed in #48 Nov 7, 2023
@mikaku
Copy link
Owner

mikaku commented Nov 7, 2023

Thank you very much.

@mikaku mikaku added the enhancement New feature or request label Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants