node-fs-ext icon indicating copy to clipboard operation
node-fs-ext copied to clipboard

record-level locking...

Open tracker1 opened this issue 11 years ago • 3 comments

It would be nice if you can do a record level lock for read/write...

fs.flock(fd, 'sh', function(err){
  fs.flockRead(bytesToRead, function(err, buffer){
    //buffer should be the bytes read after an exclusive lock of that record
    // offset at the current position, for the length of the bytes requested to read.
  });
  fs.flockWrite(buffer, function(err){})
});

tracker1 avatar Oct 21 '14 07:10 tracker1

flock doesn't support record level locking: https://linux.die.net/man/2/flock

sam-github avatar Feb 06 '19 17:02 sam-github

I think it's only possible on Windows (not sure if there's mechanisms to do this on Unix-like OS's). It seems like a terribly fragile piece of technology to use, and must be NTFS only.

On Wed, Feb 6, 2019 at 12:59 PM Sam Roberts [email protected] wrote:

flock doesn't support record level locking: https://linux.die.net/man/2/flock

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/baudehlo/node-fs-ext/issues/35#issuecomment-461122578, or mute the thread https://github.com/notifications/unsubscribe-auth/AAobYyWdOmics4V9synZmWeOce1gTxToks5vKxflgaJpZM4CxEIX .

baudehlo avatar Feb 06 '19 18:02 baudehlo

Unixen have byte-range locking:

  • http://man7.org/linux/man-pages/man3/lockf.3.html
  • Advisory record locking in http://man7.org/linux/man-pages/man2/fcntl.2.html

sam-github avatar Feb 06 '19 20:02 sam-github