fa739ae
diff --git a/support/include/conffile.h b/support/include/conffile.h
fa739ae
index ce7aa21..05ea5d2 100644
fa739ae
--- a/support/include/conffile.h
fa739ae
+++ b/support/include/conffile.h
fa739ae
@@ -54,7 +54,7 @@ extern int      conf_end(int, int);
fa739ae
 extern void     conf_free_list(struct conf_list *);
fa739ae
 extern struct sockaddr *conf_get_address(char *, char *);
fa739ae
 extern struct conf_list *conf_get_list(char *, char *);
fa739ae
-extern struct conf_list *conf_get_tag_list(char *);
fa739ae
+extern struct conf_list *conf_get_tag_list(char *, char *);
fa739ae
 extern int      conf_get_num(char *, char *, int);
fa739ae
 extern char    *conf_get_str(char *, char *);
fa739ae
 extern char    *conf_get_section(char *, char *, char *);
fa739ae
diff --git a/support/include/nfs/nfs.h b/support/include/nfs/nfs.h
fa739ae
index 174c2dd..38db5b5 100644
fa739ae
--- a/support/include/nfs/nfs.h
fa739ae
+++ b/support/include/nfs/nfs.h
fa739ae
@@ -15,6 +15,10 @@
fa739ae
 #define NFSD_MINVERS 2
fa739ae
 #define NFSD_MAXVERS 4
fa739ae
 
