]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Support "-P path" in statd as alternate to /var/lib/nfs
authorneilbrown <neilbrown>
Mon, 2 Sep 2002 02:14:53 +0000 (02:14 +0000)
committerneilbrown <neilbrown>
Mon, 2 Sep 2002 02:14:53 +0000 (02:14 +0000)
ChangeLog
utils/statd/monitor.c
utils/statd/notify.c
utils/statd/statd.c
utils/statd/statd.h
utils/statd/statd.man

index c50ca92025eb5be497d07d8e8bd6a7dbe7505ea0..363141c9c17d4ce2f99427b62735b9a031fb68b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-09-02 Juan Gomez <juang@us.ibm.com>
+       NeilBrown <neilb@cse.unsw.edu.au>
+
+       statd to have " -P directory" arg to use that directory instead
+       of /var/lib/nfs.  This is useful for fail-over clusters.
+       
+       * utils/statd/statd.h: define SM_DIR etc as var, not const.
+       * utils/statd/statd.c: define "-P" option to set SM_*
+       appropriately.
+       * utils/statd/monitor.c: sprintf to cope with SM_DIR not being
+       a constant any more.
+       * utils/statd/notify.c: ditto.
+       * utils/statd/statd.man: document -P option.
+       
 2002-08-26  Chip Salzenberg  <chip@pobox.com>
 
        * utils/nfsd/nfsd.man: Fix typo.
 2002-08-26  Chip Salzenberg  <chip@pobox.com>
 
        * utils/nfsd/nfsd.man: Fix typo.
index 27c409f97abaf473a148107cf1fa49d89722e10d..732bf8214b8fb893931ed2e66b418cb5a09e66fc 100644 (file)
@@ -168,7 +168,7 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp)
         */
 
        path=xmalloc(strlen(SM_DIR)+strlen(mon_name)+2);
         */
 
        path=xmalloc(strlen(SM_DIR)+strlen(mon_name)+2);
-       sprintf(path, SM_DIR "/%s", mon_name);
+       sprintf(path, "%s/%s", SM_DIR, mon_name);
        if ((fd = open(path, O_WRONLY|O_SYNC|O_CREAT, S_IRUSR|S_IWUSR)) < 0) {
                /* Didn't fly.  We won't monitor. */
                log(L_ERROR, "creat(%s) failed: %m", path);
        if ((fd = open(path, O_WRONLY|O_SYNC|O_CREAT, S_IRUSR|S_IWUSR)) < 0) {
                /* Didn't fly.  We won't monitor. */
                log(L_ERROR, "creat(%s) failed: %m", path);
index 89d2946abcc7d7c3ef6a36f26869fe742448d10c..c3b4ca58365416dece3d1c3f3764eb9da7243bfa 100644 (file)
@@ -55,7 +55,7 @@ notify_hosts(void)
                        char *fname;
                        fname=xmalloc(strlen(SM_BAK_DIR)+sizeof(de->d_name)+2);
                        dprintf(L_DEBUG, "We're on our own notify list?!?");
                        char *fname;
                        fname=xmalloc(strlen(SM_BAK_DIR)+sizeof(de->d_name)+2);
                        dprintf(L_DEBUG, "We're on our own notify list?!?");
-                       sprintf(fname, SM_BAK_DIR "/%s", de->d_name);
+                       sprintf(fname, "%s/%s",  SM_BAK_DIR, de->d_name);
                        if (unlink(fname)) 
                                log(L_ERROR, "unlink(%s): %s", 
                                        fname, strerror(errno));
                        if (unlink(fname)) 
                                log(L_ERROR, "unlink(%s): %s", 
                                        fname, strerror(errno));
index 4fc135abee256c58484947734f3e8a415aa85787..3a6ed61eace92dc5d31a1fc66bb9301d47b6ce01 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
 
+/* Added to enable specification of state directory path at run-time
+ * j_carlos_gomez@yahoo.com
+ */
+
+char * DIR_BASE = DEFAULT_DIR_BASE;
+
+char *  SM_DIR = DEFAULT_SM_DIR;
+char *  SM_BAK_DIR =  DEFAULT_SM_BAK_DIR;
+char *  SM_STAT_PATH = DEFAULT_SM_STAT_PATH;
+
+/* ----- end of state directory path stuff ------- */
 
 short int restart = 0;
 int    run_mode = 0;           /* foreground logging mode */
 
 short int restart = 0;
 int    run_mode = 0;           /* foreground logging mode */
@@ -43,6 +54,7 @@ static struct option longopts[] =
        { "outgoing-port", 1, 0, 'o' },
        { "port", 1, 0, 'p' },
        { "name", 1, 0, 'n' },
        { "outgoing-port", 1, 0, 'o' },
        { "port", 1, 0, 'p' },
        { "name", 1, 0, 'n' },
+       { "state-directory-path", 1, 0, 'P' },
        { NULL, 0, 0, 0 }
 };
 
        { NULL, 0, 0, 0 }
 };
 
@@ -128,6 +140,7 @@ usage()
        fprintf(stderr,"      -o, --outgoing-port  Port for outgoing connections\n");
        fprintf(stderr,"      -V, -v, --version    Display version information and exit.\n");
        fprintf(stderr,"      -n, --name           Specify a local hostname.\n");
        fprintf(stderr,"      -o, --outgoing-port  Port for outgoing connections\n");
        fprintf(stderr,"      -V, -v, --version    Display version information and exit.\n");
        fprintf(stderr,"      -n, --name           Specify a local hostname.\n");
