statd: exit if a statd is already running
Subsystems (2)
PATCH 1/1 statd: exit if a statd is already running
Moves nfs_probe_statd from mount to nfs support lib to share with statd.
Signed-off-by Weston Andros Adamson <[email protected]>
---
This patch stops users from running multiple instances of statd, which can obviously cause a lot of problems.
support/include/nfsrpc.h | 5 +++++ support/nfs/getport.c | 22 ++++++++++++++++++++++ utils/mount/network.c | 17 ----------------- utils/statd/statd.c | 6 ++++++ 4 files changed, 33 insertions(+), 17 deletions(-)
support/include/nfsrpc.h +5 -0
@@ -156,6 +156,11 @@ extern unsigned long nfs_pmap_getport(const struct sockaddr_in *, const struct timeval *);/* +* Use nfs_pmap_getport to see if statd is running locally +*/ +extern int nfs_probe_statd (void ); + +/* * Contact a remote RPC service to discover whether it is responding * to requests. */
support/nfs/getport.c +22 -0
@@ -1102,3 +1102,25 @@ unsigned long nfs_pmap_getport(const struct sockaddr_in *sin,return port; } + +static const char *nfs_ns_pgmtbl[] = { +"status" , +NULL , +}; + +/* +* nfs_probe_statd - use nfs_pmap_getport to see if statd is running locally +* +* Returns non-zero if statd is running locally. +*/ +int nfs_probe_statd (void ) +{ +struct sockaddr_in addr = { + .sin_family =AF_INET , + .sin_addr.s_addr =htonl (INADDR_LOOPBACK ), + }; +rpcprog_t program =nfs_getrpcbyname (NSMPROG , nfs_ns_pgmtbl); + +return nfs_getport_ping ((struct sockaddr *)(char *)&addr,sizeof (addr), + program, (rpcvers_t )1 ,IPPROTO_UDP ); +}
utils/mount/network.c +0 -17
@@ -65,11 +65,6 @@ extern int nfs_mount_data_version;extern char *progname;extern int verbose; -static const char *nfs_ns_pgmtbl[] = { -"status" , -NULL , -}; -static const char *nfs_mnt_pgmtbl[] = {"mount" ,"mountd" ,
@@ -761,18 +756,6 @@ int probe_bothports(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server) &nfs_server->pmap); } -static int nfs_probe_statd (void ) -{ -struct sockaddr_in addr = { - .sin_family =AF_INET , - .sin_addr.s_addr =htonl (INADDR_LOOPBACK ), - }; -rpcprog_t program =nfs_getrpcbyname (NSMPROG , nfs_ns_pgmtbl); - -return nfs_getport_ping (SAFE_SOCKADDR (&addr),sizeof (addr), - program, (rpcvers_t )1 ,IPPROTO_UDP ); -} -/** * start_statd - attempt to start rpc.statd *
utils/statd/statd.c +6 -0
@@ -237,6 +237,12 @@ int main (int argc, char **argv)/* Set hostname */ MY_NAME =NULL ; +/* Refuse to start if another statd is running */ +if (nfs_probe_statd ()) { +fprintf (stderr,"Statd service already running!\n" ); +exit (1 ); + } +/* Process command line switches */ while ((arg =getopt_long (argc, argv,"h?vVFNH:dn:p:o:P:L" , longopts,NULL )) !=EOF ) {switch (arg) {
Signature · 1 line
1.7.12.4 (Apple Git-37)
Quoted 3 lines · Weston Andros Adamson
Moves
nfs_probe_statdfrom mount to nfs support lib to share with statd.Signed-off-by Weston Andros Adamson <[email protected]>
Acked-by Chuck Lever <[email protected]>
Quoted 116 lines
---
This patch stops users from running multiple instances of statd, which can obviously cause a lot of problems.
support/include/nfsrpc.h | 5 +++++ support/nfs/getport.c | 22 ++++++++++++++++++++++ utils/mount/network.c | 17 ----------------- utils/statd/statd.c | 6 ++++++ 4 files changed, 33 insertions(+), 17 deletions(-)support/include/nfsrpc.h +5
-0@@ -156,6 +156,11 @@ extern unsigned long nfs_pmap_getport(const struct sockaddr_in *, const struct timeval *);/* +* Use nfs_pmap_getport to see if statd is running locally +*/ +extern int nfs_probe_statd (void ); + +/* * Contact a remote RPC service to discover whether it is responding * to requests. */ support/nfs/getport.c +22
-0@@ -1102,3 +1102,25 @@ unsigned long nfs_pmap_getport(const struct sockaddr_in *sin,return port; } + +static const char *nfs_ns_pgmtbl[] = { +"status" , +NULL , +}; + +/* +* nfs_probe_statd - use nfs_pmap_getport to see if statd is running locally +* +* Returns non-zero if statd is running locally. +*/ +int nfs_probe_statd (void ) +{ +struct sockaddr_in addr = { + .sin_family =AF_INET , + .sin_addr.s_addr =htonl (INADDR_LOOPBACK ), + }; +rpcprog_t program =nfs_getrpcbyname (NSMPROG , nfs_ns_pgmtbl); + +return nfs_getport_ping ((struct sockaddr *)(char *)&addr,sizeof (addr), + program, (rpcvers_t )1 ,IPPROTO_UDP ); +}utils/mount/network.c +0
-17@@ -65,11 +65,6 @@ extern int nfs_mount_data_version;extern char *progname;extern int verbose; -static const char *nfs_ns_pgmtbl[] = { -"status" , -NULL , -}; -static const char *nfs_mnt_pgmtbl[] = {"mount" ,"mountd" ,@@ -761,18 +756,6 @@ int probe_bothports(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server) &nfs_server->pmap); } -static int nfs_probe_statd (void ) -{ -struct sockaddr_in addr = { - .sin_family =AF_INET , - .sin_addr.s_addr =htonl (INADDR_LOOPBACK ), - }; -rpcprog_t program =nfs_getrpcbyname (NSMPROG , nfs_ns_pgmtbl); - -return nfs_getport_ping (SAFE_SOCKADDR (&addr),sizeof (addr), - program, (rpcvers_t )1 ,IPPROTO_UDP ); -} -/** * start_statd - attempt to start rpc.statd * utils/statd/statd.c +6
-0@@ -237,6 +237,12 @@ int main (int argc, char **argv)/* Set hostname */ MY_NAME =NULL ; +/* Refuse to start if another statd is running */ +if (nfs_probe_statd ()) { +fprintf (stderr,"Statd service already running!\n" ); +exit (1 ); + } +/* Process command line switches */ while ((arg =getopt_long (argc, argv,"h?vVFNH:dn:p:o:P:L" , longopts,NULL )) !=EOF ) {switch (arg) {Signature · 6 lines
1.7.12.4 (Apple Git-37) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Quoted 5 lines · Weston Andros Adamson
Moves
nfs_probe_statdfrom mount to nfs support lib to share with statd.Signed-off-by Weston Andros Adamson <[email protected]>---
Quoted 8 lines
This patch stops users from running multiple instances of statd, which can obviously cause a lot of problems.
support/include/nfsrpc.h | 5 +++++ support/nfs/getport.c | 22 ++++++++++++++++++++++ utils/mount/network.c | 17 ----------------- utils/statd/statd.c | 6 ++++++ 4 files changed, 33 insertions(+), 17 deletions(-)
Committed...
steved.
Quoted 100 lines
support/include/nfsrpc.h +5
-0@@ -156,6 +156,11 @@ extern unsigned long nfs_pmap_getport(const struct sockaddr_in *, const struct timeval *);/* +* Use nfs_pmap_getport to see if statd is running locally +*/ +extern int nfs_probe_statd (void ); + +/* * Contact a remote RPC service to discover whether it is responding * to requests. */ support/nfs/getport.c +22
-0@@ -1102,3 +1102,25 @@ unsigned long nfs_pmap_getport(const struct sockaddr_in *sin,return port; } + +static const char *nfs_ns_pgmtbl[] = { +"status" , +NULL , +}; + +/* +* nfs_probe_statd - use nfs_pmap_getport to see if statd is running locally +* +* Returns non-zero if statd is running locally. +*/ +int nfs_probe_statd (void ) +{ +struct sockaddr_in addr = { + .sin_family =AF_INET , + .sin_addr.s_addr =htonl (INADDR_LOOPBACK ), + }; +rpcprog_t program =nfs_getrpcbyname (NSMPROG , nfs_ns_pgmtbl); + +return nfs_getport_ping ((struct sockaddr *)(char *)&addr,sizeof (addr), + program, (rpcvers_t )1 ,IPPROTO_UDP ); +}utils/mount/network.c +0
-17@@ -65,11 +65,6 @@ extern int nfs_mount_data_version;extern char *progname;extern int verbose; -static const char *nfs_ns_pgmtbl[] = { -"status" , -NULL , -}; -static const char *nfs_mnt_pgmtbl[] = {"mount" ,"mountd" ,@@ -761,18 +756,6 @@ int probe_bothports(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server) &nfs_server->pmap); } -static int nfs_probe_statd (void ) -{ -struct sockaddr_in addr = { - .sin_family =AF_INET , - .sin_addr.s_addr =htonl (INADDR_LOOPBACK ), - }; -rpcprog_t program =nfs_getrpcbyname (NSMPROG , nfs_ns_pgmtbl); - -return nfs_getport_ping (SAFE_SOCKADDR (&addr),sizeof (addr), - program, (rpcvers_t )1 ,IPPROTO_UDP ); -} -/** * start_statd - attempt to start rpc.statd * utils/statd/statd.c +6
-0@@ -237,6 +237,12 @@ int main (int argc, char **argv)/* Set hostname */ MY_NAME =NULL ; +/* Refuse to start if another statd is running */ +if (nfs_probe_statd ()) { +fprintf (stderr,"Statd service already running!\n" ); +exit (1 ); + } +/* Process command line switches */ while ((arg =getopt_long (argc, argv,"h?vVFNH:dn:p:o:P:L" , longopts,NULL )) !=EOF ) {switch (arg) {