Trond,
Thanks for the info. Here is a section of the man page for open.
Is the information it gives correct wrt using link & stat?
O_EXCL When used with O_CREAT, if the file already exists
it is an error and the open will fail. In this con
text, a symbolic link exists, regardless of where
its points to. O_EXCL is broken on NFS file sys
tems, programs which rely on it for performing
locking tasks will contain a race condition. The
solution for performing atomic file locking using a
lockfile is to create a unique file on the same fs
(e.g., incorporating hostname and pid), use link(2)
to make a link to the lockfile. If link() returns
0, the lock is successful. Otherwise, use stat(2)
on the unique file to check if its link count has
increased to 2, in which case the lock is also suc
cessful.
Thanks,
Jim
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/