+       fprintf(stderr,"      -P                   State directory path.\n");
 }
 
 /* 
 }
 
 /* 
@@ -161,7 +174,7 @@ int main (int argc, char **argv)
        MY_NAME = NULL;
 
        /* Process command line switches */
        MY_NAME = NULL;
 
        /* Process command line switches */
-       while ((arg = getopt_long(argc, argv, "h?vVFdn:p:o:", longopts, NULL)) != EOF) {
+       while ((arg = getopt_long(argc, argv, "h?vVFdn:p:o:P:", longopts, NULL)) != EOF) {
                switch (arg) {
                case 'V':       /* Version */
                case 'v':
                switch (arg) {
                case 'V':       /* Version */
                case 'v':
@@ -194,6 +207,36 @@ int main (int argc, char **argv)
                case 'n':       /* Specify local hostname */
                        MY_NAME = xstrdup(optarg);
                        break;
                case 'n':       /* Specify local hostname */
                        MY_NAME = xstrdup(optarg);
                        break;
+               case 'P':
+
+                       if ((DIR_BASE = xstrdup(optarg)) == NULL) {
+                               fprintf(stderr, "%s: xstrdup(%s) failed!\n",
+                                       argv[0], optarg);
+                               exit(1);
+                       }
+
+                       SM_DIR = xmalloc(strlen(DIR_BASE) + 1 + sizeof("sm"));
+                       SM_BAK_DIR = xmalloc(strlen(DIR_BASE) + 1 + sizeof("sm.bak"));
+                       SM_STAT_PATH = xmalloc(strlen(DIR_BASE) + 1 + sizeof("state"));
+
+                       if ((SM_DIR == NULL) 
+                           || (SM_BAK_DIR == NULL) 
+                           || (SM_STAT_PATH == NULL)) {
+
+                               fprintf(stderr, "%s: xmalloc() failed!\n",
+                                       argv[0]);
+                               exit(1);
+                       }
+                       if (DIR_BASE[strlen(DIR_BASE)-1] == '/') {
+                               sprintf(SM_DIR, "%ssm", DIR_BASE );
+                               sprintf(SM_BAK_DIR, "%ssm.bak", DIR_BASE );
+                               sprintf(SM_STAT_PATH, "%sstate", DIR_BASE );
+                       } else {
+                               sprintf(SM_DIR, "%s/sm", DIR_BASE );
+                               sprintf(SM_BAK_DIR, "%s/sm.bak", DIR_BASE );
+                               sprintf(SM_STAT_PATH, "%s/state", DIR_BASE );
+                       }
+                       break;
                case '?':       /* heeeeeelllllllpppp? heh */
                case 'h':
                        usage();
                case '?':       /* heeeeeelllllllpppp? heh */
                case 'h':
                        usage();
index 5476d503aa8107c5eb8d2ea0b8aee6fa3939d225..5e2b6fd0679491e106d7458a6e9c9d295f126f25 100644 (file)
  * Paths and filenames.
  */
 #if defined(NFS_STATEDIR)
  * Paths and filenames.
  */
 #if defined(NFS_STATEDIR)
-# define DIR_BASE      NFS_STATEDIR "/"
+# define DEFAULT_DIR_BASE      NFS_STATEDIR "/"
 #else
 #else
-# define DIR_BASE      "/var/lib/nfs/"
+# define DEFAULT_DIR_BASE      "/var/lib/nfs/"
 #endif
 #endif
-#define SM_DIR         DIR_BASE "sm"
-#define SM_BAK_DIR     DIR_BASE "sm.bak"
-#define SM_STAT_PATH   DIR_BASE "state"
+
+#define DEFAULT_SM_DIR         DEFAULT_DIR_BASE "sm"
+#define DEFAULT_SM_BAK_DIR     DEFAULT_DIR_BASE "sm.bak"
+#define DEFAULT_SM_STAT_PATH   DEFAULT_DIR_BASE "state"
+
+/* Added to support run-time specification of state directory path.
+ * j_carlos_gomez@yahoo.com
+ */
+
+extern char * DIR_BASE;
+extern char *  SM_DIR;
+extern char *  SM_BAK_DIR;
+extern char *  SM_STAT_PATH;
 
 /*
  * Status definitions.
 
 /*
  * Status definitions.
index dbe8be1db5911c069426743dc36657dfc9c6289d..2b10803a0cc19a55b6f7f95498925b4d984f3fc7 100644 (file)
@@ -89,6 +89,12 @@ a standard port number that
 always or usually assigns.  Specifying
 a port may be useful when implementing a firewall.
 .TP
 always or usually assigns.  Specifying
 a port may be useful when implementing a firewall.
 .TP
+.BI "\-P," "" " \-\-state\-directory\-path "  directory
+specify a directory in which to place statd state information.
+If this option is not specified the default of 
+.BR /var/lib/nfs
+is used.
+.TP
 .B -?
 Causes
 .B rpc.statd
 .B -?
 Causes
 .B rpc.statd