Module Name:    src
Committed By:   bouyer
Date:           Tue Feb 15 16:45:57 UTC 2011

Modified Files:
        src/sys/compat/common [bouyer-quota2]: compat_mod.c vfs_syscalls_50.c
        src/sys/kern [bouyer-quota2]: vfs_syscalls.c
        src/sys/rump/fs/lib/libffs [bouyer-quota2]: Makefile
        src/sys/rump/librump/rumpvfs [bouyer-quota2]: Makefile.rumpvfs
        src/sys/ufs [bouyer-quota2]: files.ufs

Log Message:
Implement COMPAT_50 quotactl(2)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.2.1 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/compat/common/vfs_syscalls_50.c
cvs rdiff -u -r1.414.4.2 -r1.414.4.3 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.12.4.1 -r1.12.4.2 src/sys/rump/fs/lib/libffs/Makefile
cvs rdiff -u -r1.28 -r1.28.4.1 src/sys/rump/librump/rumpvfs/Makefile.rumpvfs
cvs rdiff -u -r1.24.6.3 -r1.24.6.4 src/sys/ufs/files.ufs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.12 src/sys/compat/common/compat_mod.c:1.12.2.1
--- src/sys/compat/common/compat_mod.c:1.12	Wed Jan 19 10:21:16 2011
+++ src/sys/compat/common/compat_mod.c	Tue Feb 15 16:45:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.12 2011/01/19 10:21:16 tsutsui Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.12.2.1 2011/02/15 16:45:56 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.12 2011/01/19 10:21:16 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.12.2.1 2011/02/15 16:45:56 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -230,6 +230,7 @@
 # endif
 	{ SYS_compat_50___fhstat40, 0, (sy_call_t *)compat_50_sys___fhstat40 },
 	{ SYS_compat_50_aio_suspend, 0, (sy_call_t *)compat_50_sys_aio_suspend },
+	{ SYS_compat_50_quotactl, 0, (sy_call_t *)compat_50_sys_quotactl },
 #endif
 	{ 0, 0, NULL },
 };

