Commit Graph

3 Commits

Author SHA1 Message Date
Ville Juven 07ce2f717a shmfs/shmfs_alloc. Fix POSIX violation for shmfs_truncate
When shmfs_truncate is called, it uses shmfs_alloc_object to create the
physical backing for the shm file. However, the allocated physical
memory returned by mm_pgalloc is not cleared when CONFIG_BUILD_KERNEL is
set, which is a clear POSIX violation:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html

"If the file was previously shorter than length, its size is increased,
and the extended area appears as if it were zero-filled."

For FLAT and PROTECTED modes zalloc is used, so the violation affects
KERNEL mode only.
2024-02-02 09:09:55 -08:00
Petro Karashchenko 2c972bd402 fs/shm: update pointer arithmetic logic
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-01-26 10:26:09 +08:00
Jukka Laitinen a0ebddaac1 fs/shm: Add initial implementation for posix shared memory
This implements the file system logic for posix shared memory:
shm_open, shm_unlink, mmap, munmap and close

For flat and protected builds the memory simply allocated from (user) heap

For kernel build the memory is allocated from page pool and mapped with MMU

This doesn't yet support protection flags or re-sizing already truncated shared
memory area.

Co-authored-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-18 11:01:20 +08:00