X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fstatd.c;h=321f7a945a81533da91ff8e1a8bc7b317c1e349f;hb=7131fc33fa6928187b639fddac49769895064f7d;hp=091ced9316e9220408fb7799004c297b8c0fd9ec;hpb=4f7fc41f6324daad94c37e9327567d27a0d50afe;p=nfs-utils.git diff --git a/utils/statd/statd.c b/utils/statd/statd.c index 091ced9..321f7a9 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -75,7 +75,7 @@ static struct option longopts[] = }; extern void sm_prog_1 (struct svc_req *, register SVCXPRT *); -extern int statd_get_socket(void); +static void load_state_number(void); #ifdef SIMULATIONS extern void simulator (int, char **); @@ -147,7 +147,7 @@ static void log_modes(void) * help the occasional admin. */ static void -usage() +usage(void) { fprintf(stderr,"usage: %s [options]\n", name_p); fprintf(stderr," -h, -?, --help Print this help screen.\n"); @@ -444,7 +444,7 @@ int main (int argc, char **argv) /* Child. */ - log_init (name_p,version_p); + log_init (/*name_p,version_p*/); log_modes(); @@ -476,14 +476,15 @@ int main (int argc, char **argv) } /* Make sure we have a privilege port for calling into the kernel */ - statd_get_socket(); + if (statd_get_socket() < 0) + exit(1); /* If sm-notify didn't take all the state files, load * state information into our notify-list so we can * pass on any SM_NOTIFY that arrives */ load_state(); - + load_state_number(); pmap_unset (SM_PROG, SM_VERS); /* this registers both UDP and TCP services */ @@ -526,3 +527,23 @@ int main (int argc, char **argv) } return 0; } + +static void +load_state_number(void) +{ + int fd; + + if ((fd = open(SM_STAT_PATH, O_RDONLY)) == -1) + return; + + read(fd, &MY_STATE, sizeof(MY_STATE)); + close(fd); + fd = open("/proc/sys/fs/nfs/nsm_local_state",O_WRONLY); + if (fd >= 0) { + char buf[20]; + snprintf(buf, sizeof(buf), "%d", MY_STATE); + write(fd, buf, strlen(buf)); + close(fd); + } + +}