sahlberg / libnfs

NFS client library
Other
524 stars 201 forks source link

question about the locks semantic #422

Closed stsp closed 7 months ago

stsp commented 1 year ago

libnfs seems to mimic the posix API so I wonder what semantic does the lockf() and NFS4_F_SETLK provide. Posix semantic is a per-process locks, that are AFAIK shared by all fds referring to the same file, and are all released once any fd of that file is closed. Linux also has F_OFD_SETLK that doesn't have such limitations, but I can't see anything with "OFD" in its name in libnfs.

So what kind of locking does libnfs provide? Can write lock be set on an O_RDONLY file?

sahlberg commented 1 year ago

No real thought has gone into the lock semantics as locking is generally uncommon.

If you want to define the semantics and improve the code by sending a pull request, that would be awesome!