Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Split the compat_50 module into two, separating the ...
details: https://anonhg.NetBSD.org/src/rev/b4cd5123f8ea
branches: trunk
changeset: 1006609:b4cd5123f8ea
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue Jan 21 02:37:16 2020 +0000
description:
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
diffstat:
distrib/sets/lists/modules/mi | 4 +-
sys/compat/common/compat_50_quota.c | 181 +++++++++++++++++++++++++++++++++++
sys/compat/common/files.common | 3 +-
sys/compat/common/vfs_syscalls_50.c | 125 +-----------------------
sys/kern/syscalls.master | 5 +-
sys/modules/Makefile | 4 +-
sys/modules/compat_50/Makefile | 3 +-
sys/modules/compat_50_quota/Makefile | 14 ++
sys/sys/param.h | 4 +-
9 files changed, 211 insertions(+), 132 deletions(-)
diffs (truncated from 470 to 300 lines):
diff -r af4da9f0ef99 -r b4cd5123f8ea distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi Mon Jan 20 23:22:09 2020 +0000
+++ b/distrib/sets/lists/modules/mi Tue Jan 21 02:37:16 2020 +0000
@@ -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
diff -r af4da9f0ef99 -r b4cd5123f8ea sys/compat/common/compat_50_quota.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/compat_50_quota.c Tue Jan 21 02:37:16 2020 +0000
@@ -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;
+ }
+}
diff -r af4da9f0ef99 -r b4cd5123f8ea sys/compat/common/files.common
--- a/sys/compat/common/files.common Mon Jan 20 23:22:09 2020 +0000
+++ b/sys/compat/common/files.common Tue Jan 21 02:37:16 2020 +0000
@@ -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/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
diff -r af4da9f0ef99 -r b4cd5123f8ea sys/compat/common/vfs_syscalls_50.c
--- a/sys/compat/common/vfs_syscalls_50.c Mon Jan 20 23:22:09 2020 +0000
+++ b/sys/compat/common/vfs_syscalls_50.c Tue Jan 21 02:37:16 2020 +0000
@@ -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 @@
#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 @@
{ 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 @@
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);
Home |
Main Index |
Thread Index |
Old Index