Module Name: src Committed By: pgoyette Date: Tue Jan 21 02:37:17 UTC 2020
Modified Files: src/distrib/sets/lists/modules: mi src/sys/compat/common: files.common vfs_syscalls_50.c src/sys/kern: syscalls.master src/sys/modules: Makefile src/sys/modules/compat_50: Makefile src/sys/sys: param.h Added Files: src/sys/compat/common: compat_50_quota.c src/sys/modules/compat_50_quota: Makefile Log Message: Split the compat_50 module into two, separating the QUOTA-related stuff from the rest of the module. This allows loading of the (main) compat_50 module on kernels that don't include ``options QUOTA''. Welcome to 9.99.40 ! Addresses PR kern/54875 To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/distrib/sets/lists/modules/mi cvs rdiff -u -r0 -r1.1 src/sys/compat/common/compat_50_quota.c cvs rdiff -u -r1.5 -r1.6 src/sys/compat/common/files.common cvs rdiff -u -r1.24 -r1.25 src/sys/compat/common/vfs_syscalls_50.c cvs rdiff -u -r1.296 -r1.297 src/sys/kern/syscalls.master cvs rdiff -u -r1.236 -r1.237 src/sys/modules/Makefile cvs rdiff -u -r1.6 -r1.7 src/sys/modules/compat_50/Makefile cvs rdiff -u -r0 -r1.1 src/sys/modules/compat_50_quota/Makefile cvs rdiff -u -r1.642 -r1.643 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/modules/mi diff -u src/distrib/sets/lists/modules/mi:1.130 src/distrib/sets/lists/modules/mi:1.131 --- src/distrib/sets/lists/modules/mi:1.130 Sun Jan 19 01:25:03 2020 +++ src/distrib/sets/lists/modules/mi Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.130 2020/01/19 01:25:03 thorpej Exp $ +# $NetBSD: mi,v 1.131 2020/01/21 02:37:16 pgoyette Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -94,6 +94,8 @@ ./@MODULEDIR@/compat_43/compat_43.kmod base-kernel-modules kmod ./@MODULEDIR@/compat_50 base-kernel-modules kmod ./@MODULEDIR@/compat_50/compat_50.kmod base-kernel-modules kmod +./@MODULEDIR@/compat_50_quota base-kernel-modules kmod +./@MODULEDIR@/compat_50_quota/compat_50_quota.kmod base-kernel-modules kmod ./@MODULEDIR@/compat_60 base-kernel-modules kmod ./@MODULEDIR@/compat_60/compat_60.kmod base-kernel-modules kmod ./@MODULEDIR@/compat_70 base-kernel-modules kmod Index: src/sys/compat/common/files.common diff -u src/sys/compat/common/files.common:1.5 src/sys/compat/common/files.common:1.6 --- src/sys/compat/common/files.common:1.5 Sun Sep 22 22:59:38 2019 +++ src/sys/compat/common/files.common Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.common,v 1.5 2019/09/22 22:59:38 christos Exp $ +# $NetBSD: files.common,v 1.6 2020/01/21 02:37:16 pgoyette Exp $ # # Generic utility files, used by various compat options. @@ -80,6 +80,7 @@ file compat/common/kern_select_50.c com file compat/common/rndpseudo_50.c compat_50 file compat/common/rtsock_50.c compat_50 file compat/common/vfs_syscalls_50.c compat_50 +file compat/common/compat_50_quota.c compat_50 & quota file compat/common/uipc_syscalls_50.c compat_50 file compat/common/vnd_50.c compat_50 file compat/common/clockctl_50.c compat_50 Index: src/sys/compat/common/vfs_syscalls_50.c diff -u src/sys/compat/common/vfs_syscalls_50.c:1.24 src/sys/compat/common/vfs_syscalls_50.c:1.25 --- src/sys/compat/common/vfs_syscalls_50.c:1.24 Sun Dec 15 16:48:26 2019 +++ src/sys/compat/common/vfs_syscalls_50.c Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls_50.c,v 1.24 2019/12/15 16:48:26 tsutsui Exp $ */ +/* $NetBSD: vfs_syscalls_50.c,v 1.25 2020/01/21 02:37:16 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.24 2019/12/15 16:48:26 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.25 2020/01/21 02:37:16 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -62,12 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls #include <ufs/lfs/lfs_extern.h> -#ifdef QUOTA -#include <sys/quota.h> -#include <sys/quotactl.h> -#include <ufs/ufs/quota1.h> -#endif - #include <compat/common/compat_util.h> #include <compat/common/compat_mod.h> #include <compat/sys/time.h> @@ -88,9 +82,6 @@ static const struct syscall_package vfs_ { SYS_compat_50_futimes, 0, (sy_call_t *)compat_50_sys_futimes }, { SYS_compat_50_lutimes, 0, (sy_call_t *)compat_50_sys_lutimes }, { SYS_compat_50_mknod, 0, (sy_call_t *)compat_50_sys_mknod }, -#ifdef QUOTA - { SYS_compat_50_quotactl, 0, (sy_call_t *)compat_50_sys_quotactl }, -#endif { 0, 0, NULL } }; @@ -339,118 +330,6 @@ compat_50_sys_mknod(struct lwp *l, SCARG(uap, dev), UIO_USERSPACE); } -#ifdef QUOTA -/* ARGSUSED */ -int -compat_50_sys_quotactl(struct lwp *l, const struct compat_50_sys_quotactl_args *uap, register_t *retval) -{ - /* { - syscallarg(const char *) path; - syscallarg(int) cmd; - syscallarg(int) uid; - syscallarg(void *) arg; - } */ - struct vnode *vp; - struct mount *mp; - int q1cmd; - int idtype; - char *qfile; - struct dqblk dqblk; - struct quotakey key; - struct quotaval blocks, files; - struct quotastat qstat; - int error; - - error = namei_simple_user(SCARG(uap, path), - NSM_FOLLOW_TRYEMULROOT, &vp); - if (error != 0) - return (error); - - mp = vp->v_mount; - q1cmd = SCARG(uap, cmd); - idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK); - - switch ((q1cmd & ~SUBCMDMASK) >> SUBCMDSHIFT) { - case Q_QUOTAON: - qfile = PNBUF_GET(); - error = copyinstr(SCARG(uap, arg), qfile, PATH_MAX, NULL); - if (error != 0) { - PNBUF_PUT(qfile); - break; - } - - error = vfs_quotactl_quotaon(mp, idtype, qfile); - - PNBUF_PUT(qfile); - break; - - case Q_QUOTAOFF: - error = vfs_quotactl_quotaoff(mp, idtype); - break; - - case Q_GETQUOTA: - key.qk_idtype = idtype; - key.qk_id = SCARG(uap, uid); - - key.qk_objtype = QUOTA_OBJTYPE_BLOCKS; - error = vfs_quotactl_get(mp, &key, &blocks); - if (error) { - break; - } - - key.qk_objtype = QUOTA_OBJTYPE_FILES; - error = vfs_quotactl_get(mp, &key, &files); - if (error) { - break; - } - - quotavals_to_dqblk(&blocks, &files, &dqblk); - error = copyout(&dqblk, SCARG(uap, arg), sizeof(dqblk)); - break; - - case Q_SETQUOTA: - error = copyin(SCARG(uap, arg), &dqblk, sizeof(dqblk)); - if (error) { - break; - } - dqblk_to_quotavals(&dqblk, &blocks, &files); - - key.qk_idtype = idtype; - key.qk_id = SCARG(uap, uid); - - key.qk_objtype = QUOTA_OBJTYPE_BLOCKS; - error = vfs_quotactl_put(mp, &key, &blocks); - if (error) { - break; - } - - key.qk_objtype = QUOTA_OBJTYPE_FILES; - error = vfs_quotactl_put(mp, &key, &files); - break; - - case Q_SYNC: - /* - * not supported but used only to see if quota is supported, - * emulate with stat - * - * XXX should probably be supported - */ - (void)idtype; /* not used */ - - error = vfs_quotactl_stat(mp, &qstat); - break; - - case Q_SETUSE: - default: - error = EOPNOTSUPP; - break; - } - - vrele(vp); - return error; -} -#endif - int vfs_syscalls_50_init(void) { Index: src/sys/kern/syscalls.master diff -u src/sys/kern/syscalls.master:1.296 src/sys/kern/syscalls.master:1.297 --- src/sys/kern/syscalls.master:1.296 Sun Sep 22 22:59:39 2019 +++ src/sys/kern/syscalls.master Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.296 2019/09/22 22:59:39 christos Exp $ + $NetBSD: syscalls.master,v 1.297 2020/01/21 02:37:16 pgoyette Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -316,7 +316,8 @@ 146 COMPAT_43 MODULAR compat_43 \ { int|sys||killpg(int pgid, int signum); } okillpg 147 STD RUMP { int|sys||setsid(void); } -148 COMPAT_50 MODULAR compat_50 { int|sys||quotactl(const char *path, \ +148 COMPAT_50 MODULAR compat_50_quota \ + { int|sys||quotactl(const char *path, \ int cmd, int uid, void *arg); } 149 COMPAT_43 MODULAR compat_43 { int|sys||quota(void); } oquota 150 COMPAT_43 MODULAR compat_43 { int|sys||getsockname(int fdec, \ Index: src/sys/modules/Makefile diff -u src/sys/modules/Makefile:1.236 src/sys/modules/Makefile:1.237 --- src/sys/modules/Makefile:1.236 Sun Jan 19 20:41:19 2020 +++ src/sys/modules/Makefile Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.236 2020/01/19 20:41:19 riastradh Exp $ +# $NetBSD: Makefile,v 1.237 2020/01/21 02:37:16 pgoyette Exp $ .include <bsd.own.mk> @@ -14,6 +14,8 @@ SUBDIR+= compat_60 compat_70 compat_ SUBDIR+= compat_sysv_10 compat_sysv_14 compat_sysv_50 +SUBDIR+= compat_50_quota + SUBDIR+= compat_raid_50 SUBDIR+= compat_raid_80 Index: src/sys/modules/compat_50/Makefile diff -u src/sys/modules/compat_50/Makefile:1.6 src/sys/modules/compat_50/Makefile:1.7 --- src/sys/modules/compat_50/Makefile:1.6 Thu Sep 26 02:00:27 2019 +++ src/sys/modules/compat_50/Makefile Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2019/09/26 02:00:27 christos Exp $ +# $NetBSD: Makefile,v 1.7 2020/01/21 02:37:16 pgoyette Exp $ .include "../Makefile.inc" @@ -7,7 +7,6 @@ KMOD= compat_50 CPPFLAGS+= -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -DCOMPAT_80 -CPPFLAGS+= -DQUOTA SRCS+= compat_50_mod.c SRCS+= kern_50.c kern_time_50.c kern_select_50.c Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.642 src/sys/sys/param.h:1.643 --- src/sys/sys/param.h:1.642 Fri Jan 17 20:11:03 2020 +++ src/sys/sys/param.h Tue Jan 21 02:37:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.642 2020/01/17 20:11:03 ad Exp $ */ +/* $NetBSD: param.h,v 1.643 2020/01/21 02:37:16 pgoyette Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 999003900 /* NetBSD 9.99.39 */ +#define __NetBSD_Version__ 999004000 /* NetBSD 9.99.40 */ #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) Added files: Index: src/sys/compat/common/compat_50_quota.c diff -u /dev/null src/sys/compat/common/compat_50_quota.c:1.1 --- /dev/null Tue Jan 21 02:37:17 2020 +++ src/sys/compat/common/compat_50_quota.c Tue Jan 21 02:37:16 2020 @@ -0,0 +1,181 @@ +/* $NetBSD: compat_50_quota.c,v 1.1 2020/01/21 02:37:16 pgoyette Exp $ */ + +/*- + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: compat_50_quota.c,v 1.1 2020/01/21 02:37:16 pgoyette Exp $"); + +#if defined(_KERNEL_OPT) +#include "opt_compat_netbsd.h" +#endif + +#include <sys/module.h> +#include <sys/namei.h> +#include <sys/param.h> +#include <sys/quota.h> +#include <sys/quotactl.h> +#include <sys/systm.h> +#include <sys/syscall.h> +#include <sys/syscallvar.h> +#include <sys/syscallargs.h> +#include <sys/vfs_syscalls.h> +#include <sys/vnode.h> + +#include <ufs/ufs/quota1.h> + +static const struct syscall_package vfs_syscalls_50_quota_syscalls[] = { + { SYS_compat_50_quotactl, 0, (sy_call_t *)compat_50_sys_quotactl }, + { 0, 0, NULL } +}; + +/* ARGSUSED */ +int +compat_50_sys_quotactl(struct lwp *l, const struct compat_50_sys_quotactl_args *uap, register_t *retval) +{ + /* { + syscallarg(const char *) path; + syscallarg(int) cmd; + syscallarg(int) uid; + syscallarg(void *) arg; + } */ + struct vnode *vp; + struct mount *mp; + int q1cmd; + int idtype; + char *qfile; + struct dqblk dqblk; + struct quotakey key; + struct quotaval blocks, files; + struct quotastat qstat; + int error; + + error = namei_simple_user(SCARG(uap, path), + NSM_FOLLOW_TRYEMULROOT, &vp); + if (error != 0) + return (error); + + mp = vp->v_mount; + q1cmd = SCARG(uap, cmd); + idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK); + + switch ((q1cmd & ~SUBCMDMASK) >> SUBCMDSHIFT) { + case Q_QUOTAON: + qfile = PNBUF_GET(); + error = copyinstr(SCARG(uap, arg), qfile, PATH_MAX, NULL); + if (error != 0) { + PNBUF_PUT(qfile); + break; + } + + error = vfs_quotactl_quotaon(mp, idtype, qfile); + + PNBUF_PUT(qfile); + break; + + case Q_QUOTAOFF: + error = vfs_quotactl_quotaoff(mp, idtype); + break; + + case Q_GETQUOTA: + key.qk_idtype = idtype; + key.qk_id = SCARG(uap, uid); + + key.qk_objtype = QUOTA_OBJTYPE_BLOCKS; + error = vfs_quotactl_get(mp, &key, &blocks); + if (error) { + break; + } + + key.qk_objtype = QUOTA_OBJTYPE_FILES; + error = vfs_quotactl_get(mp, &key, &files); + if (error) { + break; + } + + quotavals_to_dqblk(&blocks, &files, &dqblk); + error = copyout(&dqblk, SCARG(uap, arg), sizeof(dqblk)); + break; + + case Q_SETQUOTA: + error = copyin(SCARG(uap, arg), &dqblk, sizeof(dqblk)); + if (error) { + break; + } + dqblk_to_quotavals(&dqblk, &blocks, &files); + + key.qk_idtype = idtype; + key.qk_id = SCARG(uap, uid); + + key.qk_objtype = QUOTA_OBJTYPE_BLOCKS; + error = vfs_quotactl_put(mp, &key, &blocks); + if (error) { + break; + } + + key.qk_objtype = QUOTA_OBJTYPE_FILES; + error = vfs_quotactl_put(mp, &key, &files); + break; + + case Q_SYNC: + /* + * not supported but used only to see if quota is supported, + * emulate with stat + * + * XXX should probably be supported + */ + (void)idtype; /* not used */ + + error = vfs_quotactl_stat(mp, &qstat); + break; + + case Q_SETUSE: + default: + error = EOPNOTSUPP; + break; + } + + vrele(vp); + return error; +} + +MODULE(MODULE_CLASS_EXEC, compat_50_quota, "compat_60"); + +static int +compat_50_quota_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + return syscall_establish(NULL, vfs_syscalls_50_quota_syscalls); + case MODULE_CMD_FINI: + return syscall_disestablish(NULL, vfs_syscalls_50_quota_syscalls); + default: + return ENOTTY; + } +} Index: src/sys/modules/compat_50_quota/Makefile diff -u /dev/null src/sys/modules/compat_50_quota/Makefile:1.1 --- /dev/null Tue Jan 21 02:37:17 2020 +++ src/sys/modules/compat_50_quota/Makefile Tue Jan 21 02:37:17 2020 @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 2020/01/21 02:37:17 pgoyette Exp $ + +.include "../Makefile.inc" + +.PATH: ${S}/compat/common + +KMOD= compat_50_quota + +CPPFLAGS+= -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -DCOMPAT_80 +CPPFLAGS+= -DQUOTA + +SRCS+= compat_50_quota.c + +.include <bsd.kmodule.mk>