git: 4ce0e24735a1 - stable/13 - nfsd: Return ENXIO instead of EPERM when nfsd(8) already running

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 24 May 2023 02:13:42 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=4ce0e24735a1619f54a22b263518e671256aef7e

commit 4ce0e24735a1619f54a22b263518e671256aef7e
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2023-02-22 21:19:07 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2023-05-24 02:07:39 +0000

    nfsd: Return ENXIO instead of EPERM when nfsd(8) already running
    
    The nfsd(8) daemon generates an error message that does not
    indicate that the nfsd daemon is already running when the nfssvc(2)
    syscall fails for the NFSSVC_STABLERESTART.  Also, the check for
    running nfsd(8) in a vnet prison will return EPERM when it fails.
    
    This patch replaces EPERM with ENXIO so that the nfsd(8) daemon
    can generate more reasonable failure messages.  The nfsd(8) daemon
    will be patched in a future commit.
    
    (cherry picked from commit 10dff9da9748b0eadd2d02dded3afd2321d15537)
---
 sys/fs/nfsserver/nfs_nfsdport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index a5fcf58b3d9f..06e6a4147f30 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -4018,7 +4018,7 @@ nfssvc_srvcall(struct thread *p, struct nfssvc_args *uap, struct ucred *cred)
 		if (!error && (NFSFPFLAG(fp) & (FREAD | FWRITE)) != (FREAD | FWRITE))
 			error = EBADF;
 		if (!error && NFSD_VNET(nfsrv_numnfsd) != 0)
-			error = EPERM;
+			error = ENXIO;
 		if (!error) {
 			NFSD_VNET(nfsrv_stablefirst).nsf_fp = fp;
 			nfsrv_setupstable(p);