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