From 7cbd4b199f783e1ae9aaa1d3904e2700dbfcf48d Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 7 Aug 2006 16:37:13 +1000 Subject: [PATCH] "rpc.nfsd XX" should not fail if ports are already open. support/nfs/nfssvc.c: if any ports are already open, don't try to open any more. This means that once nfsd is running rpc.nfsd X will just change the number of threads, not the ports in use. --- ChangeLog | 12 +++++++++++- support/nfs/nfssvc.c | 16 +++++++++++++++- utils/nfsd/nfsd.man | 13 ++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 364ec0f..2e57dd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ Author: NeilBrown -Date: Mon Aug 7 14:01:35 EST 2006 +Date: Mon Aug 7 16:35:03 AEST 2006 + + support/nfs/nfssvc.c: if any ports are already open, + don't try to open any more. + This means that once nfsd is running + rpc.nfsd X + will just change the number of threads, not the + ports in use. + +Author: NeilBrown +Date: Mon Aug 7 14:01:35 AEST 2006 Remove warning if neither 'sync' or 'async' present. Add warning of neither 'subtree_check' or 'no_subtree_check' present. diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c index 1feffdd..ef7d8e1 100644 --- a/support/nfs/nfssvc.c +++ b/support/nfs/nfssvc.c @@ -28,11 +28,25 @@ static void nfssvc_setfds(int port, unsigned int ctlbits, char *haddr) { - int fd, on=1; + int fd, n, on=1; char buf[BUFSIZ]; int udpfd = -1, tcpfd = -1; struct sockaddr_in sin; + fd = open(NFSD_PORTS_FILE, O_RDONLY); + if (fd < 0) + return; + n = read(fd, buf, BUFSIZ); + close(fd); + if (n != 0) + return; + /* there are no ports currently open, so it is safe to + * try to open some and pass them through. + * Note: If the user explicitly asked for 'udp', then + * we should probably check if that is open, and should + * open it if not. However we don't yet. All sockets + * have to be opened when the first daemon is started. + */ fd = open(NFSD_PORTS_FILE, O_WRONLY); if (fd < 0) return; diff --git a/utils/nfsd/nfsd.man b/utils/nfsd/nfsd.man index 4ac709c..3500ae2 100644 --- a/utils/nfsd/nfsd.man +++ b/utils/nfsd/nfsd.man @@ -2,7 +2,7 @@ .\" nfsd(8) .\" .\" Copyright (C) 1999 Olaf Kirch -.TH rpc.nfsd 8 "31 May 1999" +.TH rpc.nfsd 8 "7 Aug 2006" .SH NAME rpc.nfsd \- NFS server process .SH SYNOPSIS @@ -64,6 +64,17 @@ load created by the NFS clients, but a useful starting point is the .BR nfsstat (8) program. +.P +Note that if the NFS server is already running, then the options for +specifying host, port, and protocol will be ignored. The number of +processes given will be the only option considered, and the number of +active +.B nfsd +processes will be increased or decreased to match this number. +In particular +.B rpc.nfsd 0 +will stop all threads and thus close any open connections. + .SH SEE ALSO .BR rpc.mountd (8), .BR exportfs (8), -- 2.39.5