Sample Header Ad - 728x90

Unix-esque partial-file-locking mechanism

1 vote
1 answer
72 views
Linux and AFAIK most unixes expose the flock syscall for mandatory file-locking. My experience is admittedly limited with this, however am informed that it is kernel-enforced on the entire resource. But what if I wanted to only lock a part of a file mandatorily, such that read/writes to this resource are permitted, as long as they don't cross a particular boundary or stop reading once it reaches an outer bound of the locked region. Is this possible? ## Edit: Possible Implementation A possibility for advisory partial locking may be via MMaped regions, where the memory is mapped into each reader's address-space, on the condition that the requested region does not hold a lock. This would be implemented entirely in user-space, and thus loses the advantages of kernel-enforced locking, but would certainly work
Asked by J-Cake (229 rep)
Sep 3, 2023, 12:33 PM
Last activity: Sep 3, 2023, 01:50 PM