aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAlan Swanson <reiver@improbability.net>2018-10-04 13:45:50 -0400
committerSteve Dickson <steved@redhat.com>2018-10-04 13:54:09 -0400
commitcec1278cdb385188cdf6b693fda1b00f9b93df55 (patch)
tree82c999c406a66d005755abee52163fba83cc01b9 /utils
parentf48d08f1148c9e0652f69f8274090970ca48a9fe (diff)
downloadnfs-utils-cec1278cdb385188cdf6b693fda1b00f9b93df55.tar.gz
idmapd: Use inotify instead of dnotify
Remove last use of dnotify in nfs-utils by bringing idmapd upto date with (required) inotify use by gssd and blkmapd. Acked-by: J. Bruce Fields <bfields@fieldses.org> Signed-off-by: Alan Swanson <reiver@improbability.net> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/idmapd/idmapd.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
index d14eef73..91c02537 100644
--- a/utils/idmapd/idmapd.c
+++ b/utils/idmapd/idmapd.c
@@ -36,7 +36,7 @@
#include <sys/types.h>
#include <sys/time.h>
-#include <sys/poll.h>
+#include <sys/inotify.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <time.h>
@@ -205,15 +205,16 @@ static void usage(char *progname)
int
main(int argc, char **argv)
{
- int fd = 0, opt, fg = 0, nfsdret = -1;
+ int wd = -1, opt, fg = 0, nfsdret = -1;
struct idmap_clientq icq;
- struct event rootdirev, clntdirev, svrdirev;
+ struct event rootdirev, clntdirev, svrdirev, inotifyev;
struct event initialize;
struct passwd *pw;
struct group *gr;
struct stat sb;
char *xpipefsdir = NULL;
int serverstart = 1, clientstart = 1;
+ int inotify_fd;
int ret;
char *progname;
char *conf_path = NULL;
@@ -381,18 +382,15 @@ main(int argc, char **argv)
}
}
- if ((fd = open(pipefsdir, O_RDONLY)) == -1)
- xlog_err("main: open(%s): %s", pipefsdir, strerror(errno));
-
- if (fcntl(fd, F_SETSIG, SIGUSR1) == -1)
- xlog_err("main: fcntl(%s): %s", pipefsdir, strerror(errno));
-
- if (fcntl(fd, F_NOTIFY,
- DN_CREATE | DN_DELETE | DN_MODIFY | DN_MULTISHOT) == -1) {
- xlog_err("main: fcntl(%s): %s", pipefsdir, strerror(errno));
- if (errno == EINVAL)
- xlog_err("main: Possibly no Dnotify support in kernel.");
+ inotify_fd = inotify_init1(IN_NONBLOCK);
+ if (inotify_fd == -1) {
+ xlog_err("Unable to initialise inotify_init1: %s\n", strerror(errno));
+ } else {
+ wd = inotify_add_watch(inotify_fd, pipefsdir, IN_CREATE | IN_DELETE | IN_MODIFY);
+ if (wd < 0)
+ xlog_err("Unable to inotify_add_watch(%s): %s\n", pipefsdir, strerror(errno));
}
+
TAILQ_INIT(&icq);
/* These events are persistent */
@@ -402,6 +400,10 @@ main(int argc, char **argv)
signal_add(&clntdirev, NULL);
signal_set(&svrdirev, SIGHUP, svrreopen, NULL);
signal_add(&svrdirev, NULL);
+ if ( wd >= 0) {
+ event_set(&inotifyev, inotify_fd, EV_READ, dirscancb, &icq);
+ event_add(&inotifyev, NULL);
+ }
/* Fetch current state */
/* (Delay till start of event_dispatch to avoid possibly losing
@@ -410,7 +412,7 @@ main(int argc, char **argv)
evtimer_add(&initialize, &now);
}
- if (nfsdret != 0 && fd == 0)
+ if (nfsdret != 0 && wd < 0)
xlog_err("main: Neither NFS client nor NFSd found");
daemon_ready();