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