Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_quota.c revision 1.1.6.3
      1  1.1.6.3    martin /*	$NetBSD: netbsd32_quota.c,v 1.1.6.3 2020/04/13 08:04:16 martin Exp $	*/
      2  1.1.6.2  christos 
      3  1.1.6.2  christos /*
      4  1.1.6.2  christos  * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green
      5  1.1.6.2  christos  * All rights reserved.
      6  1.1.6.2  christos  *
      7  1.1.6.2  christos  * Redistribution and use in source and binary forms, with or without
      8  1.1.6.2  christos  * modification, are permitted provided that the following conditions
      9  1.1.6.2  christos  * are met:
     10  1.1.6.2  christos  * 1. Redistributions of source code must retain the above copyright
     11  1.1.6.2  christos  *    notice, this list of conditions and the following disclaimer.
     12  1.1.6.2  christos  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.6.2  christos  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.6.2  christos  *    documentation and/or other materials provided with the distribution.
     15  1.1.6.2  christos  *
     16  1.1.6.2  christos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1.6.2  christos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1.6.2  christos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1.6.2  christos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1.6.2  christos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  1.1.6.2  christos  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  1.1.6.2  christos  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  1.1.6.2  christos  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  1.1.6.2  christos  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1.6.2  christos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1.6.2  christos  * SUCH DAMAGE.
     27  1.1.6.2  christos  *
     28  1.1.6.2  christos  * from: NetBSD: netbsd32_netbsd.c,v 1.218 2018/08/10 21:44:58 pgoyette Exp
     29  1.1.6.2  christos  */
     30  1.1.6.2  christos 
     31  1.1.6.2  christos #include <sys/cdefs.h>
     32  1.1.6.3    martin __KERNEL_RCSID(0, "$NetBSD: netbsd32_quota.c,v 1.1.6.3 2020/04/13 08:04:16 martin Exp $");
     33  1.1.6.3    martin 
     34  1.1.6.3    martin #ifdef _KERNEL_OPT
     35  1.1.6.3    martin #include "opt_quota.h"
     36  1.1.6.3    martin #endif
     37  1.1.6.2  christos 
     38  1.1.6.2  christos #include <sys/param.h>
     39  1.1.6.2  christos #include <sys/systm.h>
     40  1.1.6.2  christos #include <sys/quotactl.h>
     41  1.1.6.3    martin #include <sys/module.h>
     42  1.1.6.2  christos #include <sys/vfs_syscalls.h>
     43  1.1.6.3    martin #include <sys/syscallvar.h>
     44  1.1.6.2  christos 
     45  1.1.6.2  christos #include <compat/netbsd32/netbsd32.h>
     46  1.1.6.2  christos #include <compat/netbsd32/netbsd32_syscall.h>
     47  1.1.6.2  christos #include <compat/netbsd32/netbsd32_syscallargs.h>
     48  1.1.6.2  christos 
     49  1.1.6.3    martin #ifdef QUOTA
     50  1.1.6.2  christos int
     51  1.1.6.2  christos netbsd32___quotactl(struct lwp *l, const struct netbsd32___quotactl_args *uap, register_t *retval)
     52  1.1.6.2  christos {
     53  1.1.6.2  christos 	/* {
     54  1.1.6.2  christos 		syscallarg(const netbsd32_charp) path;
     55  1.1.6.2  christos 		syscallarg(netbsd32_voidp) args;
     56  1.1.6.2  christos 	} */
     57  1.1.6.2  christos 	struct netbsd32_quotactlargs args32;
     58  1.1.6.2  christos 	struct quotactl_args args;
     59  1.1.6.2  christos 	int error;
     60  1.1.6.2  christos 
     61  1.1.6.2  christos 	error = copyin(SCARG_P32(uap, args), &args32, sizeof(args32));
     62  1.1.6.2  christos 	if (error) {
     63  1.1.6.2  christos 		return error;
     64  1.1.6.2  christos 	}
     65  1.1.6.2  christos 
     66  1.1.6.2  christos 	args.qc_op = args32.qc_op;
     67  1.1.6.2  christos 	switch (args.qc_op) {
     68  1.1.6.2  christos 	    case QUOTACTL_STAT:
     69  1.1.6.2  christos 		args.u.stat.qc_info = NETBSD32PTR64(args32.u.stat.qc_info);
     70  1.1.6.2  christos 		break;
     71  1.1.6.2  christos 	    case QUOTACTL_IDTYPESTAT:
     72  1.1.6.2  christos 		args.u.idtypestat.qc_idtype = args32.u.idtypestat.qc_idtype;
     73  1.1.6.2  christos 		args.u.idtypestat.qc_info =
     74  1.1.6.2  christos 			NETBSD32PTR64(args32.u.idtypestat.qc_info);
     75  1.1.6.2  christos 		break;
     76  1.1.6.2  christos 	    case QUOTACTL_OBJTYPESTAT:
     77  1.1.6.2  christos 		args.u.objtypestat.qc_objtype =
     78  1.1.6.2  christos 			args32.u.objtypestat.qc_objtype;
     79  1.1.6.2  christos 		args.u.objtypestat.qc_info =
     80  1.1.6.2  christos 			NETBSD32PTR64(args32.u.objtypestat.qc_info);
     81  1.1.6.2  christos 		break;
     82  1.1.6.2  christos 	    case QUOTACTL_GET:
     83  1.1.6.2  christos 		args.u.get.qc_key = NETBSD32PTR64(args32.u.get.qc_key);
     84  1.1.6.2  christos 		args.u.get.qc_val = NETBSD32PTR64(args32.u.get.qc_val);
     85  1.1.6.2  christos 		break;
     86  1.1.6.2  christos 	    case QUOTACTL_PUT:
     87  1.1.6.2  christos 		args.u.put.qc_key = NETBSD32PTR64(args32.u.put.qc_key);
     88  1.1.6.2  christos 		args.u.put.qc_val = NETBSD32PTR64(args32.u.put.qc_val);
     89  1.1.6.2  christos 		break;
     90  1.1.6.2  christos 	    case QUOTACTL_DEL:
     91  1.1.6.2  christos 		args.u.del.qc_key = NETBSD32PTR64(args32.u.del.qc_key);
     92  1.1.6.2  christos 		break;
     93  1.1.6.2  christos 	    case QUOTACTL_CURSOROPEN:
     94  1.1.6.2  christos 		args.u.cursoropen.qc_cursor =
     95  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursoropen.qc_cursor);
     96  1.1.6.2  christos 		break;
     97  1.1.6.2  christos 	    case QUOTACTL_CURSORCLOSE:
     98  1.1.6.2  christos 		args.u.cursorclose.qc_cursor =
     99  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorclose.qc_cursor);
    100  1.1.6.2  christos 		break;
    101  1.1.6.2  christos 	    case QUOTACTL_CURSORSKIPIDTYPE:
    102  1.1.6.2  christos 		args.u.cursorskipidtype.qc_cursor =
    103  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorskipidtype.qc_cursor);
    104  1.1.6.2  christos 		args.u.cursorskipidtype.qc_idtype =
    105  1.1.6.2  christos 			args32.u.cursorskipidtype.qc_idtype;
    106  1.1.6.2  christos 		break;
    107  1.1.6.2  christos 	    case QUOTACTL_CURSORGET:
    108  1.1.6.2  christos 		args.u.cursorget.qc_cursor =
    109  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorget.qc_cursor);
    110  1.1.6.2  christos 		args.u.cursorget.qc_keys =
    111  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorget.qc_keys);
    112  1.1.6.2  christos 		args.u.cursorget.qc_vals =
    113  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorget.qc_vals);
    114  1.1.6.2  christos 		args.u.cursorget.qc_maxnum =
    115  1.1.6.2  christos 			args32.u.cursorget.qc_maxnum;
    116  1.1.6.2  christos 		args.u.cursorget.qc_ret =
    117  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorget.qc_ret);
    118  1.1.6.2  christos 		break;
    119  1.1.6.2  christos 	    case QUOTACTL_CURSORATEND:
    120  1.1.6.2  christos 		args.u.cursoratend.qc_cursor =
    121  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursoratend.qc_cursor);
    122  1.1.6.2  christos 		args.u.cursoratend.qc_ret =
    123  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursoratend.qc_ret);
    124  1.1.6.2  christos 		break;
    125  1.1.6.2  christos 	    case QUOTACTL_CURSORREWIND:
    126  1.1.6.2  christos 		args.u.cursorrewind.qc_cursor =
    127  1.1.6.2  christos 			NETBSD32PTR64(args32.u.cursorrewind.qc_cursor);
    128  1.1.6.2  christos 		break;
    129  1.1.6.2  christos 	    case QUOTACTL_QUOTAON:
    130  1.1.6.2  christos 		args.u.quotaon.qc_idtype = args32.u.quotaon.qc_idtype;
    131  1.1.6.2  christos 		args.u.quotaon.qc_quotafile =
    132  1.1.6.2  christos 			NETBSD32PTR64(args32.u.quotaon.qc_quotafile);
    133  1.1.6.2  christos 		break;
    134  1.1.6.2  christos 	    case QUOTACTL_QUOTAOFF:
    135  1.1.6.2  christos 		args.u.quotaoff.qc_idtype = args32.u.quotaoff.qc_idtype;
    136  1.1.6.2  christos 		break;
    137  1.1.6.2  christos 	    default:
    138  1.1.6.2  christos 		return EINVAL;
    139  1.1.6.2  christos 	}
    140  1.1.6.2  christos 
    141  1.1.6.2  christos 	return do_sys_quotactl(SCARG_P32(uap, path), &args);
    142  1.1.6.2  christos }
    143  1.1.6.3    martin static struct syscall_package compat_netbsd32_quota_syscalls[] = {
    144  1.1.6.3    martin 	{ NETBSD32_SYS_netbsd32___quotactl, 0,
    145  1.1.6.3    martin 	    (sy_call_t *)netbsd32___quotactl },
    146  1.1.6.3    martin 	{ 0, 0, NULL }
    147  1.1.6.3    martin };
    148  1.1.6.3    martin 
    149  1.1.6.3    martin MODULE(MODULE_CLASS_EXEC, compat_netbsd32_quota, "compat_netbsd32");
    150  1.1.6.3    martin 
    151  1.1.6.3    martin static int
    152  1.1.6.3    martin compat_netbsd32_quota_modcmd(modcmd_t cmd, void *arg)
    153  1.1.6.3    martin {
    154  1.1.6.3    martin 	int ret;
    155  1.1.6.3    martin 
    156  1.1.6.3    martin 	switch (cmd) {
    157  1.1.6.3    martin 	case MODULE_CMD_INIT:
    158  1.1.6.3    martin 		ret = syscall_establish(&emul_netbsd32,
    159  1.1.6.3    martin 		    compat_netbsd32_quota_syscalls);
    160  1.1.6.3    martin 		return ret;
    161  1.1.6.3    martin 	case MODULE_CMD_FINI:
    162  1.1.6.3    martin 		ret = syscall_disestablish(&emul_netbsd32,
    163  1.1.6.3    martin 		    compat_netbsd32_quota_syscalls);
    164  1.1.6.3    martin 		return ret;
    165  1.1.6.3    martin 	default:
    166  1.1.6.3    martin 		return ENOTTY;
    167  1.1.6.3    martin 	}
    168  1.1.6.3    martin }
    169  1.1.6.3    martin #endif
    170