Module Name: src Committed By: hannken Date: Fri Jun 4 10:44:59 UTC 2021
Modified Files: src/sys/nfs: nfs.h nfs_export.c nfs_syscalls.c nfs_var.h Log Message: Add flag/command NFSSVC_REPLACEEXPORTSLIST to nfssvc(2) system call. Works like NFSSVC_SETEXPORTSLIST but supports "mel_nexports > 1" and will atomically update the complete exports list for a file system. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/nfs/nfs.h cvs rdiff -u -r1.62 -r1.63 src/sys/nfs/nfs_export.c cvs rdiff -u -r1.162 -r1.163 src/sys/nfs/nfs_syscalls.c cvs rdiff -u -r1.94 -r1.95 src/sys/nfs/nfs_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/nfs/nfs.h diff -u src/sys/nfs/nfs.h:1.78 src/sys/nfs/nfs.h:1.79 --- src/sys/nfs/nfs.h:1.78 Wed Aug 22 01:05:24 2018 +++ src/sys/nfs/nfs.h Fri Jun 4 10:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs.h,v 1.78 2018/08/22 01:05:24 msaitoh Exp $ */ +/* $NetBSD: nfs.h,v 1.79 2021/06/04 10:44:58 hannken Exp $ */ /* * Copyright (c) 1989, 1993, 1995 * The Regents of the University of California. All rights reserved. @@ -285,6 +285,7 @@ struct nfsstats { #define NFSSVC_AUTHINFAIL 0x080 #define NFSSVC_MNTD 0x100 #define NFSSVC_SETEXPORTSLIST 0x200 +#define NFSSVC_REPLACEEXPORTSLIST 0x400 /* * fs.nfs sysctl(3) identifiers Index: src/sys/nfs/nfs_export.c diff -u src/sys/nfs/nfs_export.c:1.62 src/sys/nfs/nfs_export.c:1.63 --- src/sys/nfs/nfs_export.c:1.62 Fri Jan 17 20:08:09 2020 +++ src/sys/nfs/nfs_export.c Fri Jun 4 10:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $ */ +/* $NetBSD: nfs_export.c,v 1.63 2021/06/04 10:44:58 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2008, 2019 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.63 2021/06/04 10:44:58 hannken Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -233,17 +233,14 @@ netexport_fini(void) * Returns zero on success or an appropriate error code otherwise. * * Helper function for the nfssvc(2) system call (NFSSVC_SETEXPORTSLIST - * command). + * and NFSSVC_REPLACEEXPORTSLIST command). */ int mountd_set_exports_list(const struct mountd_exports_list *mel, struct lwp *l, - struct mount *nmp) + struct mount *nmp, int cmd) { int error; -#ifdef notyet - /* XXX: See below to see the reason why this is disabled. */ size_t i; -#endif struct mount *mp; struct netexport *ne; struct pathbuf *pb; @@ -302,31 +299,24 @@ mountd_set_exports_list(const struct mou KASSERT(ne != NULL); KASSERT(ne->ne_mount == mp); - /* - * XXX: The part marked as 'notyet' works fine from the kernel's - * point of view, in the sense that it is able to atomically update - * the complete exports list for a file system. However, supporting - * this in mountd(8) requires a lot of work; so, for now, keep the - * old behavior of updating a single entry per call. - * - * When mountd(8) is fixed, just remove the second branch of this - * preprocessor conditional and enable the first one. - */ -#ifdef notyet - netexport_clear(ne); - for (i = 0; error == 0 && i < mel->mel_nexports; i++) - error = export(ne, &mel->mel_exports[i]); -#else - if (mel->mel_nexports == 0) + if (cmd == NFSSVC_SETEXPORTSLIST) { + if (mel->mel_nexports == 0) + netexport_clear(ne); + else if (mel->mel_nexports == 1) + error = export(ne, &mel->mel_exports[0]); + else { + printf("%s: Cannot set more than one " + "entry at once (unimplemented)\n", __func__); + error = EOPNOTSUPP; + } + } else if (cmd == NFSSVC_REPLACEEXPORTSLIST) { netexport_clear(ne); - else if (mel->mel_nexports == 1) - error = export(ne, &mel->mel_exports[0]); - else { - printf("%s: Cannot set more than one " - "entry at once (unimplemented)\n", __func__); + for (i = 0; error == 0 && i < mel->mel_nexports; i++) + error = export(ne, &mel->mel_exports[i]); + } else { + printf("%s: Command %#x not implemented\n", __func__, cmd); error = EOPNOTSUPP; } -#endif out: netexport_wrunlock(); @@ -455,7 +445,7 @@ nfs_export_update_30(struct mount *mp, c mel.mel_exports = (void *)&args->eargs; } - return mountd_set_exports_list(&mel, curlwp, mp); + return mountd_set_exports_list(&mel, curlwp, mp, NFSSVC_SETEXPORTSLIST); } /* Index: src/sys/nfs/nfs_syscalls.c diff -u src/sys/nfs/nfs_syscalls.c:1.162 src/sys/nfs/nfs_syscalls.c:1.163 --- src/sys/nfs/nfs_syscalls.c:1.162 Sat Mar 14 18:08:39 2020 +++ src/sys/nfs/nfs_syscalls.c Fri Jun 4 10:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_syscalls.c,v 1.162 2020/03/14 18:08:39 ad Exp $ */ +/* $NetBSD: nfs_syscalls.c,v 1.163 2021/06/04 10:44:58 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.162 2020/03/14 18:08:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.163 2021/06/04 10:44:58 hannken Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -340,7 +340,7 @@ do_nfssvc(struct nfssvc_copy_ops *ops, s } error = nfssvc_addsock(fp, nam); fd_putfile(nfsdarg.sock); - } else if (flag & NFSSVC_SETEXPORTSLIST) { + } else if (flag & (NFSSVC_SETEXPORTSLIST | NFSSVC_REPLACEEXPORTSLIST)) { struct export_args *args; struct mountd_exports_list mel; @@ -357,7 +357,8 @@ do_nfssvc(struct nfssvc_copy_ops *ops, s } mel.mel_exports = args; - error = mountd_set_exports_list(&mel, l, NULL); + error = mountd_set_exports_list(&mel, l, NULL, + flag & (NFSSVC_SETEXPORTSLIST | NFSSVC_REPLACEEXPORTSLIST)); free(args, M_TEMP); } else { Index: src/sys/nfs/nfs_var.h diff -u src/sys/nfs/nfs_var.h:1.94 src/sys/nfs/nfs_var.h:1.95 --- src/sys/nfs/nfs_var.h:1.94 Wed Jul 15 03:28:55 2015 +++ src/sys/nfs/nfs_var.h Fri Jun 4 10:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_var.h,v 1.94 2015/07/15 03:28:55 manu Exp $ */ +/* $NetBSD: nfs_var.h,v 1.95 2021/06/04 10:44:58 hannken Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -356,7 +356,7 @@ int do_nfssvc(struct nfssvc_copy_ops *, /* nfs_export.c */ extern struct nfs_public nfs_pub; int mountd_set_exports_list(const struct mountd_exports_list *, struct lwp *, - struct mount *); + struct mount *, int); int netexport_check(const fsid_t *, struct mbuf *, struct mount **, int *, kauth_cred_t *); void netexport_rdlock(void);