summaryrefslogtreecommitdiffstats
path: root/utils/mountd/auth.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2007-05-09 10:19:33 -0400
committerNeil Brown <neilb@suse.de>2007-05-11 13:33:56 +1000
commitfd9097110f74f39bce89ec3a341fd9b686a68719 (patch)
tree3cae6aad996e95b0436770d97ef0e1bda1a4119d /utils/mountd/auth.c
parent89fb5a45d2020aaee203dd9016d98c3ff9d9f991 (diff)
downloadnfs-utils-fd9097110f74f39bce89ec3a341fd9b686a68719.tar.gz
nfs-utils-fd9097110f74f39bce89ec3a341fd9b686a68719.tar.xz
nfs-utils-fd9097110f74f39bce89ec3a341fd9b686a68719.zip
nfs-utils: have mountd hold open etab file to force inode number to change
This patch changes mountd to hold the etab file open so that when it's changed by exportfs, the inode number should change. We then change auth_reload to reload the file based on whether st_ino is different from the last time it was checked. It also changes auth_reload to maintain a static counter value and return it instead of a timestamp and fixes up get_exportlist accordingly. Finally, it adds some comments to xtab_write to warn people about editing the etab in place. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'utils/mountd/auth.c')
-rw-r--r--utils/mountd/auth.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c
index 183c9ea..f7fe23d 100644
--- a/utils/mountd/auth.c
+++ b/utils/mountd/auth.c
@@ -14,6 +14,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
+#include <unistd.h>
#include "misc.h"
#include "nfslib.h"
#include "exportfs.h"
@@ -46,24 +47,34 @@ auth_init(char *exports)
xtab_mount_write();
}
-time_t
+unsigned int
auth_reload()
{
struct stat stb;
- static time_t last_modified = 0;
-
- if (stat(_PATH_ETAB, &stb) < 0)
+ static ino_t last_inode;
+ static int last_fd;
+ static unsigned int counter;
+ int fd;
+
+ if ((fd = open(_PATH_ETAB, O_RDONLY)) < 0) {
+ xlog(L_FATAL, "couldn't open %s", _PATH_ETAB);
+ } else if (fstat(fd, &stb) < 0) {
xlog(L_FATAL, "couldn't stat %s", _PATH_ETAB);
- if (stb.st_mtime == last_modified)
- return last_modified;
- last_modified = stb.st_mtime;
+ } else if (stb.st_ino == last_inode) {
+ close(fd);
+ return counter;
+ } else {
+ close(last_fd);
+ last_fd = fd;
+ last_inode = stb.st_ino;
+ }
export_freeall();
memset(&my_client, 0, sizeof(my_client));
- // export_read(export_file);
xtab_export_read();
+ ++counter;
- return last_modified;
+ return counter;
}
static nfs_export *