Print this page
195 Need replacement for nfs/lockd+klm
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Jeremy Jones <jeremy@delphix.com>
Reviewed by: Jeff Biseda <jbiseda@delphix.com>

@@ -34,11 +34,13 @@
  * University Acknowledgment- Portions of this document are derived from
  * software developed by the University of California, Berkeley, and its
  * contributors.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
 
 /*
  * sm_statd.c consists of routines used for the intermediate
  * statd implementation(3.2 rpc.statd);
  * it creates an entry in "current" directory for each site that it monitors;

@@ -128,12 +130,12 @@
          * Scan alternate paths for largest "state" number
          */
         for (i = 0; i < pathix; i++) {
                 (void) sprintf(state_file, "%s/statmon/state", path_name[i]);
                 if ((fp_tmp = fopen(state_file, "r+")) == (FILE *)NULL) {
-                        if ((fp_tmp = fopen(state_file, "w+"))
-                                == (FILE *)NULL) {
+                        if ((fp_tmp = fopen(state_file, "w+")) ==
+                            (FILE *)NULL) {
                                 if (debug)
                                     syslog(LOG_ERR,
                                         "can't open %s: %m",
                                         state_file);
                                 continue;

@@ -178,12 +180,12 @@
         (void) fclose(fp);
 
         for (i = 0; i < pathix; i++) {
                 (void) sprintf(state_file, "%s/statmon/state", path_name[i]);
                 if ((fp_tmp = fopen(state_file, "r+")) == (FILE *)NULL) {
-                        if ((fp_tmp = fopen(state_file, "w+"))
-                                == (FILE *)NULL) {
+                        if ((fp_tmp = fopen(state_file, "w+")) ==
+                            (FILE *)NULL) {
                                 syslog(LOG_ERR,
                                     "can't open %s: %m", state_file);
                                 continue;
                         } else
                                 (void) chmod(state_file, 0644);

@@ -304,12 +306,12 @@
 
                 /* Create a thread to do a statd_call_statd for name */
                 if (thr_create(NULL, NULL, thr_call_statd,
                                         (void *) name, 0, 0)) {
                         syslog(LOG_ERR,
-                "statd: unable to create thr_call_statd() for name %s.\n",
-                                dirp->d_name);
+                            "statd: unable to create thr_call_statd() "
+                            "for name %s.\n", dirp->d_name);
                         free(name);
                         continue;
                 }
                 num_threads++;
         }

@@ -379,12 +381,12 @@
 
                 /* Create a thread to do a statd_call_statd for name */
                 if (thr_create(NULL, NULL, thr_call_statd,
                                         (void *) name, 0, 0)) {
                         syslog(LOG_ERR,
-                "statd: unable to create thr_call_statd() for name %s.\n",
-                                dirp->d_name);
+                            "statd: unable to create thr_call_statd() "
+                            "for name %s.\n", dirp->d_name);
                         free(name);
                         continue;
                 }
                 num_threads++;
         }

@@ -487,12 +489,12 @@
                 if (is_symlink(path)) {
                         n = readlink(path, rname, MAXNAMELEN);
                         if (n <= 0) {
                                 if (debug >= 2) {
                                         (void) printf(
-                                        "thr_call_statd: can't read link %s\n",
-                                                        path);
+                                            "thr_call_statd: can't read "
+                                            "link %s\n", path);
                                 }
                         } else {
                                 rname[n] = '\0';
 
                                 tail = strrchr(path, '/') + 1;

@@ -579,12 +581,12 @@
         }
 
         tottimeout.tv_sec = SM_RPC_TIMEOUT;
         tottimeout.tv_usec = 0;
 
-        if ((clnt = create_client(name_or_addr, SM_PROG, SM_VERS,
-            &tottimeout)) == (CLIENT *) NULL) {
+        if ((clnt = create_client(name_or_addr, SM_PROG, SM_VERS, NULL,
+            &tottimeout)) == NULL) {
                 return (-1);
         }
 
         /* Perform notification to client */
         rc = 0;

@@ -673,12 +675,12 @@
                                  * Print message only once since unreachable
                                  * host can be contacted forever.
                                  */
                                 if (delay == 0)
                                         syslog(LOG_WARNING,
-                                        "statd: host %s is not responding\n",
-                                                nl->name);
+                                            "statd: host %s is not "
+                                            "responding\n", nl->name);
                         }
                 }
                 /*
                  * Increment the amount of delay before restarting again.
                  * The amount of delay should not exceed the MAX_DELAYTIME.

@@ -1033,12 +1035,12 @@
         int n, error;
         char path[MAXPATHLEN+MAXNAMELEN+SM_MAXPATHLEN]; /* why > MAXPATHLEN? */
         char dirpath[MAXPATHLEN];
         char rname[MAXNAMELEN + 1]; /* +1 for NULL term */
 
-        if (strlen(name) + strlen(dir1) + (dir2 != NULL ? strlen(dir2) : 0)
-                        + 3 > MAXPATHLEN) {
+        if (strlen(name) + strlen(dir1) + (dir2 != NULL ? strlen(dir2) : 0) +
+            3 > MAXPATHLEN) {
                 if (dir2 != NULL)
                         syslog(LOG_ERR,
                                 "statd: pathname too long: %s/%s/%s\n",
                                                 dir1, dir2, name);
                 else

@@ -1076,16 +1078,17 @@
                                 (void) strcat(dirpath, rname);
                                 error = unlink(dirpath);
                                 if (debug >= 2) {
                                         if (error < 0) {
                                                 (void) printf(
-                                        "remove_name: can't unlink %s\n",
+                                                    "remove_name: can't "
+                                                    "unlink %s\n",
                                                         dirpath);
                                         } else {
                                                 (void) printf(
-                                        "remove_name: unlinked %s\n",
-                                                        dirpath);
+                                                    "remove_name: unlinked ",
+                                                    "%s\n", dirpath);
                                         }
                                 }
                         }
                 } else {
                         /*

@@ -1139,12 +1142,12 @@
                          */
                         n = readlink(lpath, rname, MAXNAMELEN);
                         if (n <= 0) {
                                 if (debug >= 2) {
                                         (void) printf(
-                                        "count_symlinks: can't read link %s\n",
-                                                lpath);
+                                            "count_symlinks: can't read link "
+                                            "%s\n", lpath);
                                 }
                                 continue;
                         }
                         rname[n] = '\0';
 

@@ -1363,13 +1366,12 @@
                 break;
 
             default:
                 if (debug) {
                         (void) printf(
-                "record_addr: family2string supports unknown family %d (%s)\n",
-                                family,
-                                famstr);
+                            "record_addr: family2string supports unknown "
+                            "family %d (%s)\n", family, famstr);
                 }
                 free(famstr);
                 return;
         }