fa739ae
+#define NFS4_MINMINOR 1
fa739ae
+#define NFS4_MAXMINOR 2
fa739ae
+#define NFS4_VERDEFAULT  0x1  /* minor verion 1 */
fa739ae
+
fa739ae
 struct nfs_fh_len {
fa739ae
 	int		fh_size;
fa739ae
 	u_int8_t	fh_handle[NFS3_FHSIZE];
fa739ae
@@ -52,6 +56,7 @@ struct nfs_fh_old {
fa739ae
 #define NFSCTL_UDPISSET(_cltbits)     ((_cltbits) & NFSCTL_UDPBIT) 
fa739ae
 #define NFSCTL_TCPISSET(_cltbits)     ((_cltbits) & NFSCTL_TCPBIT) 
fa739ae
 
fa739ae
+#define NFSCTL_VERDEFAULT (0xc)       /* versions 3 and 4 */
fa739ae
 #define NFSCTL_VERSET(_cltbits, _v)   ((_cltbits) |= (1 << ((_v) - 1))) 
fa739ae
 #define NFSCTL_UDPSET(_cltbits)       ((_cltbits) |= NFSCTL_UDPBIT)
fa739ae
 #define NFSCTL_TCPSET(_cltbits)       ((_cltbits) |= NFSCTL_TCPBIT)
fa739ae
diff --git a/support/include/nfsrpc.h b/support/include/nfsrpc.h
fa739ae
index a0b80e1..1bfae7a 100644
fa739ae
--- a/support/include/nfsrpc.h
fa739ae
+++ b/support/include/nfsrpc.h
fa739ae
@@ -156,6 +156,11 @@ extern unsigned long	nfs_pmap_getport(const struct sockaddr_in *,
fa739ae
 				const struct timeval *);
fa739ae
 
fa739ae
 /*
fa739ae
+ * Use nfs_pmap_getport to see if statd is running locally
fa739ae
+ */
fa739ae
+extern int nfs_probe_statd(void);
fa739ae
+
fa739ae
+/*
fa739ae
  * Contact a remote RPC service to discover whether it is responding
fa739ae
  * to requests.
fa739ae
  */
fa739ae
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
fa739ae
index 5015e94..c3434d5 100644
fa739ae
--- a/support/nfs/conffile.c
fa739ae
+++ b/support/nfs/conffile.c
fa739ae
@@ -565,7 +565,7 @@ cleanup:
fa739ae
 }
fa739ae
 
fa739ae
 struct conf_list *
fa739ae
-conf_get_tag_list(char *section)
fa739ae
+conf_get_tag_list(char *section, char *arg)
fa739ae
 {
fa739ae
 	struct conf_list *list = 0;
fa739ae
 	struct conf_list_node *node;
fa739ae
@@ -579,6 +579,8 @@ conf_get_tag_list(char *section)
fa739ae
 	cb = LIST_FIRST(&conf_bindings[conf_hash (section)]);
fa739ae
 	for (; cb; cb = LIST_NEXT(cb, link)) {
fa739ae
 		if (strcasecmp (section, cb->section) == 0) {
fa739ae
+			if (arg != NULL && strcasecmp(arg, cb->arg) != 0)
fa739ae
+				continue;
fa739ae
 			list->cnt++;
fa739ae
 			node = calloc(1, sizeof *node);
fa739ae
 			if (!node)
fa739ae
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
fa739ae
index dea040f..05178f7 100644
fa739ae
--- a/support/nfs/exports.c
fa739ae
+++ b/support/nfs/exports.c
fa739ae
@@ -196,10 +196,35 @@ getexportent(int fromkernel, int fromexports)
fa739ae
 	return ⅇ
fa739ae
 }
fa739ae
 
fa739ae
+static const struct secinfo_flag_displaymap {
fa739ae
+	unsigned int flag;
fa739ae
+	const char *set;
fa739ae
+	const char *unset;
fa739ae
+} secinfo_flag_displaymap[] = {
fa739ae
+	{ NFSEXP_READONLY, "ro", "rw" },
fa739ae
+	{ NFSEXP_INSECURE_PORT, "insecure", "secure" },
fa739ae
+	{ NFSEXP_ROOTSQUASH, "root_squash", "no_root_squash" },
fa739ae
+	{ NFSEXP_ALLSQUASH, "all_squash", "no_all_squash" },
fa739ae
+	{ 0, NULL, NULL }
fa739ae
+};
fa739ae
+
fa739ae
+static void secinfo_flags_show(FILE *fp, unsigned int flags, unsigned int mask)
fa739ae
+{
fa739ae
+	const struct secinfo_flag_displaymap *p;
fa739ae
+
fa739ae
+	for (p = &secinfo_flag_displaymap[0]; p->flag != 0; p++) {
fa739ae
+		if (!(mask & p->flag))
fa739ae
+			continue;
fa739ae
+		fprintf(fp, ",%s", (flags & p->flag) ? p->set : p->unset);
fa739ae
+	}
fa739ae
+}
fa739ae
+
fa739ae
 void secinfo_show(FILE *fp, struct exportent *ep)
fa739ae
 {
fa739ae
+	const struct export_features *ef;
fa739ae
 	struct sec_entry *p1, *p2;
fa739ae
-	int flags;
fa739ae
+
fa739ae
+	ef = get_export_features();
fa739ae
 
fa739ae
 	for (p1=ep->e_secinfo; p1->flav; p1=p2) {
fa739ae
 
fa739ae
@@ -208,12 +233,7 @@ void secinfo_show(FILE *fp, struct exportent *ep)
fa739ae
 								p2++) {
fa739ae
 			fprintf(fp, ":%s", p2->flav->flavour);
fa739ae
 		}
fa739ae
-		flags = p1->flags;
fa739ae
-		fprintf(fp, ",%s", (flags & NFSEXP_READONLY) ? "ro" : "rw");
fa739ae
-		fprintf(fp, ",%sroot_squash", (flags & NFSEXP_ROOTSQUASH)?
fa739ae
-				"" : "no_");
fa739ae
-		fprintf(fp, ",%sall_squash", (flags & NFSEXP_ALLSQUASH)?
fa739ae
-				"" : "no_");
fa739ae
+		secinfo_flags_show(fp, p1->flags, ef->secinfo_flags);
fa739ae
 	}
fa739ae
 }
fa739ae
 
fa739ae
diff --git a/support/nfs/getport.c b/support/nfs/getport.c
fa739ae
index 3331ad4..081594c 100644
fa739ae
--- a/support/nfs/getport.c
fa739ae
+++ b/support/nfs/getport.c
fa739ae
@@ -1102,3 +1102,25 @@ unsigned long nfs_pmap_getport(const struct sockaddr_in *sin,
fa739ae
 
fa739ae
 	return port;
fa739ae
 }
fa739ae
+
fa739ae
+static const char *nfs_ns_pgmtbl[] = {
fa739ae
+        "status",
fa739ae
+        NULL,
fa739ae
+};
fa739ae
+
fa739ae
+/*
fa739ae
+ * nfs_probe_statd - use nfs_pmap_getport to see if statd is running locally
fa739ae
+ *
fa739ae
+ * Returns non-zero if statd is running locally.
fa739ae
+ */
fa739ae
+int nfs_probe_statd(void)
fa739ae
+{
fa739ae
+        struct sockaddr_in addr = {
fa739ae
+                .sin_family             = AF_INET,
fa739ae
+                .sin_addr.s_addr        = htonl(INADDR_LOOPBACK),
fa739ae
+        };
fa739ae
+        rpcprog_t program = nfs_getrpcbyname(NSMPROG, nfs_ns_pgmtbl);
fa739ae
+
fa739ae
+        return nfs_getport_ping((struct sockaddr *)(char *)&addr, sizeof(addr),
fa739ae
+                                program, (rpcvers_t)1, IPPROTO_UDP);
fa739ae
+}
fa739ae
diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py
fa739ae
index b95b71d..3f5fea5 100644
fa739ae
--- a/tools/mountstats/mountstats.py
fa739ae
+++ b/tools/mountstats/mountstats.py
fa739ae
@@ -53,7 +53,7 @@ class DeviceData:
fa739ae
             if words[6].find('nfs') != -1:
fa739ae
                 self.__nfs_data['statvers'] = words[7]
fa739ae
         elif words[0] == 'age:':
fa739ae
-            self.__nfs_data['age'] = long(words[1])
fa739ae
+            self.__nfs_data['age'] = int(words[1])
fa739ae
         elif words[0] == 'opts:':
fa739ae
             self.__nfs_data['mountoptions'] = ''.join(words[1:]).split(',')
fa739ae
         elif words[0] == 'caps:':
fa739ae
@@ -91,12 +91,12 @@ class DeviceData:
fa739ae
             self.__nfs_data['shortwrites'] = int(words[22])
fa739ae
             self.__nfs_data['delay'] = int(words[23])
fa739ae
         elif words[0] == 'bytes:':
fa739ae
-            self.__nfs_data['normalreadbytes'] = long(words[1])
fa739ae
-            self.__nfs_data['normalwritebytes'] = long(words[2])
fa739ae
-            self.__nfs_data['directreadbytes'] = long(words[3])
fa739ae
-            self.__nfs_data['directwritebytes'] = long(words[4])
fa739ae
-            self.__nfs_data['serverreadbytes'] = long(words[5])
fa739ae
-            self.__nfs_data['serverwritebytes'] = long(words[6])
fa739ae
+            self.__nfs_data['normalreadbytes'] = int(words[1])
fa739ae
+            self.__nfs_data['normalwritebytes'] = int(words[2])
fa739ae
+            self.__nfs_data['directreadbytes'] = int(words[3])
fa739ae
+            self.__nfs_data['directwritebytes'] = int(words[4])
fa739ae
+            self.__nfs_data['serverreadbytes'] = int(words[5])
fa739ae
+            self.__nfs_data['serverwritebytes'] = int(words[6])
fa739ae
 
fa739ae
     def __parse_rpc_line(self, words):
fa739ae
         if words[0] == 'RPC':
fa739ae
@@ -110,8 +110,8 @@ class DeviceData:
fa739ae
                 self.__rpc_data['rpcsends'] = int(words[4])
fa739ae
                 self.__rpc_data['rpcreceives'] = int(words[5])
fa739ae
                 self.__rpc_data['badxids'] = int(words[6])
fa739ae
-                self.__rpc_data['inflightsends'] = long(words[7])
fa739ae
-                self.__rpc_data['backlogutil'] = long(words[8])
fa739ae
+                self.__rpc_data['inflightsends'] = int(words[7])
fa739ae
+                self.__rpc_data['backlogutil'] = int(words[8])
fa739ae
             elif words[1] == 'tcp':
fa739ae
                 self.__rpc_data['port'] = words[2]
fa739ae
                 self.__rpc_data['bind_count'] = int(words[3])
fa739ae
@@ -121,7 +121,7 @@ class DeviceData:
fa739ae
                 self.__rpc_data['rpcsends'] = int(words[7])
fa739ae
                 self.__rpc_data['rpcreceives'] = int(words[8])
fa739ae
                 self.__rpc_data['badxids'] = int(words[9])
fa739ae
-                self.__rpc_data['inflightsends'] = long(words[10])
fa739ae
+                self.__rpc_data['inflightsends'] = int(words[10])
fa739ae
                 self.__rpc_data['backlogutil'] = int(words[11])
fa739ae
             elif words[1] == 'rdma':
fa739ae
                 self.__rpc_data['port'] = words[2]
fa739ae
@@ -148,7 +148,7 @@ class DeviceData:
fa739ae
         else:
fa739ae
             op = words[0][:-1]
fa739ae
             self.__rpc_data['ops'] += [op]
fa739ae
-            self.__rpc_data[op] = [long(word) for word in words[1:]]
fa739ae
+            self.__rpc_data[op] = [int(word) for word in words[1:]]
fa739ae
 
fa739ae
     def parse_stats(self, lines):
fa739ae
         """Turn a list of lines from a mount stat file into a 
fa739ae
@@ -179,81 +179,81 @@ class DeviceData:
fa739ae
     def display_nfs_options(self):
fa739ae
         """Pretty-print the NFS options
fa739ae
         """
fa739ae
-        print 'Stats for %s mounted on %s:' % \
fa739ae
-            (self.__nfs_data['export'], self.__nfs_data['mountpoint'])
fa739ae
-
fa739ae
-        print '  NFS mount options: %s' % ','.join(self.__nfs_data['mountoptions'])
fa739ae
-        print '  NFS server capabilities: %s' % ','.join(self.__nfs_data['servercapabilities'])
fa739ae
-        if self.__nfs_data.has_key('nfsv4flags'):
fa739ae
-            print '  NFSv4 capability flags: %s' % ','.join(self.__nfs_data['nfsv4flags'])
fa739ae
-        if self.__nfs_data.has_key('pseudoflavor'):
fa739ae
-            print '  NFS security flavor: %d  pseudoflavor: %d' % \
fa739ae
-                (self.__nfs_data['flavor'], self.__nfs_data['pseudoflavor'])
fa739ae
+        print('Stats for %s mounted on %s:' % \
fa739ae
+            (self.__nfs_data['export'], self.__nfs_data['mountpoint']))
fa739ae
+
fa739ae
+        print('  NFS mount options: %s' % ','.join(self.__nfs_data['mountoptions']))
fa739ae
+        print('  NFS server capabilities: %s' % ','.join(self.__nfs_data['servercapabilities']))
fa739ae
+        if 'nfsv4flags' in self.__nfs_data:
fa739ae
+            print('  NFSv4 capability flags: %s' % ','.join(self.__nfs_data['nfsv4flags']))
fa739ae
+        if 'pseudoflavor' in self.__nfs_data:
fa739ae
+            print('  NFS security flavor: %d  pseudoflavor: %d' % \
fa739ae
+                (self.__nfs_data['flavor'], self.__nfs_data['pseudoflavor']))
fa739ae
         else:
fa739ae
-            print '  NFS security flavor: %d' % self.__nfs_data['flavor']
fa739ae
+            print('  NFS security flavor: %d' % self.__nfs_data['flavor'])
fa739ae
 
fa739ae
     def display_nfs_events(self):
fa739ae
         """Pretty-print the NFS event counters
fa739ae
         """
fa739ae
-        print
fa739ae
-        print 'Cache events:'
fa739ae
-        print '  data cache invalidated %d times' % self.__nfs_data['datainvalidates']
fa739ae
-        print '  attribute cache invalidated %d times' % self.__nfs_data['attrinvalidates']
fa739ae
-        print '  inodes synced %d times' % self.__nfs_data['syncinodes']
fa739ae
-        print
fa739ae
-        print 'VFS calls:'
fa739ae
-        print '  VFS requested %d inode revalidations' % self.__nfs_data['inoderevalidates']
fa739ae
-        print '  VFS requested %d dentry revalidations' % self.__nfs_data['dentryrevalidates']
fa739ae
-        print
fa739ae
-        print '  VFS called nfs_readdir() %d times' % self.__nfs_data['vfsreaddir']
fa739ae
-        print '  VFS called nfs_lookup() %d times' % self.__nfs_data['vfslookup']
fa739ae
-        print '  VFS called nfs_permission() %d times' % self.__nfs_data['vfspermission']
fa739ae
-        print '  VFS called nfs_file_open() %d times' % self.__nfs_data['vfsopen']
fa739ae
-        print '  VFS called nfs_file_flush() %d times' % self.__nfs_data['vfsflush']
fa739ae
-        print '  VFS called nfs_lock() %d times' % self.__nfs_data['vfslock']
fa739ae
-        print '  VFS called nfs_fsync() %d times' % self.__nfs_data['vfsfsync']
fa739ae
-        print '  VFS called nfs_file_release() %d times' % self.__nfs_data['vfsrelease']
fa739ae
-        print
fa739ae
-        print 'VM calls:'
fa739ae
-        print '  VFS called nfs_readpage() %d times' % self.__nfs_data['vfsreadpage']
fa739ae
-        print '  VFS called nfs_readpages() %d times' % self.__nfs_data['vfsreadpages']
fa739ae
-        print '  VFS called nfs_writepage() %d times' % self.__nfs_data['vfswritepage']
fa739ae
-        print '  VFS called nfs_writepages() %d times' % self.__nfs_data['vfswritepages']
fa739ae
-        print
fa739ae
-        print 'Generic NFS counters:'
fa739ae
-        print '  File size changing operations:'
fa739ae
-        print '    truncating SETATTRs: %d  extending WRITEs: %d' % \
fa739ae
-            (self.__nfs_data['setattrtrunc'], self.__nfs_data['extendwrite'])
fa739ae
-        print '  %d silly renames' % self.__nfs_data['sillyrenames']
fa739ae
-        print '  short reads: %d  short writes: %d' % \
fa739ae
-            (self.__nfs_data['shortreads'], self.__nfs_data['shortwrites'])
fa739ae
-        print '  NFSERR_DELAYs from server: %d' % self.__nfs_data['delay']
fa739ae
+        print()
fa739ae
+        print('Cache events:')
fa739ae
+        print('  data cache invalidated %d times' % self.__nfs_data['datainvalidates'])
fa739ae
+        print('  attribute cache invalidated %d times' % self.__nfs_data['attrinvalidates'])
fa739ae
+        print('  inodes synced %d times' % self.__nfs_data['syncinodes'])
fa739ae
+        print()
fa739ae
+        print('VFS calls:')
fa739ae
+        print('  VFS requested %d inode revalidations' % self.__nfs_data['inoderevalidates'])
fa739ae
+        print('  VFS requested %d dentry revalidations' % self.__nfs_data['dentryrevalidates'])
fa739ae
+        print()
fa739ae
+        print('  VFS called nfs_readdir() %d times' % self.__nfs_data['vfsreaddir'])
fa739ae
+        print('  VFS called nfs_lookup() %d times' % self.__nfs_data['vfslookup'])
fa739ae
+        print('  VFS called nfs_permission() %d times' % self.__nfs_data['vfspermission'])
fa739ae
+        print('  VFS called nfs_file_open() %d times' % self.__nfs_data['vfsopen'])
fa739ae
+        print('  VFS called nfs_file_flush() %d times' % self.__nfs_data['vfsflush'])
fa739ae
+        print('  VFS called nfs_lock() %d times' % self.__nfs_data['vfslock'])
fa739ae
+        print('  VFS called nfs_fsync() %d times' % self.__nfs_data['vfsfsync'])
fa739ae
+        print('  VFS called nfs_file_release() %d times' % self.__nfs_data['vfsrelease'])
fa739ae
+        print()
fa739ae
+        print('VM calls:')
fa739ae
+        print('  VFS called nfs_readpage() %d times' % self.__nfs_data['vfsreadpage'])
fa739ae
+        print('  VFS called nfs_readpages() %d times' % self.__nfs_data['vfsreadpages'])
fa739ae
+        print('  VFS called nfs_writepage() %d times' % self.__nfs_data['vfswritepage'])
fa739ae
+        print('  VFS called nfs_writepages() %d times' % self.__nfs_data['vfswritepages'])
fa739ae
+        print()
fa739ae
+        print('Generic NFS counters:')
fa739ae
+        print('  File size changing operations:')
fa739ae
+        print('    truncating SETATTRs: %d  extending WRITEs: %d' % \
fa739ae
+            (self.__nfs_data['setattrtrunc'], self.__nfs_data['extendwrite']))
fa739ae
+        print('  %d silly renames' % self.__nfs_data['sillyrenames'])
fa739ae
+        print('  short reads: %d  short writes: %d' % \
fa739ae
+            (self.__nfs_data['shortreads'], self.__nfs_data['shortwrites']))
fa739ae
+        print('  NFSERR_DELAYs from server: %d' % self.__nfs_data['delay'])
fa739ae
 
fa739ae
     def display_nfs_bytes(self):
fa739ae
         """Pretty-print the NFS event counters
fa739ae
         """
fa739ae
-        print
fa739ae
-        print 'NFS byte counts:'
fa739ae
-        print '  applications read %d bytes via read(2)' % self.__nfs_data['normalreadbytes']
fa739ae
-        print '  applications wrote %d bytes via write(2)' % self.__nfs_data['normalwritebytes']
fa739ae
-        print '  applications read %d bytes via O_DIRECT read(2)' % self.__nfs_data['directreadbytes']
fa739ae
-        print '  applications wrote %d bytes via O_DIRECT write(2)' % self.__nfs_data['directwritebytes']
fa739ae
-        print '  client read %d bytes via NFS READ' % self.__nfs_data['serverreadbytes']
fa739ae
-        print '  client wrote %d bytes via NFS WRITE' % self.__nfs_data['serverwritebytes']
fa739ae
+        print()
fa739ae
+        print('NFS byte counts:')
fa739ae
+        print('  applications read %d bytes via read(2)' % self.__nfs_data['normalreadbytes'])
fa739ae
+        print('  applications wrote %d bytes via write(2)' % self.__nfs_data['normalwritebytes'])
fa739ae
+        print('  applications read %d bytes via O_DIRECT read(2)' % self.__nfs_data['directreadbytes'])
fa739ae
+        print('  applications wrote %d bytes via O_DIRECT write(2)' % self.__nfs_data['directwritebytes'])
fa739ae
+        print('  client read %d bytes via NFS READ' % self.__nfs_data['serverreadbytes'])
fa739ae
+        print('  client wrote %d bytes via NFS WRITE' % self.__nfs_data['serverwritebytes'])
fa739ae
 
fa739ae
     def display_rpc_generic_stats(self):
fa739ae
         """Pretty-print the generic RPC stats
fa739ae
         """
fa739ae
         sends = self.__rpc_data['rpcsends']
fa739ae
 
fa739ae
-        print
fa739ae
-        print 'RPC statistics:'
fa739ae
+        print()
fa739ae
+        print('RPC statistics:')
fa739ae
 
fa739ae
-        print '  %d RPC requests sent, %d RPC replies received (%d XIDs not found)' % \
fa739ae
-            (sends, self.__rpc_data['rpcreceives'], self.__rpc_data['badxids'])
fa739ae
+        print('  %d RPC requests sent, %d RPC replies received (%d XIDs not found)' % \
fa739ae
+            (sends, self.__rpc_data['rpcreceives'], self.__rpc_data['badxids']))
fa739ae
         if sends != 0:
fa739ae
-            print '  average backlog queue length: %d' % \
fa739ae
-                (float(self.__rpc_data['backlogutil']) / sends)
fa739ae
+            print('  average backlog queue length: %d' % \
fa739ae
+                (float(self.__rpc_data['backlogutil']) / sends))
fa739ae
 
fa739ae
     def display_rpc_op_stats(self):
fa739ae
         """Pretty-print the per-op stats
fa739ae
@@ -261,23 +261,23 @@ class DeviceData:
fa739ae
         sends = self.__rpc_data['rpcsends']
fa739ae
 
fa739ae
         # XXX: these should be sorted by 'count'
fa739ae
-        print
fa739ae
+        print()
fa739ae
         for op in self.__rpc_data['ops']:
fa739ae
             stats = self.__rpc_data[op]
fa739ae
             count = stats[0]
fa739ae
             retrans = stats[1] - count
fa739ae
             if count != 0:
fa739ae
-                print '%s:' % op
fa739ae
-                print '\t%d ops (%d%%)' % \
fa739ae
-                    (count, ((count * 100) / sends)),
fa739ae
-                print '\t%d retrans (%d%%)' % (retrans, ((retrans * 100) / count)),
fa739ae
-                print '\t%d major timeouts' % stats[2]
fa739ae
-                print '\tavg bytes sent per op: %d\tavg bytes received per op: %d' % \
fa739ae
-                    (stats[3] / count, stats[4] / count)
fa739ae
-                print '\tbacklog wait: %f' % (float(stats[5]) / count),
fa739ae
-                print '\tRTT: %f' % (float(stats[6]) / count),
fa739ae
-                print '\ttotal execute time: %f (milliseconds)' % \
fa739ae
-                    (float(stats[7]) / count)
fa739ae
+                print('%s:' % op)
fa739ae
+                print('\t%d ops (%d%%)' % \
fa739ae
+                    (count, ((count * 100) / sends)), end=' ')
fa739ae
+                print('\t%d retrans (%d%%)' % (retrans, ((retrans * 100) / count)), end=' ')
fa739ae
+                print('\t%d major timeouts' % stats[2])
fa739ae
+                print('\tavg bytes sent per op: %d\tavg bytes received per op: %d' % \
fa739ae
+                    (stats[3] / count, stats[4] / count))
fa739ae
+                print('\tbacklog wait: %f' % (float(stats[5]) / count), end=' ')
fa739ae
+                print('\tRTT: %f' % (float(stats[6]) / count), end=' ')
fa739ae
+                print('\ttotal execute time: %f (milliseconds)' % \
fa739ae
+                    (float(stats[7]) / count))
fa739ae
 
fa739ae
     def compare_iostats(self, old_stats):
fa739ae
         """Return the difference between two sets of stats
fa739ae
@@ -285,9 +285,9 @@ class DeviceData:
fa739ae
         result = DeviceData()
fa739ae
 
fa739ae
         # copy self into result
fa739ae
-        for key, value in self.__nfs_data.iteritems():
fa739ae
+        for key, value in self.__nfs_data.items():
fa739ae
             result.__nfs_data[key] = value
fa739ae
-        for key, value in self.__rpc_data.iteritems():
fa739ae
+        for key, value in self.__rpc_data.items():
fa739ae
             result.__rpc_data[key] = value
fa739ae
 
fa739ae
         # compute the difference of each item in the list
fa739ae
@@ -295,7 +295,7 @@ class DeviceData:
fa739ae
         # the reference to them.  so we build new lists here
fa739ae
         # for the result object.
fa739ae
         for op in result.__rpc_data['ops']:
fa739ae
-            result.__rpc_data[op] = map(difference, self.__rpc_data[op], old_stats.__rpc_data[op])
fa739ae
+            result.__rpc_data[op] = list(map(difference, self.__rpc_data[op], old_stats.__rpc_data[op]))
fa739ae
 
fa739ae
         # update the remaining keys we care about
fa739ae
         result.__rpc_data['rpcsends'] -= old_stats.__rpc_data['rpcsends']
fa739ae
@@ -312,17 +312,17 @@ class DeviceData:
fa739ae
         if sample_time == 0:
fa739ae
             sample_time = float(self.__nfs_data['age'])
fa739ae
 
fa739ae
-        print
fa739ae
-        print '%s mounted on %s:' % \
fa739ae
-            (self.__nfs_data['export'], self.__nfs_data['mountpoint'])
fa739ae
+        print()
fa739ae
+        print('%s mounted on %s:' % \
fa739ae
+            (self.__nfs_data['export'], self.__nfs_data['mountpoint']))
fa739ae
 
fa739ae
-        print '\top/s\trpc bklog'
fa739ae
-        print '\t%.2f' % (sends / sample_time), 
fa739ae
+        print('\top/s\trpc bklog')
fa739ae
+        print('\t%.2f' % (sends / sample_time), end=' ')
fa739ae
         if sends != 0:
fa739ae
-            print '\t%.2f' % \
fa739ae
-                ((float(self.__rpc_data['backlogutil']) / sends) / sample_time)
fa739ae
+            print('\t%.2f' % \
fa739ae
+                ((float(self.__rpc_data['backlogutil']) / sends) / sample_time))
fa739ae
         else:
fa739ae
-            print '\t0.00'
fa739ae
+            print('\t0.00')
fa739ae
 
fa739ae
         # reads:  ops/s, kB/s, avg rtt, and avg exe
fa739ae
         # XXX: include avg xfer size and retransmits?
fa739ae
@@ -332,15 +332,15 @@ class DeviceData:
fa739ae
         rtt = float(read_rpc_stats[6])
fa739ae
         exe = float(read_rpc_stats[7])
fa739ae
 
fa739ae
-        print '\treads:\tops/s\t\tkB/s\t\tavg RTT (ms)\tavg exe (ms)'
fa739ae
-        print '\t\t%.2f' % (ops / sample_time),
fa739ae
-        print '\t\t%.2f' % (kilobytes / sample_time),
fa739ae
+        print('\treads:\tops/s\t\tkB/s\t\tavg RTT (ms)\tavg exe (ms)')
fa739ae
+        print('\t\t%.2f' % (ops / sample_time), end=' ')
fa739ae
+        print('\t\t%.2f' % (kilobytes / sample_time), end=' ')
fa739ae
         if ops != 0:
fa739ae
-            print '\t\t%.2f' % (rtt / ops),
fa739ae
-            print '\t\t%.2f' % (exe / ops)
fa739ae
+            print('\t\t%.2f' % (rtt / ops), end=' ')
fa739ae
+            print('\t\t%.2f' % (exe / ops))
fa739ae
         else:
fa739ae
-            print '\t\t0.00',
fa739ae
-            print '\t\t0.00'
fa739ae
+            print('\t\t0.00', end=' ')
fa739ae
+            print('\t\t0.00')
fa739ae
 
fa739ae
         # writes:  ops/s, kB/s, avg rtt, and avg exe
fa739ae
         # XXX: include avg xfer size and retransmits?
fa739ae
@@ -350,15 +350,15 @@ class DeviceData:
fa739ae
         rtt = float(write_rpc_stats[6])
fa739ae
         exe = float(write_rpc_stats[7])
fa739ae
 
fa739ae
-        print '\twrites:\tops/s\t\tkB/s\t\tavg RTT (ms)\tavg exe (ms)'
fa739ae
-        print '\t\t%.2f' % (ops / sample_time),
fa739ae
-        print '\t\t%.2f' % (kilobytes / sample_time),
fa739ae
+        print('\twrites:\tops/s\t\tkB/s\t\tavg RTT (ms)\tavg exe (ms)')
fa739ae
+        print('\t\t%.2f' % (ops / sample_time), end=' ')
fa739ae
+        print('\t\t%.2f' % (kilobytes / sample_time), end=' ')
fa739ae
         if ops != 0:
fa739ae
-            print '\t\t%.2f' % (rtt / ops),
fa739ae
-            print '\t\t%.2f' % (exe / ops)
fa739ae
+            print('\t\t%.2f' % (rtt / ops), end=' ')
fa739ae
+            print('\t\t%.2f' % (exe / ops))
fa739ae
         else:
fa739ae
-            print '\t\t0.00',
fa739ae
-            print '\t\t0.00'
fa739ae
+            print('\t\t0.00', end=' ')
fa739ae
+            print('\t\t0.00')
fa739ae
 
fa739ae
 def parse_stats_file(filename):
fa739ae
     """pop the contents of a mountstats file into a dictionary,
fa739ae
@@ -388,18 +388,18 @@ def parse_stats_file(filename):
fa739ae
     return ms_dict
fa739ae
 
fa739ae
 def print_mountstats_help(name):
fa739ae
-    print 'usage: %s [ options ] <mount point>' % name
fa739ae
-    print
fa739ae
-    print ' Version %s' % Mountstats_version
fa739ae
-    print
fa739ae
-    print ' Display NFS client per-mount statistics.'
fa739ae
-    print
fa739ae
-    print '  --version    display the version of this command'
fa739ae
-    print '  --nfs        display only the NFS statistics'
fa739ae
-    print '  --rpc        display only the RPC statistics'
fa739ae
-    print '  --start      sample and save statistics'
fa739ae
-    print '  --end        resample statistics and compare them with saved'
fa739ae
-    print
fa739ae
+    print('usage: %s [ options ] <mount point>' % name)
fa739ae
+    print()
fa739ae
+    print(' Version %s' % Mountstats_version)
fa739ae
+    print()
fa739ae
+    print(' Display NFS client per-mount statistics.')
fa739ae
+    print()
fa739ae
+    print('  --version    display the version of this command')
fa739ae
+    print('  --nfs        display only the NFS statistics')
fa739ae
+    print('  --rpc        display only the RPC statistics')
fa739ae
+    print('  --start      sample and save statistics')
fa739ae
+    print('  --end        resample statistics and compare them with saved')
fa739ae
+    print()
fa739ae
 
fa739ae
 def mountstats_command():
fa739ae
     """Mountstats command
fa739ae
@@ -414,7 +414,7 @@ def mountstats_command():
fa739ae
             return
fa739ae
 
fa739ae
         if arg in ['-v', '--version', 'version']:
fa739ae
-            print '%s version %s' % (sys.argv[0], Mountstats_version)
fa739ae
+            print('%s version %s' % (sys.argv[0], Mountstats_version))
fa739ae
             sys.exit(0)
fa739ae
 
fa739ae
         if arg in ['-n', '--nfs']:
fa739ae
@@ -426,10 +426,10 @@ def mountstats_command():
fa739ae
             continue
fa739ae
 
fa739ae
         if arg in ['-s', '--start']:
fa739ae
-            raise Exception, 'Sampling is not yet implemented'
fa739ae
+            raise Exception('Sampling is not yet implemented')
fa739ae
 
fa739ae
         if arg in ['-e', '--end']:
fa739ae
-            raise Exception, 'Sampling is not yet implemented'
fa739ae
+            raise Exception('Sampling is not yet implemented')
fa739ae
 
fa739ae
         if arg == sys.argv[0]:
fa739ae
             continue
fa739ae
@@ -448,14 +448,14 @@ def mountstats_command():
fa739ae
 
fa739ae
     for mp in mountpoints:
fa739ae
         if mp not in mountstats:
fa739ae
-            print 'Statistics for mount point %s not found' % mp
fa739ae
+            print('Statistics for mount point %s not found' % mp)
fa739ae
             continue
fa739ae
 
fa739ae
         stats = DeviceData()
fa739ae
         stats.parse_stats(mountstats[mp])
fa739ae
 
fa739ae
         if not stats.is_nfs_mountpoint():
fa739ae
-            print 'Mount point %s exists but is not an NFS mount' % mp
fa739ae
+            print('Mount point %s exists but is not an NFS mount' % mp)
fa739ae
             continue
fa739ae
 
fa739ae
         if nfs_only:
fa739ae
@@ -472,37 +472,37 @@ def mountstats_command():
fa739ae
            stats.display_rpc_op_stats()
fa739ae
 
fa739ae
 def print_nfsstat_help(name):
fa739ae
-    print 'usage: %s [ options ]' % name
fa739ae
-    print
fa739ae
-    print ' Version %s' % Mountstats_version
fa739ae
-    print
fa739ae
-    print ' nfsstat-like program that uses NFS client per-mount statistics.'
fa739ae
-    print
fa739ae
+    print('usage: %s [ options ]' % name)
fa739ae
+    print()
fa739ae
+    print(' Version %s' % Mountstats_version)
fa739ae
+    print()
fa739ae
+    print(' nfsstat-like program that uses NFS client per-mount statistics.')
fa739ae
+    print()
fa739ae
 
fa739ae
 def nfsstat_command():
fa739ae
     print_nfsstat_help(prog)
fa739ae
 
fa739ae
 def print_iostat_help(name):
fa739ae
-    print 'usage: %s [ <interval> [ <count> ] ] [ <mount point> ] ' % name
fa739ae
-    print
fa739ae
-    print ' Version %s' % Mountstats_version
fa739ae
-    print
fa739ae
-    print ' iostat-like program to display NFS client per-mount statistics.'
fa739ae
-    print
fa739ae
-    print ' The <interval> parameter specifies the amount of time in seconds between'
fa739ae
-    print ' each report.  The first report contains statistics for the time since each'
fa739ae
-    print ' file system was mounted.  Each subsequent report contains statistics'
fa739ae
-    print ' collected during the interval since the previous report.'
fa739ae
-    print
fa739ae
-    print ' If the <count> parameter is specified, the value of <count> determines the'
fa739ae
-    print ' number of reports generated at <interval> seconds apart.  If the interval'
fa739ae
-    print ' parameter is specified without the <count> parameter, the command generates'
fa739ae
-    print ' reports continuously.'
fa739ae
-    print
fa739ae
-    print ' If one or more <mount point> names are specified, statistics for only these'
fa739ae
-    print ' mount points will be displayed.  Otherwise, all NFS mount points on the'
fa739ae
-    print ' client are listed.'
fa739ae
-    print
fa739ae
+    print('usage: %s [ <interval> [ <count> ] ] [ <mount point> ] ' % name)
fa739ae
+    print()
fa739ae
+    print(' Version %s' % Mountstats_version)
fa739ae
+    print()
fa739ae
+    print(' iostat-like program to display NFS client per-mount statistics.')
fa739ae
+    print()
fa739ae
+    print(' The <interval> parameter specifies the amount of time in seconds between')
fa739ae
+    print(' each report.  The first report contains statistics for the time since each')
fa739ae
+    print(' file system was mounted.  Each subsequent report contains statistics')
fa739ae
+    print(' collected during the interval since the previous report.')
fa739ae
+    print()
fa739ae
+    print(' If the <count> parameter is specified, the value of <count> determines the')
fa739ae
+    print(' number of reports generated at <interval> seconds apart.  If the interval')
fa739ae
+    print(' parameter is specified without the <count> parameter, the command generates')
fa739ae
+    print(' reports continuously.')
fa739ae
+    print()
fa739ae
+    print(' If one or more <mount point> names are specified, statistics for only these')
fa739ae
+    print(' mount points will be displayed.  Otherwise, all NFS mount points on the')
fa739ae
+    print(' client are listed.')
fa739ae
+    print()
fa739ae
 
fa739ae
 def print_iostat_summary(old, new, devices, time):
fa739ae
     for device in devices:
fa739ae
@@ -530,7 +530,7 @@ def iostat_command():
fa739ae
             return
fa739ae
 
fa739ae
         if arg in ['-v', '--version', 'version']:
fa739ae
-            print '%s version %s' % (sys.argv[0], Mountstats_version)
fa739ae
+            print('%s version %s' % (sys.argv[0], Mountstats_version))
fa739ae
             return
fa739ae
 
fa739ae
         if arg == sys.argv[0]:
fa739ae
@@ -543,14 +543,14 @@ def iostat_command():
fa739ae
             if interval > 0:
fa739ae
                 interval_seen = True
fa739ae
             else:
fa739ae
-                print 'Illegal <interval> value'
fa739ae
+                print('Illegal <interval> value')
fa739ae
                 return
fa739ae
         elif not count_seen:
fa739ae
             count = int(arg)
fa739ae
             if count > 0:
fa739ae
                 count_seen = True
fa739ae
             else:
fa739ae
-                print 'Illegal <count> value'
fa739ae
+                print('Illegal <count> value')
fa739ae
                 return
fa739ae
 
fa739ae
     # make certain devices contains only NFS mount points
fa739ae
@@ -563,13 +563,13 @@ def iostat_command():
fa739ae
                 check += [device]
fa739ae
         devices = check
fa739ae
     else:
fa739ae
-        for device, descr in mountstats.iteritems():
fa739ae
+        for device, descr in mountstats.items():
fa739ae
             stats = DeviceData()
fa739ae
             stats.parse_stats(descr)
fa739ae
             if stats.is_nfs_mountpoint():
fa739ae
                 devices += [device]
fa739ae
     if len(devices) == 0:
fa739ae
-        print 'No NFS mount points were found'
fa739ae
+        print('No NFS mount points were found')
fa739ae
         return
fa739ae
 
fa739ae
     old_mountstats = None
fa739ae
@@ -608,7 +608,7 @@ try:
fa739ae
     elif prog == 'ms-iostat':
fa739ae
         iostat_command()
fa739ae
 except KeyboardInterrupt:
fa739ae
-    print 'Caught ^C... exiting'
fa739ae
+    print('Caught ^C... exiting')
fa739ae
     sys.exit(1)
fa739ae
 
fa739ae
 sys.exit(0)
fa739ae
diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py
fa739ae
index dfbef87..341cdbf 100644
fa739ae
--- a/tools/nfs-iostat/nfs-iostat.py
fa739ae
+++ b/tools/nfs-iostat/nfs-iostat.py
fa739ae
@@ -95,7 +95,7 @@ class DeviceData:
fa739ae
             if words[6] == 'nfs':
fa739ae
                 self.__nfs_data['statvers'] = words[7]
fa739ae
         elif words[0] == 'age:':
fa739ae
-            self.__nfs_data['age'] = long(words[1])
fa739ae
+            self.__nfs_data['age'] = int(words[1])
fa739ae
         elif words[0] == 'opts:':
fa739ae
             self.__nfs_data['mountoptions'] = ''.join(words[1:]).split(',')
fa739ae
         elif words[0] == 'caps:':
fa739ae
@@ -116,7 +116,7 @@ class DeviceData:
fa739ae
         elif words[0] == 'bytes:':
fa739ae
             i = 1
fa739ae
             for key in NfsByteCounters:
fa739ae
-                self.__nfs_data[key] = long(words[i])
fa739ae
+                self.__nfs_data[key] = int(words[i])
fa739ae
                 i += 1
fa739ae
 
fa739ae
     def __parse_rpc_line(self, words):
fa739ae
@@ -131,8 +131,8 @@ class DeviceData:
fa739ae
                 self.__rpc_data['rpcsends'] = int(words[4])
fa739ae
                 self.__rpc_data['rpcreceives'] = int(words[5])
fa739ae
                 self.__rpc_data['badxids'] = int(words[6])
fa739ae
-                self.__rpc_data['inflightsends'] = long(words[7])
fa739ae
-                self.__rpc_data['backlogutil'] = long(words[8])
fa739ae
+                self.__rpc_data['inflightsends'] = int(words[7])
fa739ae
+                self.__rpc_data['backlogutil'] = int(words[8])
fa739ae
             elif words[1] == 'tcp':
fa739ae
                 self.__rpc_data['port'] = words[2]
fa739ae
                 self.__rpc_data['bind_count'] = int(words[3])
fa739ae
@@ -142,8 +142,8 @@ class DeviceData:
fa739ae
                 self.__rpc_data['rpcsends'] = int(words[7])
fa739ae
                 self.__rpc_data['rpcreceives'] = int(words[8])
fa739ae
                 self.__rpc_data['badxids'] = int(words[9])
fa739ae
-                self.__rpc_data['inflightsends'] = long(words[10])
fa739ae
-                self.__rpc_data['backlogutil'] = long(words[11])
fa739ae
+                self.__rpc_data['inflightsends'] = int(words[10])
fa739ae
+                self.__rpc_data['backlogutil'] = int(words[11])
fa739ae
             elif words[1] == 'rdma':
fa739ae
                 self.__rpc_data['port'] = words[2]
fa739ae
                 self.__rpc_data['bind_count'] = int(words[3])
fa739ae
@@ -169,7 +169,7 @@ class DeviceData:
fa739ae
         else:
fa739ae
             op = words[0][:-1]
fa739ae
             self.__rpc_data['ops'] += [op]
fa739ae
-            self.__rpc_data[op] = [long(word) for word in words[1:]]
fa739ae
+            self.__rpc_data[op] = [int(word) for word in words[1:]]
fa739ae
 
fa739ae
     def parse_stats(self, lines):
fa739ae
         """Turn a list of lines from a mount stat file into a 
fa739ae
@@ -271,7 +271,7 @@ class DeviceData:
fa739ae
         nfs_stats = self.__nfs_data
fa739ae
         lookup_ops = self.__rpc_data['LOOKUP'][0]
fa739ae
         readdir_ops = self.__rpc_data['READDIR'][0]
fa739ae
-        if self.__rpc_data.has_key('READDIRPLUS'):
fa739ae
+        if 'READDIRPLUS' in self.__rpc_data:
fa739ae
             readdir_ops += self.__rpc_data['READDIRPLUS'][0]
fa739ae
 
fa739ae
         dentry_revals = nfs_stats['dentryrevalidates']
fa739ae
@@ -330,7 +330,7 @@ class DeviceData:
fa739ae
     def __print_rpc_op_stats(self, op, sample_time):
fa739ae
         """Print generic stats for one RPC op
fa739ae
         """
fa739ae
-        if not self.__rpc_data.has_key(op):
fa739ae
+        if op not in self.__rpc_data:
fa739ae
             return
fa739ae
 
fa739ae
         rpc_stats = self.__rpc_data[op]
fa739ae
@@ -353,14 +353,14 @@ class DeviceData:
fa739ae
             exe_per_op = 0.0
fa739ae
 
fa739ae
         op += ':'
fa739ae
-        print('%s' % op.lower().ljust(15))
fa739ae
+        print('%s' % op.lower().ljust(15), end='')
fa739ae
         print('  ops/s\t\t   kB/s\t\t  kB/op\t\tretrans\t\tavg RTT (ms)\tavg exe (ms)')
fa739ae
 
fa739ae
-        print('\t\t%7.3f' % (ops / sample_time))
fa739ae
-        print('\t%7.3f' % (kilobytes / sample_time))
fa739ae
-        print('\t%7.3f' % kb_per_op)
fa739ae
-        print(' %7d (%3.1f%%)' % (retrans, retrans_percent))
fa739ae
-        print('\t%7.3f' % rtt_per_op)
fa739ae
+        print('\t\t%7.3f' % (ops / sample_time), end='')
fa739ae
+        print('\t%7.3f' % (kilobytes / sample_time), end='')
fa739ae
+        print('\t%7.3f' % kb_per_op, end='')
fa739ae
+        print(' %7d (%3.1f%%)' % (retrans, retrans_percent), end='')
fa739ae
+        print('\t%7.3f' % rtt_per_op, end='')
fa739ae
         print('\t%7.3f' % exe_per_op)
fa739ae
 
fa739ae
     def ops(self, sample_time):
fa739ae
@@ -392,7 +392,7 @@ class DeviceData:
fa739ae
         print()
fa739ae
 
fa739ae
         print('   op/s\t\trpc bklog')
fa739ae
-        print('%7.2f' % (sends / sample_time))
fa739ae
+        print('%7.2f' % (sends / sample_time), end='')
fa739ae
         print('\t%7.2f' % backlog)
fa739ae
 
fa739ae
         if which == 0:
fa739ae
@@ -405,7 +405,7 @@ class DeviceData:
fa739ae
         elif which == 2:
fa739ae
             self.__print_rpc_op_stats('LOOKUP', sample_time)
fa739ae
             self.__print_rpc_op_stats('READDIR', sample_time)
fa739ae
-            if self.__rpc_data.has_key('READDIRPLUS'):
fa739ae
+            if 'READDIRPLUS' in self.__rpc_data:
fa739ae
                 self.__print_rpc_op_stats('READDIRPLUS', sample_time)
fa739ae
             self.__print_dir_cache_stats(sample_time)
fa739ae
         elif which == 3:
fa739ae
@@ -413,6 +413,8 @@ class DeviceData:
fa739ae
             self.__print_rpc_op_stats('WRITE', sample_time)
fa739ae
             self.__print_page_stats(sample_time)
fa739ae
 
fa739ae
+        sys.stdout.flush()
fa739ae
+
fa739ae
 #
fa739ae
 # Functions
fa739ae
 #
fa739ae
@@ -450,7 +452,7 @@ def print_iostat_summary(old, new, devices, time, options):
fa739ae
     if old:
fa739ae
         # Trim device list to only include intersection of old and new data,
fa739ae
         # this addresses umounts due to autofs mountpoints
fa739ae
-        devicelist = filter(lambda x:x in devices,old)
fa739ae
+        devicelist = [x for x in old if x in devices]
fa739ae
     else:
fa739ae
         devicelist = devices
fa739ae
 
fa739ae
diff --git a/utils/exportfs/exports.man b/utils/exportfs/exports.man
fa739ae
index bc1de73..58c0f66 100644
fa739ae
--- a/utils/exportfs/exports.man
fa739ae
+++ b/utils/exportfs/exports.man
fa739ae
@@ -39,7 +39,7 @@ the export name using a backslash followed by the character code as three
fa739ae
 octal digits.
fa739ae
 .PP
fa739ae
 To apply changes to this file, run
fa739ae
-.BR exportfs \-ra
fa739ae
+.BR "exportfs \-ra"
fa739ae
 or restart the NFS server.
fa739ae
 .PP
fa739ae
 .SS Machine Name Formats
fa739ae
diff --git a/utils/gssd/gssd.man b/utils/gssd/gssd.man
fa739ae
index 1df75c5..ac13fd4 100644
fa739ae
--- a/utils/gssd/gssd.man
fa739ae
+++ b/utils/gssd/gssd.man
fa739ae
@@ -195,11 +195,28 @@ option when starting
fa739ae
 .BR rpc.gssd .
fa739ae
 .SH OPTIONS
fa739ae
 .TP
fa739ae
-.B -D
fa739ae
-DNS Reverse lookups are not used for determining the
fa739ae
-server names pass to GSSAPI. This option will reverses that and forces 
fa739ae
-the use of DNS Reverse resolution of the server's IP address to 
fa739ae
-retrieve the server name to use in GSAPI authentication.
fa739ae
+.B \-D
fa739ae
+The server name passed to GSSAPI for authentication is normally the
fa739ae
+name exactly as requested.  e.g. for NFS
fa739ae
+it is the server name in the "servername:/path" mount request.  Only if this
fa739ae
+servername appears to be an IP address (IPv4 or IPv6) or an
fa739ae
+unqualified name (no dots) will a reverse DNS lookup
fa739ae
+will be performed to get the canoncial server name.
fa739ae
+
fa739ae
+If
fa739ae
+.B \-D
fa739ae
+is present, a reverse DNS lookup will
fa739ae
+.I always
fa739ae
+be used, even if the server name looks like a canonical name.  So it
fa739ae
+is needed if partially qualified, or non canonical names are regularly
fa739ae
+used.
fa739ae
+
fa739ae
+Using
fa739ae
+.B \-D
fa739ae
+can introduce a security vulnerability, so it is recommended that
fa739ae
+.B \-D
fa739ae
+not be used, and that canonical names always be used when requesting
fa739ae
+services.
fa739ae
 .TP
fa739ae
 .B -f
fa739ae
 Runs
fa739ae
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
fa739ae
index af1844c..2d3dbec 100644
fa739ae
--- a/utils/gssd/gssd_proc.c
fa739ae
+++ b/utils/gssd/gssd_proc.c
fa739ae
@@ -67,7 +67,6 @@
fa739ae
 #include <errno.h>
fa739ae
 #include <gssapi/gssapi.h>
fa739ae
 #include <netdb.h>
fa739ae
-#include <ctype.h>
fa739ae
 
fa739ae
 #include "gssd.h"
fa739ae
 #include "err_util.h"
fa739ae
@@ -176,7 +175,6 @@ get_servername(const char *name, const struct sockaddr *sa, const char *addr)
fa739ae
 	char			*hostname;
fa739ae
 	char			hbuf[NI_MAXHOST];
fa739ae
 	unsigned char		buf[sizeof(struct in6_addr)];
fa739ae
-	int			servername = 0;
fa739ae
 
fa739ae
 	if (avoid_dns) {
fa739ae
 		/*
fa739ae
@@ -184,15 +182,18 @@ get_servername(const char *name, const struct sockaddr *sa, const char *addr)
fa739ae
 		 * If it is an IP address, do the DNS lookup otherwise
fa739ae
 		 * skip the DNS lookup.
fa739ae
 		 */
fa739ae
-		servername = 0;
fa739ae
-		if (strchr(name, '.') && inet_pton(AF_INET, name, buf) == 1)
fa739ae
-			servername = 1; /* IPv4 */
fa739ae
-		else if (strchr(name, ':') && inet_pton(AF_INET6, name, buf) == 1)
fa739ae
-			servername = 1; /* or IPv6 */
fa739ae
-
fa739ae
-		if (servername) {
fa739ae
+		int is_fqdn = 1;
fa739ae
+		if (strchr(name, '.') == NULL)
fa739ae
+			is_fqdn = 0; /* local name */
fa739ae
+		else if (inet_pton(AF_INET, name, buf) == 1)
fa739ae
+			is_fqdn = 0; /* IPv4 address */
fa739ae
+		else if (inet_pton(AF_INET6, name, buf) == 1)
fa739ae
+			is_fqdn = 0; /* IPv6 addrss */
fa739ae
+
fa739ae
+		if (is_fqdn) {
fa739ae
 			return strdup(name);
fa739ae
 		}
fa739ae
+		/* Sorry, cannot avoid dns after all */
fa739ae
 	}
fa739ae
 
fa739ae
 	switch (sa->sa_family) {
fa739ae
@@ -466,8 +467,9 @@ process_clnt_dir(char *dir, char *pdir)
fa739ae
 	}
fa739ae
 	sprintf(clp->dirname, "%s/%s", pdir, dir);
fa739ae
 	if ((clp->dir_fd = open(clp->dirname, O_RDONLY)) == -1) {
fa739ae
-		printerr(0, "ERROR: can't open %s: %s\n",
fa739ae
-			 clp->dirname, strerror(errno));
fa739ae
+		if (errno != ENOENT)
fa739ae
+			printerr(0, "ERROR: can't open %s: %s\n",
fa739ae
+				 clp->dirname, strerror(errno));
fa739ae
 		goto fail_destroy_client;
fa739ae
 	}
fa739ae
 	fcntl(clp->dir_fd, F_SETSIG, DNOTIFY_SIGNAL);
fa739ae
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
fa739ae
index 6275dd8..83b9651 100644
fa739ae
--- a/utils/gssd/krb5_util.c
fa739ae
+++ b/utils/gssd/krb5_util.c
fa739ae
@@ -231,7 +231,7 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname,
fa739ae
 				continue;
fa739ae
 			}
fa739ae
 			if (uid == 0 && !root_uses_machine_creds && 
fa739ae
-				strstr(namelist[i]->d_name, "_machine_")) {
fa739ae
+				strstr(namelist[i]->d_name, "machine_")) {
fa739ae
 				printerr(3, "CC '%s' not available to root\n",
fa739ae
 					 statname);
fa739ae
 				free(namelist[i]);
fa739ae
@@ -825,8 +825,10 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
fa739ae
 	myhostad[i+1] = 0;
fa739ae
 
fa739ae
 	retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname));
fa739ae
-	if (retval)
fa739ae
-		goto out;
fa739ae
+	if (retval) {
fa739ae
+		/* Don't use myhostname */
fa739ae
+		myhostname[0] = 0;
fa739ae
+	}
fa739ae
 
fa739ae
 	code = krb5_get_default_realm(context, &default_realm);
fa739ae
 	if (code) {
fa739ae
@@ -852,11 +854,19 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
fa739ae
 	}
fa739ae
 
fa739ae
 	/*
fa739ae
-	 * Try the "appropriate" realm first, and if nothing found for that
fa739ae
-	 * realm, try the default realm (if it hasn't already been tried).
fa739ae
+	 * Make sure the preferred_realm, which may have been explicitly set
fa739ae
+	 * on the command line, is tried first. If nothing is found go on with
fa739ae
+	 * the host and local default realm (if that hasn't already been tried).
fa739ae
 	 */
fa739ae
 	i = 0;
fa739ae
 	realm = realmnames[i];
fa739ae
+
fa739ae
+	if (strcmp (realm, preferred_realm) != 0) {
fa739ae
+		realm = preferred_realm;
fa739ae
+		/* resetting the realmnames index */
fa739ae
+		i = -1;
fa739ae
+	}
fa739ae
+
fa739ae
 	while (1) {
fa739ae
 		if (realm == NULL) {
fa739ae
 			tried_all = 1;
fa739ae
@@ -883,6 +893,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
fa739ae
 								myhostad,
fa739ae
 								NULL);
fa739ae
 			} else {
fa739ae
+				if (!myhostname[0])
fa739ae
+					continue;
fa739ae
 				snprintf(spn, sizeof(spn), "%s/%s@%s",
fa739ae
 					 svcnames[j], myhostname, realm);
fa739ae
 				code = krb5_build_principal_ext(context, &princ,
fa739ae
@@ -1236,7 +1248,7 @@ gssd_refresh_krb5_machine_credential(char *hostname,
fa739ae
 	krb5_keytab kt = NULL;;
fa739ae
 	int retval = 0;
fa739ae
 	char *k5err = NULL;
fa739ae
-	const char *svcnames[5] = { "$", "root", "nfs", "host", NULL };
fa739ae
+	const char *svcnames[] = { "$", "root", "nfs", "host", NULL };
fa739ae
 
fa739ae
 	/*
fa739ae
 	 * If a specific service name was specified, use it.
fa739ae
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
fa739ae
index beba9c4..b6c6231 100644
fa739ae
--- a/utils/idmapd/idmapd.c
fa739ae
+++ b/utils/idmapd/idmapd.c
fa739ae
@@ -502,7 +502,7 @@ nfsdcb(int UNUSED(fd), short which, void *data)
fa739ae
 	struct idmap_client *ic = data;
fa739ae
 	struct idmap_msg im;
fa739ae
 	u_char buf[IDMAP_MAXMSGSZ + 1];
fa739ae
-	size_t len;
fa739ae
+	ssize_t len;
fa739ae
 	ssize_t bsiz;
fa739ae
 	char *bp, typebuf[IDMAP_MAXMSGSZ],
fa739ae
 		buf1[IDMAP_MAXMSGSZ], authbuf[IDMAP_MAXMSGSZ], *p;
fa739ae
@@ -511,10 +511,14 @@ nfsdcb(int UNUSED(fd), short which, void *data)
fa739ae
 	if (which != EV_READ)
fa739ae
 		goto out;
fa739ae
 
fa739ae
-	if ((len = read(ic->ic_fd, buf, sizeof(buf))) <= 0) {
fa739ae
+	len = read(ic->ic_fd, buf, sizeof(buf));
fa739ae
+	if (len == 0)
fa739ae
+		/* No upcall to read; not necessarily a problem: */
fa739ae
+		return;
fa739ae
+	if (len < 0) {
fa739ae
 		xlog_warn("nfsdcb: read(%s) failed: errno %d (%s)",
fa739ae
-			     ic->ic_path, len?errno:0, 
fa739ae
-			     len?strerror(errno):"End of File");
fa739ae
+			     ic->ic_path, errno,
fa739ae
+			     strerror(errno));
fa739ae
 		nfsdreopen_one(ic);
fa739ae
 		return;
fa739ae
 	}
fa739ae
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
fa739ae
index 6f2ee75..68b9f93 100644
fa739ae
--- a/utils/mount/configfile.c
fa739ae
+++ b/utils/mount/configfile.c
fa739ae
@@ -73,6 +73,8 @@ struct mnt_alias {
fa739ae
 };
fa739ae
 int mnt_alias_sz = (sizeof(mnt_alias_tab)/sizeof(mnt_alias_tab[0]));
fa739ae
 
fa739ae
+static int strict;
fa739ae
+
fa739ae
 /*
fa739ae
  * See if the option is an alias, if so return the 
fa739ae
  * real mount option along with the argument type.
fa739ae
@@ -286,7 +288,7 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
fa739ae
 	char *nvalue, *ptr;
fa739ae
 	int argtype;
fa739ae
 
fa739ae
-	list = conf_get_tag_list(section);
fa739ae
+	list = conf_get_tag_list(section, arg);
fa739ae
 	TAILQ_FOREACH(node, &list->fields, link) {
fa739ae
 		/*
fa739ae
 		 * Do not overwrite options if already exists 
fa739ae
@@ -310,7 +312,15 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
fa739ae
 		if (strcasecmp(value, "false") == 0) {
fa739ae
 			if (argtype != MNT_NOARG)
fa739ae
 				snprintf(buf, BUFSIZ, "no%s", field);
fa739ae
+			else if (strcasecmp(field, "bg") == 0)
fa739ae
+				snprintf(buf, BUFSIZ, "fg");
fa739ae
+			else if (strcasecmp(field, "fg") == 0)
fa739ae
+				snprintf(buf, BUFSIZ, "bg");
fa739ae
+			else if (strcasecmp(field, "sloppy") == 0)
fa739ae
+				strict = 1;
fa739ae
 		} else if (strcasecmp(value, "true") == 0) {
fa739ae
+			if ((strcasecmp(field, "sloppy") == 0) && strict)
fa739ae
+				continue;
fa739ae
 			snprintf(buf, BUFSIZ, "%s", field);
fa739ae
 		} else {
fa739ae
 			nvalue = strdup(value);
fa739ae
@@ -345,6 +355,7 @@ char *conf_get_mntopts(char *spec, char *mount_point,
fa739ae
 	char *ptr, *server, *config_opts;
fa739ae
 	int optlen = 0;
fa739ae
 
fa739ae
+	strict = 0;
fa739ae
 	SLIST_INIT(&head;;
fa739ae
 	list_size = 0;
fa739ae
 	/*
fa739ae
diff --git a/utils/mount/network.c b/utils/mount/network.c
fa739ae
index 4be48cd..e2cdcaf 100644
fa739ae
--- a/utils/mount/network.c
fa739ae
+++ b/utils/mount/network.c
fa739ae
@@ -65,11 +65,6 @@ extern int nfs_mount_data_version;
fa739ae
 extern char *progname;
fa739ae
 extern int verbose;
fa739ae
 
fa739ae
-static const char *nfs_ns_pgmtbl[] = {
fa739ae
-	"status",
fa739ae
-	NULL,
fa739ae
-};
fa739ae
-
fa739ae
 static const char *nfs_mnt_pgmtbl[] = {
fa739ae
 	"mount",
fa739ae
 	"mountd",
fa739ae
@@ -761,18 +756,6 @@ int probe_bothports(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server)
fa739ae
 					&nfs_server->pmap);
fa739ae
 }
fa739ae
 
fa739ae
-static int nfs_probe_statd(void)
fa739ae
-{
fa739ae
-	struct sockaddr_in addr = {
fa739ae
-		.sin_family		= AF_INET,
fa739ae
-		.sin_addr.s_addr	= htonl(INADDR_LOOPBACK),
fa739ae
-	};
fa739ae
-	rpcprog_t program = nfs_getrpcbyname(NSMPROG, nfs_ns_pgmtbl);
fa739ae
-
fa739ae
-	return nfs_getport_ping(SAFE_SOCKADDR(&addr), sizeof(addr),
fa739ae
-				program, (rpcvers_t)1, IPPROTO_UDP);
fa739ae
-}
fa739ae
-
fa739ae
 /**
fa739ae
  * start_statd - attempt to start rpc.statd
fa739ae
  *
fa739ae
diff --git a/utils/mount/nfs.man b/utils/mount/nfs.man
fa739ae
index a8ec46c..2a42b93 100644
fa739ae
--- a/utils/mount/nfs.man
fa739ae
+++ b/utils/mount/nfs.man
fa739ae
@@ -84,6 +84,20 @@ in
fa739ae
 .SS "Options supported by all versions"
fa739ae
 These options are valid to use with any NFS version.
fa739ae
 .TP 1.5i
fa739ae
+.BI nfsvers= n
fa739ae
+The NFS protocol version number used to contact the server's NFS service.
fa739ae
+If the server does not support the requested version, the mount request 
fa739ae
+fails.
fa739ae
+If this option is not specified, the client negotiates a suitable version 
fa739ae
+with
fa739ae
+the server, trying version 4 first, version 3 second, and version 2 last.
fa739ae
+.TP 1.5i
fa739ae
+.BI vers= n
fa739ae
+This option is an alternative to the
fa739ae
+.B nfsvers
fa739ae
+option.
fa739ae
+It is included for compatibility with other operating systems
fa739ae
+.TP 1.5i
fa739ae
 .BR soft " / " hard
fa739ae
 Determines the recovery behavior of the NFS client
fa739ae
 after an NFS request times out.
fa739ae
@@ -621,18 +635,6 @@ Using this option ensures that
fa739ae
 reports the proper maximum component length to applications
fa739ae
 in such cases.
fa739ae
 .TP 1.5i
fa739ae
-.BI nfsvers= n
fa739ae
-The NFS protocol version number used to contact the server's NFS service.
fa739ae
-If the server does not support the requested version, the mount request fails.
fa739ae
-If this option is not specified, the client negotiates a suitable version with
fa739ae
-the server, trying version 4 first, version 3 second, and version 2 last.
fa739ae
-.TP 1.5i
fa739ae
-.BI vers= n
fa739ae
-This option is an alternative to the
fa739ae
-.B nfsvers
fa739ae
-option.
fa739ae
-It is included for compatibility with other operating systems.
fa739ae
-.TP 1.5i
fa739ae
 .BR lock " / " nolock
fa739ae
 Selects whether to use the NLM sideband protocol to lock files on the server.
fa739ae
 If neither option is specified (or if
fa739ae
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
fa739ae
index 737927c..517aa62 100644
fa739ae
--- a/utils/mountd/cache.c
fa739ae
+++ b/utils/mountd/cache.c
fa739ae
@@ -347,20 +347,26 @@ static char *next_mnt(void **v, char *p)
fa739ae
 
fa739ae
 static int is_subdirectory(char *child, char *parent)
fa739ae
 {
fa739ae
+	/* Check is child is strictly a subdirectory of
fa739ae
+	 * parent or a more distant descendant.
fa739ae
+	 */
fa739ae
 	size_t l = strlen(parent);
fa739ae
 
fa739ae
-	if (strcmp(parent, "/") == 0)
fa739ae
+	if (strcmp(parent, "/") == 0 && child[1] != 0)
fa739ae
 		return 1;
fa739ae
 
fa739ae
-	return strcmp(child, parent) == 0
fa739ae
-		|| (strncmp(child, parent, l) == 0 && child[l] == '/');
fa739ae
+	return (strncmp(child, parent, l) == 0 && child[l] == '/');
fa739ae
 }
fa739ae
 
fa739ae
 static int path_matches(nfs_export *exp, char *path)
fa739ae
 {
fa739ae
-	if (exp->m_export.e_flags & NFSEXP_CROSSMOUNT)
fa739ae
-		return is_subdirectory(path, exp->m_export.e_path);
fa739ae
-	return strcmp(path, exp->m_export.e_path) == 0;
fa739ae
+	/* Does the path match the export?  I.e. is it an
fa739ae
+	 * exact match, or does the export have CROSSMOUNT, and path
fa739ae
+	 * is a descendant?
fa739ae
+	 */
fa739ae
+	return strcmp(path, exp->m_export.e_path) == 0
fa739ae
+		|| ((exp->m_export.e_flags & NFSEXP_CROSSMOUNT)
fa739ae
+		    && is_subdirectory(path, exp->m_export.e_path));
fa739ae
 }
fa739ae
 
fa739ae
 static int
fa739ae
@@ -369,15 +375,13 @@ export_matches(nfs_export *exp, char *dom, char *path, struct addrinfo *ai)
fa739ae
 	return path_matches(exp, path) && client_matches(exp, dom, ai);
fa739ae
 }
fa739ae
 
fa739ae
-/* True iff e1 is a child of e2 and e2 has crossmnt set: */
fa739ae
+/* True iff e1 is a child of e2 (or descendant) and e2 has crossmnt set: */
fa739ae
 static bool subexport(struct exportent *e1, struct exportent *e2)
fa739ae
 {
fa739ae
 	char *p1 = e1->e_path, *p2 = e2->e_path;
fa739ae
-	size_t l2 = strlen(p2);
fa739ae
 
fa739ae
 	return e2->e_flags & NFSEXP_CROSSMOUNT
fa739ae
-		&& strncmp(p1, p2, l2) == 0
fa739ae
-		&& p1[l2] == '/';
fa739ae
+		&& is_subdirectory(p1, p2);
fa739ae
 }
fa739ae
 
fa739ae
 struct parsed_fsid {
fa739ae
diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
fa739ae
index e87c0a9..6db92f0 100644
fa739ae
--- a/utils/nfsd/nfsd.c
fa739ae
+++ b/utils/nfsd/nfsd.c
fa739ae
@@ -99,8 +99,8 @@ main(int argc, char **argv)
fa739ae
 	char *p, *progname, *port;
fa739ae
 	char *haddr = NULL;
fa739ae
 	int	socket_up = 0;
fa739ae
-	int minorvers41 = 0;	/* nfsv4 minor version */
fa739ae
-	unsigned int versbits = NFSCTL_ALLBITS;
fa739ae
+	int minorvers = NFS4_VERDEFAULT;	/* nfsv4 minor version */
fa739ae
+	unsigned int versbits = NFSCTL_VERDEFAULT;
fa739ae
 	unsigned int protobits = NFSCTL_ALLBITS;
fa739ae
 	unsigned int proto4 = 0;
fa739ae
 	unsigned int proto6 = 0;
fa739ae
@@ -160,11 +160,11 @@ main(int argc, char **argv)
fa739ae
 			case 4:
fa739ae
 				if (*p == '.') {
fa739ae
 					int i = atoi(p+1);
fa739ae
-					if (i != 1) {
fa739ae
+					if (i > 2) {
fa739ae
 						fprintf(stderr, "%s: unsupported minor version\n", optarg);
fa739ae
 						exit(1);
fa739ae
 					}
fa739ae
-					minorvers41 = -1;
fa739ae
+					NFSCTL_VERUNSET(minorvers, i);
fa739ae
 					break;
fa739ae
 				}
fa739ae
 			case 3:
fa739ae
@@ -181,11 +181,11 @@ main(int argc, char **argv)
fa739ae
 			case 4:
fa739ae
 				if (*p == '.') {
fa739ae
 					int i = atoi(p+1);
fa739ae
-					if (i != 1) {
fa739ae
+					if (i > 2) {
fa739ae
 						fprintf(stderr, "%s: unsupported minor version\n", optarg);
fa739ae
 						exit(1);
fa739ae
 					}
fa739ae
-					minorvers41 = 1;
fa739ae
+					NFSCTL_VERSET(minorvers, i);
fa739ae
 					break;
fa739ae
 				}
fa739ae
 			case 3:
fa739ae
@@ -282,7 +282,7 @@ main(int argc, char **argv)
fa739ae
 	 * registered with rpcbind. Note that on older kernels w/o the right
fa739ae
 	 * interfaces, these are a no-op.
fa739ae
 	 */
fa739ae
-	nfssvc_setvers(versbits, minorvers41);
fa739ae
+	nfssvc_setvers(versbits, minorvers);
fa739ae
  
fa739ae
 	error = nfssvc_set_sockets(AF_INET, proto4, haddr, port);
fa739ae
 	if (!error)
fa739ae
diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c
fa739ae
index 683008e..8b85846 100644
fa739ae
--- a/utils/nfsd/nfssvc.c
fa739ae
+++ b/utils/nfsd/nfssvc.c
fa739ae
@@ -269,7 +269,7 @@ nfssvc_set_sockets(const int family, const unsigned int protobits,
fa739ae
 }
fa739ae
 
fa739ae
 void
fa739ae
-nfssvc_setvers(unsigned int ctlbits, int minorvers41)
fa739ae
+nfssvc_setvers(unsigned int ctlbits, int minorvers)
fa739ae
 {
fa739ae
 	int fd, n, off;
fa739ae
 	char *ptr;
fa739ae
@@ -280,9 +280,12 @@ nfssvc_setvers(unsigned int ctlbits, int minorvers41)
fa739ae
 	if (fd < 0)
fa739ae
 		return;
fa739ae
 
fa739ae
-	if (minorvers41)
fa739ae
-		off += snprintf(ptr+off, sizeof(buf) - off, "%c4.1",
fa739ae
-				minorvers41 > 0 ? '+' : '-');
fa739ae
+	for (n = NFS4_MINMINOR; n <= NFS4_MAXMINOR; n++) {
fa739ae
+		if (NFSCTL_VERISSET(minorvers, n)) 
fa739ae
+			off += snprintf(ptr+off, sizeof(buf) - off, "+4.%d ", n);
fa739ae
+		else			
fa739ae
+			off += snprintf(ptr+off, sizeof(buf) - off, "-4.%d ", n);
fa739ae
+	}
fa739ae
 	for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) {
fa739ae
 		if (NFSCTL_VERISSET(ctlbits, n))
fa739ae
 		    off += snprintf(ptr+off, sizeof(buf) - off, "+%d ", n);
fa739ae
diff --git a/utils/nfsdcltrack/nfsdcltrack.man b/utils/nfsdcltrack/nfsdcltrack.man
fa739ae
index 47007df..6940788 100644
fa739ae
--- a/utils/nfsdcltrack/nfsdcltrack.man
fa739ae
+++ b/utils/nfsdcltrack/nfsdcltrack.man
fa739ae
@@ -1,53 +1,3 @@
fa739ae
-.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
fa739ae
-.\"
fa739ae
-.\" Standard preamble:
fa739ae
-.\" ========================================================================
fa739ae
-.de Sp \" Vertical space (when we can't use .PP)
fa739ae
-.if t .sp .5v
fa739ae
-.if n .sp
fa739ae
-..
fa739ae
-.de Vb \" Begin verbatim text
fa739ae
-.ft CW
fa739ae
-.nf
fa739ae
-.ne \\$1
fa739ae
-..
fa739ae
-.de Ve \" End verbatim text
fa739ae
-.ft R
fa739ae
-.fi
fa739ae
-..
fa739ae
-.\" Set up some character translations and predefined strings.  \*(-- will
fa739ae
-.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
fa739ae
-.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
fa739ae
-.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
fa739ae
-.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
fa739ae
-.\" nothing in troff, for use with C<>.
fa739ae
-.tr \(*W-
fa739ae
-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
fa739ae
-.ie n \{\
fa739ae
-.    ds -- \(*W-
fa739ae
-.    ds PI pi
fa739ae
-.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
fa739ae
-.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
fa739ae
-.    ds L" ""
fa739ae
-.    ds R" ""
fa739ae
-.    ds C` ""
fa739ae
-.    ds C' ""
fa739ae
-'br\}
fa739ae
-.el\{\
fa739ae
-.    ds -- \|\(em\|
fa739ae
-.    ds PI \(*p
fa739ae
-.    ds L" ``
fa739ae
-.    ds R" ''
fa739ae
-'br\}
fa739ae
-.\"
fa739ae
-.\" Escape single quotes in literal strings from groff's Unicode transform.
fa739ae
-.ie \n(.g .ds Aq \(aq
fa739ae
-.el       .ds Aq '
fa739ae
-.\"
fa739ae
-.\" If the F register is turned on, we'll generate index entries on stderr for
fa739ae
-.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
fa739ae
-.\" entries marked with X<> in POD.  Of course, you'll have to process the
fa739ae
-.\" output yourself in some meaningful fashion.
fa739ae
 .ie \nF \{\
fa739ae
 .    de IX
fa739ae
 .    tm Index:\\$1\t\\n%\t"\\$2"
fa739ae
@@ -59,70 +9,6 @@
fa739ae
 .    de IX
fa739ae
 ..
fa739ae
 .\}
fa739ae
-.\"
fa739ae
-.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
fa739ae
-.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
fa739ae
-.    \" fudge factors for nroff and troff
fa739ae
-.if n \{\
fa739ae
-.    ds #H 0
fa739ae
-.    ds #V .8m
fa739ae
-.    ds #F .3m
fa739ae
-.    ds #[ \f1
fa739ae
-.    ds #] \fP
fa739ae
-.\}
fa739ae
-.if t \{\
fa739ae
-.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
fa739ae
-.    ds #V .6m
fa739ae
-.    ds #F 0
fa739ae
-.    ds #[ \&
fa739ae
-.    ds #] \&
fa739ae
-.\}
fa739ae
-.    \" simple accents for nroff and troff
fa739ae
-.if n \{\
fa739ae
-.    ds ' \&
fa739ae
-.    ds ` \&
fa739ae
-.    ds ^ \&
fa739ae
-.    ds , \&
fa739ae
-.    ds ~ ~
fa739ae
-.    ds /
fa739ae
-.\}
fa739ae
-.if t \{\
fa739ae
-.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
fa739ae
-.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
fa739ae
-.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
fa739ae
-.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
fa739ae
-.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
fa739ae
-.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
fa739ae
-.\}
fa739ae
-.    \" troff and (daisy-wheel) nroff accents
fa739ae
-.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
fa739ae
-.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
fa739ae
-.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
fa739ae
-.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
fa739ae
-.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
fa739ae
-.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
fa739ae
-.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
fa739ae
-.ds ae a\h'-(\w'a'u*4/10)'e
fa739ae
-.ds Ae A\h'-(\w'A'u*4/10)'E
fa739ae
-.    \" corrections for vroff
fa739ae
-.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
fa739ae
-.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
fa739ae
-.    \" for low resolution devices (crt and lpr)
fa739ae
-.if \n(.H>23 .if \n(.V>19 \
fa739ae
-\{\
fa739ae
-.    ds : e
fa739ae
-.    ds 8 ss
fa739ae
-.    ds o a
fa739ae
-.    ds d- d\h'-1'\(ga
fa739ae
-.    ds D- D\h'-1'\(hy
fa739ae
-.    ds th \o'bp'
fa739ae
-.    ds Th \o'LP'
fa739ae
-.    ds ae ae
fa739ae
-.    ds Ae AE
fa739ae
-.\}
fa739ae
-.rm #[ #] #H #V #F C
fa739ae
-.\" ========================================================================
fa739ae
-.\"
fa739ae
 .IX Title "NFSDCLTRACK 8"
fa739ae
 .TH NFSDCLTRACK 8 "2012-10-24" "" ""
fa739ae
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
fa739ae
diff --git a/utils/nfsidmap/Makefile.am b/utils/nfsidmap/Makefile.am
fa739ae
index c0675c4..737a219 100644
fa739ae
--- a/utils/nfsidmap/Makefile.am
fa739ae
+++ b/utils/nfsidmap/Makefile.am
fa739ae
@@ -1,9 +1,10 @@
fa739ae
 ## Process this file with automake to produce Makefile.in
fa739ae
 
fa739ae
 man8_MANS = nfsidmap.man
fa739ae
-
fa739ae
 sbin_PROGRAMS	= nfsidmap
fa739ae
+
fa739ae
 nfsidmap_SOURCES = nfsidmap.c
fa739ae
 nfsidmap_LDADD = $(LIBNFSIDMAP) -lkeyutils ../../support/nfs/libnfs.a
fa739ae
 
fa739ae
 MAINTAINERCLEANFILES = Makefile.in
fa739ae
+EXTRA_DIST = id_resolver.conf
fa739ae
diff --git a/utils/nfsidmap/id_resolver.conf b/utils/nfsidmap/id_resolver.conf
fa739ae
new file mode 100644
fa739ae
index 0000000..2c156c6
fa739ae
--- /dev/null
fa739ae
+++ b/utils/nfsidmap/id_resolver.conf
fa739ae
@@ -0,0 +1 @@
fa739ae
+create	id_resolver	*	*	/usr/sbin/nfsidmap -t 600 %k %d
fa739ae
diff --git a/utils/statd/statd.c b/utils/statd/statd.c
fa739ae
index 652546c..8c51bcc 100644
fa739ae
--- a/utils/statd/statd.c
fa739ae
+++ b/utils/statd/statd.c
fa739ae
@@ -28,6 +28,7 @@
fa739ae
 
fa739ae
 #include "statd.h"
fa739ae
 #include "nfslib.h"
fa739ae
+#include "nfsrpc.h"
fa739ae
 #include "nsm.h"
fa739ae
 
fa739ae
 /* Socket operations */
fa739ae
@@ -237,6 +238,12 @@ int main (int argc, char **argv)
fa739ae
 	/* Set hostname */
fa739ae
 	MY_NAME = NULL;
fa739ae
 
fa739ae
+	/* Refuse to start if another statd is running */
fa739ae
+	if (nfs_probe_statd()) {
fa739ae
+		fprintf(stderr, "Statd service already running!\n");
fa739ae
+		exit(1);
fa739ae
+	}
fa739ae
+
fa739ae
 	/* Process command line switches */
fa739ae
 	while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:L", longopts, NULL)) != EOF) {
fa739ae
 		switch (arg) {