[Samba] Need a cross-platform lockfile algorithm
Phil Endecott
spam_from_samba at chezphil.org
Mon Oct 29 22:55:25 GMT 2007
Dear Experts,
I'm hoping that your experience with SMB and CIFS means that you're
familiar with cross-platform file locking. I need a
lowest-common-denominator whole-file locking method that will work on
as many combinations of client and server systems as possible; in
particular it needs to run on
- Linux client talking to NFS server.
- Linux client talking to Samba server.
- Linux client talking to Windows server.
- Windows client talking to Samba server.
- Windows client talking to Windows server.
- Linux local disk access.
- Windows local disk access.
No doubt each of those combinations has many variations.
I only need advisory locking, not mandatory locking; a lockfile
convention would be fine. I'm hoping that something like the algorithm
used by liblockfile could be used (see man lockfile_create, e.g.
http://pwet.fr/man/linux/fonctions_bibliotheques/lockfile_create).
Basically it creates a file with a unique name, links it to the
<filename>.lock file, and uses stat() to see if its link got there
before any other contender. This is designed to be NFS-safe but I
don't know if it would be possible or safe in an SMB or CIFS environment.
I'm sure this must have been solved before but I can't find anything
especially helpful; maybe I'm not searching for the right keywords.
If anyone can point me in the right direction I would be very grateful.
Regards,
Phil.
More information about the samba
mailing list