Patchwork [12/13] Clean up use of 2049 as default NFS server port

login
register
mail settings
Submitter Chuck Lever
Date Feb. 1, 2013, 5:21 p.m.
Message ID <20130201172130.63192.73056.stgit@seurat.1015granger.net>
Download mbox | patch
Permalink /patch/217539/
State Accepted
Headers show

Comments

Chuck Lever - Feb. 1, 2013, 5:21 p.m.
Clean up: Replace local definition of the NFS_PORT port macro with
the correct public header definition.

Introduced by commit 4f681570 "libjunction: Add support for
nfs-basic junctions", Thu Dec 22 15:40:01 2011.

Clean up: Avoid using "zero" for the fileserver port when creating
new NFS FSL records.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 src/libjunction/nfs.c        |    6 ++----
 src/libnsdb/administrator.c  |    4 +++-
 src/nfsref/lookup.c          |    7 ++++++-
 src/nsdbc/nsdb-create-fsl.c  |    3 ++-
 src/nsdbc/nsdb-resolve-fsn.c |    3 ++-
 5 files changed, 15 insertions(+), 8 deletions(-)

Patch

diff --git a/src/libjunction/nfs.c b/src/libjunction/nfs.c
index 42c1015..3447bb5 100644
--- a/src/libjunction/nfs.c
+++ b/src/libjunction/nfs.c
@@ -77,16 +77,14 @@ 
 #include <string.h>
 #include <unistd.h>
 
+#include <rpcsvc/nfs_prot.h>
+
 #include "fedfs.h"
 #include "nsdb.h"
 #include "junction.h"
 #include "junction-internal.h"
 #include "xlog.h"
 
-#ifndef NFS_PORT
-#define NFS_PORT	(2049)
-#endif
-
 /**
  * Tag name of NFS location element of a junction XML document
  */
diff --git a/src/libnsdb/administrator.c b/src/libnsdb/administrator.c
index 0565caa..4fd93ec 100644
--- a/src/libnsdb/administrator.c
+++ b/src/libnsdb/administrator.c
@@ -41,6 +41,8 @@ 
 #include <netdb.h>
 #include <errno.h>
 
+#include <rpcsvc/nfs_prot.h>
+
 #include "nsdb.h"
 #include "junction.h"
 #include "nsdb-internal.h"
@@ -627,7 +629,7 @@  nsdb_nfsfsl_to_uri(const struct fedfs_nfs_fsl *nfsfsl, UriUriA *uri)
 
 	nsdb_assign_textrange(&uri->scheme, "nfs");
 	nsdb_assign_textrange(&uri->hostText, nfsfsl->fn_fslhost);
-	if (nfsfsl->fn_fslport != 2049 && nfsfsl->fn_fslport != 0) {
+	if (nfsfsl->fn_fslport != NFS_PORT && nfsfsl->fn_fslport != 0) {
 		char portbuf[8];
 		sprintf(portbuf, "%u", nfsfsl->fn_fslport);
 		nsdb_assign_textrange(&uri->portText, portbuf);
diff --git a/src/nfsref/lookup.c b/src/nfsref/lookup.c
index 6c8764d..1271e3d 100644
--- a/src/nfsref/lookup.c
+++ b/src/nfsref/lookup.c
@@ -28,6 +28,8 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 
+#include <rpcsvc/nfs_prot.h>
+
 #include "fedfs.h"
 #include "junction.h"
 #include "nsdb.h"
@@ -194,9 +196,12 @@  static void
 nfsref_lookup_display_fedfs_nfs_fsl(struct fedfs_nfs_fsl *nfsl)
 {
 	char *rootpath;
+	unsigned port = nfsl->fn_fslport;
 
 	printf("\tFileserver name:\t\t%s\n", nfsl->fn_fslhost);
-	printf("\tFileserver port:\t\t%u\n", nfsl->fn_fslport);
+	if (port == 0)
+		port = NFS_PORT;
+	printf("\tFileserver port:\t\t%u\n", port);
 
 	if (nsdb_path_array_to_posix(nfsl->fn_nfspath, &rootpath) == FEDFS_OK) {
 		printf("\tExport path:\t\t\t%s\n", rootpath);
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index 0e15e15..8af3177 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -40,6 +40,7 @@ 
 #include <netdb.h>
 #include <langinfo.h>
 
+#include <rpcsvc/nfs_prot.h>
 #include <uuid/uuid.h>
 
 #include "fedfs.h"
@@ -135,7 +136,7 @@  main(int argc, char **argv)
 
 	nsdb_env(&nsdbname, &nsdbport, &binddn, &nce);
 
-	serverport = 0;
+	serverport = NFS_PORT;
 	while ((arg = getopt_long(argc, argv, nsdb_create_fsl_opts,
 			nsdb_create_fsl_longopts, NULL)) != -1) {
 		switch (arg) {
diff --git a/src/nsdbc/nsdb-resolve-fsn.c b/src/nsdbc/nsdb-resolve-fsn.c
index 5a004fb..38ec28d 100644
--- a/src/nsdbc/nsdb-resolve-fsn.c
+++ b/src/nsdbc/nsdb-resolve-fsn.c
@@ -40,6 +40,7 @@ 
 #include <netdb.h>
 #include <langinfo.h>
 
+#include <rpcsvc/nfs_prot.h>
 #include <uuid/uuid.h>
 
 #include "fedfs.h"
@@ -115,7 +116,7 @@  nsdb_resolve_fsn_display_nfs_fsl(struct fedfs_nfs_fsl *nfsl)
 	if (status != FEDFS_OK)
 		return;
 
-	if (nfsl->fn_fslport == 0)
+	if (nfsl->fn_fslport == 0 || nfsl->fn_fslport == NFS_PORT)
 		printf(" NFS fls_server:\t\t%s\n", nfsl->fn_fslhost);
 	else
 		printf(" NFS fls_server:\t\t%s:%u\n", nfsl->fn_fslhost,