diff options
author | Ben Myers <bpm@sgi.com> | 2009-04-03 15:13:10 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2009-04-03 15:13:10 -0400 |
commit | f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4 (patch) | |
tree | e525bec15e10a3c984dbc6b26b075a7433e0d417 /utils/mountd/rmtab.c | |
parent | c56152202a3000c69b87f9cb90f40166f1f21275 (diff) | |
download | nfs-utils-f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4.tar.gz nfs-utils-f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4.tar.xz nfs-utils-f0ed8401e854e1cbd23b2fb5dca5e88dec2df7c4.zip |
Mountd should use separate lockfiles
Mountd keeps file descriptors used for locks separate from
those used for io and seems to assume that the lock will
only be released on close of the file descriptor that was used
with fcntl. Actually the lock is released when any file
descriptor for that file is closed. When setexportent() is called
after xflock() he closes and reopens the io file descriptor and defeats the
lock.
This patch fixes that by using a separate file for locking, cleaning
them up when finished.
Signed-off-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/mountd/rmtab.c')
-rw-r--r-- | utils/mountd/rmtab.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/utils/mountd/rmtab.c b/utils/mountd/rmtab.c index 5787ed6..c371f8d 100644 --- a/utils/mountd/rmtab.c +++ b/utils/mountd/rmtab.c @@ -58,7 +58,7 @@ mountlist_add(char *host, const char *path) int lockid; long pos; - if ((lockid = xflock(_PATH_RMTAB, "a")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "a")) < 0) return; setrmtabent("r+"); while ((rep = getrmtabent(1, &pos)) != NULL) { @@ -98,7 +98,7 @@ mountlist_del(char *hname, const char *path) int lockid; int match; - if ((lockid = xflock(_PATH_RMTAB, "w")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "w")) < 0) return; if (!setrmtabent("r")) { xfunlock(lockid); @@ -139,7 +139,7 @@ mountlist_del_all(struct sockaddr_in *sin) FILE *fp; int lockid; - if ((lockid = xflock(_PATH_RMTAB, "w")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "w")) < 0) return; if (!(hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET))) { xlog(L_ERROR, "can't get hostname of %s", inet_ntoa(addr)); @@ -188,7 +188,7 @@ mountlist_list(void) struct in_addr addr; struct hostent *he; - if ((lockid = xflock(_PATH_RMTAB, "r")) < 0) + if ((lockid = xflock(_PATH_RMTABLCK, "r")) < 0) return NULL; if (stat(_PATH_RMTAB, &stb) < 0) { xlog(L_ERROR, "can't stat %s", _PATH_RMTAB); |