return xtab_read(_PATH_ETAB, 1);
}
+/*
+ * mountd now keeps an open fd for the etab at all times to make sure that the
+ * inode number changes when the xtab_export_write is done. If you change the
+ * routine below such that the files are edited in place, then you'll need to
+ * fix the auth_reload logic as well...
+ */
static int
xtab_write(char *xtab, char *xtabtmp, int is_export)
{
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
+#include <unistd.h>
#include "misc.h"
#include "nfslib.h"
#include "exportfs.h"
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 *
get_exportlist(void)
{
static exports elist = NULL;
- static time_t etime = 0;
- time_t atime;
struct exportnode *e, *ne;
struct groupnode *g, *ng, *c, **cp;
nfs_export *exp;
int i;
+ static unsigned int ecounter;
+ unsigned int acounter;
- atime = auth_reload();
- if (elist && atime == etime)
+ acounter = auth_reload();
+ if (elist && acounter == ecounter)
return elist;
- etime = atime;
+ ecounter = acounter;
for (e = elist; e != NULL; e = ne) {
ne = e->ex_next;
void mount_dispatch(struct svc_req *, SVCXPRT *);
void auth_init(char *export_file);
-time_t auth_reload(void);
+unsigned int auth_reload(void);
nfs_export * auth_authenticate(char *what, struct sockaddr_in *sin,
char *path);
void auth_export(nfs_export *exp);