Index: src/sys/compat/common/vfs_syscalls_50.c
diff -u src/sys/compat/common/vfs_syscalls_50.c:1.6 src/sys/compat/common/vfs_syscalls_50.c:1.6.4.1
--- src/sys/compat/common/vfs_syscalls_50.c:1.6	Tue Jul 13 15:38:15 2010
+++ src/sys/compat/common/vfs_syscalls_50.c	Tue Feb 15 16:45:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_50.c,v 1.6 2010/07/13 15:38:15 pooka Exp $	*/
+/*	$NetBSD: vfs_syscalls_50.c,v 1.6.4.1 2011/02/15 16:45:56 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.6 2010/07/13 15:38:15 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.6.4.1 2011/02/15 16:45:56 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -312,3 +312,218 @@
 	return do_sys_mknod(l, SCARG(uap, path), SCARG(uap, mode),
 	    SCARG(uap, dev), retval, UIO_USERSPACE);
 }
+
+#include <ufs/ufs/quota1.h>
+#include <ufs/ufs/quota2_prop.h>
+
+/* 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 mount *mp;
+	int error;
+	uint8_t error8;
+	struct vnode *vp;
+	int q1cmd = SCARG(uap, cmd);
+	prop_dictionary_t dict, data, cmd;
+	prop_array_t cmds, datas;
+	char *bufpath;
+	struct dqblk dqblk;
+	struct quota2_entry q2e;
+	static const char *quotatypes[MAXQUOTAS] = INITQFNAMES;
+
+	error = namei_simple_user(SCARG(uap, path),
+				NSM_FOLLOW_TRYEMULROOT, &vp);
+	if (error != 0)
+		return (error);       
+	error = ENOMEM;
+	mp = vp->v_mount;
+	if ((dict = quota2_prop_create()) == NULL)
+		goto out;
+	if ((cmds = prop_array_create()) == NULL)
+		goto out_dict;
+	if ((datas = prop_array_create()) == NULL)
+		goto out_cmds;
+
+	switch((q1cmd & ~SUBCMDMASK) >> SUBCMDSHIFT) {
+	case Q_QUOTAON:
+		data = prop_dictionary_create();
+		if (data == NULL)
+			goto out_datas;
+		bufpath = malloc(PATH_MAX * sizeof(char), M_TEMP, M_WAITOK);
+		if (bufpath == NULL)
+			goto out_data;
+		error = copyinstr(SCARG(uap, arg), bufpath, PATH_MAX, NULL);
+		if (error != 0) {
+			free(bufpath, M_TEMP);
+			goto out_data;
+		}
+		if (!prop_dictionary_set_cstring(data, "quotafile", bufpath))
+			error = ENOMEM;
+		free(bufpath, M_TEMP);
+		if (error)
+			goto out_data;
+		error = ENOMEM;
+		if (!prop_array_add_and_rel(datas, data))
+			goto out_datas;
+		if (!quota2_prop_add_command(cmds, "quotaon",
+		    quotatypes[q1cmd & SUBCMDMASK], datas))
+			goto out_cmds;
+		goto do_quotaonoff;
+
+	case Q_QUOTAOFF:
+		error = ENOMEM;
+		if (!quota2_prop_add_command(cmds, "quotaoff",
+		    quotatypes[q1cmd & SUBCMDMASK], datas))
+			goto out_cmds;
+do_quotaonoff:
+		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
+			goto out_dict;
+		error = VFS_QUOTACTL(mp, dict);
+		if (error)
+			goto out_dict;
+		if ((error = quota2_get_cmds(dict, &cmds)) != 0)
+			goto out_dict;
+		cmd = prop_array_get(cmds, 0);
+		if (cmd == NULL) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		if (!prop_dictionary_get_int8(cmd, "return", &error8)) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		error = error8;
+		goto out_dict;
+
+	case Q_GETQUOTA:
+		error = ENOMEM;
+		data = prop_dictionary_create();
+		if (data == NULL)
+			goto out_datas;
+		if (!prop_dictionary_set_uint32(data, "id", SCARG(uap, uid)))
+			goto out_data;
+		if (!prop_array_add_and_rel(datas, data))
+			goto out_datas;
+		if (!quota2_prop_add_command(cmds, "get",
+		    quotatypes[q1cmd & SUBCMDMASK], datas))
+			goto out_cmds;
+		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
+			goto out_dict;
+		error = VFS_QUOTACTL(mp, dict);
+		if (error)
+			goto out_dict;
+		if ((error = quota2_get_cmds(dict, &cmds)) != 0)
+			goto out_dict;
+		cmd = prop_array_get(cmds, 0);
+		if (cmd == NULL) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		if (!prop_dictionary_get_int8(cmd, "return", &error8)) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		error = error8;
+		if (error)
+			goto out_dict;
+		datas = prop_dictionary_get(cmd, "data");
+		error = EINVAL;
+		if (datas == NULL)
+			goto out_dict;
+		data = prop_array_get(datas, 0);
+		if (data == NULL)
+			goto out_dict;
+		error = quota2_dict_get_q2e_usage(data, &q2e);
+		if (error)
+			goto out_dict;
+		q2e2dqblk(&q2e, &dqblk);
+		error = copyout(&dqblk, SCARG(uap, arg), sizeof(dqblk));
+		goto out_dict;
+		
+	case Q_SETQUOTA:
+		error = copyin(SCARG(uap, arg), &dqblk, sizeof(dqblk));
+		if (error)
+			goto out_datas;
+		dqblk2q2e(&dqblk, &q2e);
+		q2e.q2e_uid = SCARG(uap, uid);
+
+		error = ENOMEM;
+		data = q2etoprop(&q2e, 0);
+		if (data == NULL)
+			goto out_data;
+		if (!prop_array_add_and_rel(datas, data))
+			goto out_datas;
+		if (!quota2_prop_add_command(cmds, "set",
+		    quotatypes[q1cmd & SUBCMDMASK], datas))
+			goto out_cmds;
+		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
+			goto out_dict;
+		error = VFS_QUOTACTL(mp, dict);
+		if (error)
+			goto out_dict;
+		if ((error = quota2_get_cmds(dict, &cmds)) != 0)
+			goto out_dict;
+		cmd = prop_array_get(cmds, 0);
+		if (cmd == NULL) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		if (!prop_dictionary_get_int8(cmd, "return", &error8)) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		error = error8;
+		goto out_dict;
+		
+	case Q_SYNC:
+		/*
+		 * not supported but used only to see if quota is supported,
+		 * emulate with a "get version"
+		 */
+		error = ENOMEM;
+		if (!quota2_prop_add_command(cmds, "get version",
+		    quotatypes[q1cmd & SUBCMDMASK], datas))
+			goto out_cmds;
+		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
+			goto out_dict;
+		error = VFS_QUOTACTL(mp, dict);
+		if (error)
+			goto out_dict;
+		if ((error = quota2_get_cmds(dict, &cmds)) != 0)
+			goto out_dict;
+		cmd = prop_array_get(cmds, 0);
+		if (cmd == NULL) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		if (!prop_dictionary_get_int8(cmd, "return", &error8)) {
+			error = EINVAL;
+			goto out_dict;
+		}
+		error = error8;
+		goto out_dict;
+
+	case Q_SETUSE:
+	default:
+		error = EOPNOTSUPP;
+		goto out_datas;
+	}
+out_data:
+	prop_object_release(data);
+out_datas:
+	prop_object_release(datas);
+out_cmds:
+	prop_object_release(cmds);
+out_dict:
+	prop_object_release(dict);
+out:
+	vrele(vp);
+	return error;
+}

Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.414.4.2 src/sys/kern/vfs_syscalls.c:1.414.4.3
--- src/sys/kern/vfs_syscalls.c:1.414.4.2	Fri Feb 11 11:27:29 2011
+++ src/sys/kern/vfs_syscalls.c	Tue Feb 15 16:45:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.414.4.2 2011/02/11 11:27:29 bouyer Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.414.4.3 2011/02/15 16:45:56 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.414.4.2 2011/02/11 11:27:29 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.414.4.3 2011/02/15 16:45:56 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -852,38 +852,6 @@
  */
 /* 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 mount *mp;
-	int error;
-	struct vnode *vp;
-
-	error = namei_simple_user(SCARG(uap, path),
-				NSM_FOLLOW_TRYEMULROOT, &vp);
-	if (error != 0)
-		return (error);
-	mp = vp->v_mount;
-#if 0
-	error = VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid),
-	    SCARG(uap, arg));
-#else
-	error = EOPNOTSUPP;
-#endif
-	vrele(vp);
-	return (error);
-}
-
-/*
- * Change filesystem quotas.
- */
-/* ARGSUSED */
-int
 sys___quotactl50(struct lwp *l, const struct sys___quotactl50_args *uap,
     register_t *retval)
 {

Index: src/sys/rump/fs/lib/libffs/Makefile
diff -u src/sys/rump/fs/lib/libffs/Makefile:1.12.4.1 src/sys/rump/fs/lib/libffs/Makefile:1.12.4.2
--- src/sys/rump/fs/lib/libffs/Makefile:1.12.4.1	Thu Jan 20 14:24:59 2011
+++ src/sys/rump/fs/lib/libffs/Makefile	Tue Feb 15 16:45:57 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.12.4.1 2011/01/20 14:24:59 bouyer Exp $
+#	$NetBSD: Makefile,v 1.12.4.2 2011/02/15 16:45:57 bouyer Exp $
 #
 
 .PATH:  ${.CURDIR}/../../../../ufs/ffs ${.CURDIR}/../../../../ufs/ufs
@@ -11,7 +11,7 @@
 
 SRCS+=	ufs_bmap.c ufs_dirhash.c ufs_extattr.c ufs_ihash.c ufs_inode.c	\
 	ufs_lookup.c ufs_vfsops.c ufs_vnops.c ufs_wapbl.c \
-	ufs_quota.c ufs_quota2.c quota2_subr.c quota2_prop.c
+	ufs_quota.c ufs_quota2.c
 
 CPPFLAGS+=	-DFFS_EI -DUFS_DIRHASH -DWAPBL -DAPPLE_UFS -DUFS_EXTATTR \
 		-DQUOTA2

Index: src/sys/rump/librump/rumpvfs/Makefile.rumpvfs
diff -u src/sys/rump/librump/rumpvfs/Makefile.rumpvfs:1.28 src/sys/rump/librump/rumpvfs/Makefile.rumpvfs:1.28.4.1
--- src/sys/rump/librump/rumpvfs/Makefile.rumpvfs:1.28	Wed Apr 21 16:29:08 2010
+++ src/sys/rump/librump/rumpvfs/Makefile.rumpvfs	Tue Feb 15 16:45:57 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.rumpvfs,v 1.28 2010/04/21 16:29:08 pooka Exp $
+#	$NetBSD: Makefile.rumpvfs,v 1.28.4.1 2011/02/15 16:45:57 bouyer Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -10,7 +10,8 @@
 	${RUMPTOP}/../miscfs/genfs ${RUMPTOP}/../miscfs/syncfs	\
 	${RUMPTOP}/../miscfs/specfs ${RUMPTOP}/../miscfs/deadfs	\
 	${RUMPTOP}/../compat/common ${RUMPTOP}/../uvm		\
-	${RUMPTOP}/../dev ${RUMPTOP}/../ufs/mfs
+	${RUMPTOP}/../dev ${RUMPTOP}/../ufs/mfs			\
+	${RUMPTOP}/../dev ${RUMPTOP}/../ufs/ufs
 
 #
 # Source modules, first the ones specifically implemented for librump.
@@ -49,6 +50,9 @@
 # MFS miniroot support
 SRCS+=	mfs_miniroot.c
 
+#quota2 plists
+SRCS+= quota1_subr.c quota2_subr.c quota2_prop.c 
+
 # dev
 # firmload is technically part of rumpdev, but it's pure vfs in nature.
 SRCS+=	firmload.c

Index: src/sys/ufs/files.ufs
diff -u src/sys/ufs/files.ufs:1.24.6.3 src/sys/ufs/files.ufs:1.24.6.4
--- src/sys/ufs/files.ufs:1.24.6.3	Wed Feb  9 16:15:01 2011
+++ src/sys/ufs/files.ufs	Tue Feb 15 16:45:57 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ufs,v 1.24.6.3 2011/02/09 16:15:01 bouyer Exp $
+#	$NetBSD: files.ufs,v 1.24.6.4 2011/02/15 16:45:57 bouyer Exp $
 
 deffs					FFS
 deffs					EXT2FS
@@ -62,9 +62,9 @@
 file	ufs/ufs/ufs_quota.c		(quota | quota2) & (ffs | lfs | mfs | ext2fs)
 file	ufs/ufs/ufs_quota1.c		quota & (ffs | lfs | mfs | ext2fs)
 file	ufs/ufs/ufs_quota2.c		quota2 & (ffs | lfs | mfs | ext2fs)
-file	ufs/ufs/quota1_subr.c		quota & (ffs | lfs | mfs | ext2fs)
-file	ufs/ufs/quota2_subr.c		quota2 & (ffs | lfs | mfs | ext2fs)
-file	ufs/ufs/quota2_prop.c		(quota | quota2) & (ffs | lfs | mfs | ext2fs)
+file	ufs/ufs/quota1_subr.c
+file	ufs/ufs/quota2_subr.c
+file	ufs/ufs/quota2_prop.c
 file	ufs/ufs/ufs_vfsops.c		ffs | lfs | mfs | ext2fs
 file	ufs/ufs/ufs_vnops.c		ffs | lfs | mfs | ext2fs
 file	ufs/ufs/ufs_wapbl.c		ffs & wapbl

Reply via email to