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 **);
int arg;
int port = 0, out_port = 0;
struct rlimit rlim;
- int once = 1;
int pipefds[2] = { -1, -1};
char status;
* pass on any SM_NOTIFY that arrives
*/
load_state();
+ load_state_number();
+ pmap_unset (SM_PROG, SM_VERS);
- for (;;) {
- pmap_unset (SM_PROG, SM_VERS);
+ /* this registers both UDP and TCP services */
+ rpc_init("statd", SM_PROG, SM_VERS, sm_prog_1, port);
- /* If we got this far, we have successfully started, so notify parent */
- if (pipefds[1] > 0) {
- status = 0;
- write(pipefds[1], &status, 1);
- close(pipefds[1]);
- pipefds[1] = -1;
- }
+ /* If we got this far, we have successfully started, so notify parent */
+ if (pipefds[1] > 0) {
+ status = 0;
+ write(pipefds[1], &status, 1);
+ close(pipefds[1]);
+ pipefds[1] = -1;
+ }
- /* this registers both UDP and TCP services */
- rpc_init("statd", SM_PROG, SM_VERS, sm_prog_1, port);
+ drop_privs();
- if (once) {
- once = 0;
- drop_privs();
- }
+ for (;;) {
/*
* Handle incoming requests: SM_NOTIFY socket requests, as
* well as callbacks from lockd.
}
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);
+ }
+
+}