Kevin-Jin / mmap

Forked from https://r-forge.r-project.org/scm/?group_id=648
1 stars 1 forks source link

Fix problems with requesting just `PROT_READ` on a non-writable file #24

Closed Kevin-Jin closed 7 years ago

Kevin-Jin commented 7 years ago

Currently, files are always opened with O_RDWR. However, O_RDONLY may be sufficient for users who'll never request PROT_WRITE. If this is the case, the user should be able to specify oflag to the POSIX open() and shm_open() functions so that the file system does not deny access to the file. As usual, perform the necessary translations to support the same behavior on the Win32 analogues.

In order to fully support oflag, then the O_CREAT flag must be supported and so must the mode parameter of open() and shm_open(). The behavior of mode is probably best emulated by Windows's access control lists using the concepts of effective user and primary group.

Kevin-Jin commented 7 years ago

By default, the O_CREAT flag should be set for shared memory so that it is created if it does not already exist. Do not set the flag for file-backed memory so that, by default, the mmap R constructor fails if the file does not already exist. In any case, this behavior should all be customizable by the user through the oflag parameter to the mmap R constructor.