1 1.3 pgoyette /* $NetBSD: netbsd32_quota.c,v 1.3 2020/03/12 15:02:29 pgoyette 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.3 pgoyette __KERNEL_RCSID(0, "$NetBSD: netbsd32_quota.c,v 1.3 2020/03/12 15:02:29 pgoyette Exp $"); 33 1.2 christos 34 1.2 christos #ifdef _KERNEL_OPT 35 1.2 christos #include "opt_quota.h" 36 1.2 christos #endif 37 1.1 mrg 38 1.1 mrg #include <sys/param.h> 39 1.1 mrg #include <sys/systm.h> 40 1.1 mrg #include <sys/quotactl.h> 41 1.3 pgoyette #include <sys/module.h> 42 1.1 mrg #include <sys/vfs_syscalls.h> 43 1.3 pgoyette #include <sys/syscallvar.h> 44 1.1 mrg 45 1.1 mrg #include <compat/netbsd32/netbsd32.h> 46 1.1 mrg #include <compat/netbsd32/netbsd32_syscall.h> 47 1.1 mrg #include <compat/netbsd32/netbsd32_syscallargs.h> 48 1.1 mrg 49 1.2 christos #ifdef QUOTA 50 1.1 mrg int 51 1.1 mrg netbsd32___quotactl(struct lwp *l, const struct netbsd32___quotactl_args *uap, register_t *retval) 52 1.1 mrg { 53 1.1 mrg /* { 54 1.1 mrg syscallarg(const netbsd32_charp) path; 55 1.1 mrg syscallarg(netbsd32_voidp) args; 56 1.1 mrg } */ 57 1.1 mrg struct netbsd32_quotactlargs args32; 58 1.1 mrg struct quotactl_args args; 59 1.1 mrg int error; 60 1.1 mrg 61 1.1 mrg error = copyin(SCARG_P32(uap, args), &args32, sizeof(args32)); 62 1.1 mrg if (error) { 63 1.1 mrg return error; 64 1.1 mrg } 65 1.1 mrg 66 1.1 mrg args.qc_op = args32.qc_op; 67 1.1 mrg switch (args.qc_op) { 68 1.1 mrg case QUOTACTL_STAT: 69 1.1 mrg args.u.stat.qc_info = NETBSD32PTR64(args32.u.stat.qc_info); 70 1.1 mrg break; 71 1.1 mrg case QUOTACTL_IDTYPESTAT: 72 1.1 mrg args.u.idtypestat.qc_idtype = args32.u.idtypestat.qc_idtype; 73 1.1 mrg args.u.idtypestat.qc_info = 74 1.1 mrg NETBSD32PTR64(args32.u.idtypestat.qc_info); 75 1.1 mrg break; 76 1.1 mrg case QUOTACTL_OBJTYPESTAT: 77 1.1 mrg args.u.objtypestat.qc_objtype = 78 1.1 mrg args32.u.objtypestat.qc_objtype; 79 1.1 mrg args.u.objtypestat.qc_info = 80 1.1 mrg NETBSD32PTR64(args32.u.objtypestat.qc_info); 81 1.1 mrg break; 82 1.1 mrg case QUOTACTL_GET: 83 1.1 mrg args.u.get.qc_key = NETBSD32PTR64(args32.u.get.qc_key); 84 1.1 mrg args.u.get.qc_val = NETBSD32PTR64(args32.u.get.qc_val); 85 1.1 mrg break; 86 1.1 mrg case QUOTACTL_PUT: 87 1.1 mrg args.u.put.qc_key = NETBSD32PTR64(args32.u.put.qc_key); 88 1.1 mrg args.u.put.qc_val = NETBSD32PTR64(args32.u.put.qc_val); 89 1.1 mrg break; 90 1.1 mrg case QUOTACTL_DEL: 91 1.1 mrg args.u.del.qc_key = NETBSD32PTR64(args32.u.del.qc_key); 92 1.1 mrg break; 93 1.1 mrg case QUOTACTL_CURSOROPEN: 94 1.1 mrg args.u.cursoropen.qc_cursor = 95 1.1 mrg NETBSD32PTR64(args32.u.cursoropen.qc_cursor); 96 1.1 mrg break; 97 1.1 mrg case QUOTACTL_CURSORCLOSE: 98 1.1 mrg args.u.cursorclose.qc_cursor = 99 1.1 mrg NETBSD32PTR64(args32.u.cursorclose.qc_cursor); 100 1.1 mrg break; 101 1.1 mrg case QUOTACTL_CURSORSKIPIDTYPE: 102 1.1 mrg args.u.cursorskipidtype.qc_cursor = 103 1.1 mrg NETBSD32PTR64(args32.u.cursorskipidtype.qc_cursor); 104 1.1 mrg args.u.cursorskipidtype.qc_idtype = 105 1.1 mrg args32.u.cursorskipidtype.qc_idtype; 106 1.1 mrg break; 107 1.1 mrg case QUOTACTL_CURSORGET: 108 1.1 mrg args.u.cursorget.qc_cursor = 109 1.1 mrg NETBSD32PTR64(args32.u.cursorget.qc_cursor); 110 1.1 mrg args.u.cursorget.qc_keys = 111 1.1 mrg NETBSD32PTR64(args32.u.cursorget.qc_keys); 112 1.1 mrg args.u.cursorget.qc_vals = 113 1.1 mrg NETBSD32PTR64(args32.u.cursorget.qc_vals); 114 1.1 mrg args.u.cursorget.qc_maxnum = 115 1.1 mrg args32.u.cursorget.qc_maxnum; 116 1.1 mrg args.u.cursorget.qc_ret = 117 1.1 mrg NETBSD32PTR64(args32.u.cursorget.qc_ret); 118 1.1 mrg break; 119 1.1 mrg case QUOTACTL_CURSORATEND: 120 1.1 mrg args.u.cursoratend.qc_cursor = 121 1.1 mrg NETBSD32PTR64(args32.u.cursoratend.qc_cursor); 122 1.1 mrg args.u.cursoratend.qc_ret = 123 1.1 mrg NETBSD32PTR64(args32.u.cursoratend.qc_ret); 124 1.1 mrg break; 125 1.1 mrg case QUOTACTL_CURSORREWIND: 126 1.1 mrg args.u.cursorrewind.qc_cursor = 127 1.1 mrg NETBSD32PTR64(args32.u.cursorrewind.qc_cursor); 128 1.1 mrg break; 129 1.1 mrg case QUOTACTL_QUOTAON: 130 1.1 mrg args.u.quotaon.qc_idtype = args32.u.quotaon.qc_idtype; 131 1.1 mrg args.u.quotaon.qc_quotafile = 132 1.1 mrg NETBSD32PTR64(args32.u.quotaon.qc_quotafile); 133 1.1 mrg break; 134 1.1 mrg case QUOTACTL_QUOTAOFF: 135 1.1 mrg args.u.quotaoff.qc_idtype = args32.u.quotaoff.qc_idtype; 136 1.1 mrg break; 137 1.1 mrg default: 138 1.1 mrg return EINVAL; 139 1.1 mrg } 140 1.1 mrg 141 1.1 mrg return do_sys_quotactl(SCARG_P32(uap, path), &args); 142 1.1 mrg } 143 1.3 pgoyette static struct syscall_package compat_netbsd32_quota_syscalls[] = { 144 1.3 pgoyette { NETBSD32_SYS_netbsd32___quotactl, 0, 145 1.3 pgoyette (sy_call_t *)netbsd32___quotactl }, 146 1.3 pgoyette { 0, 0, NULL } 147 1.3 pgoyette }; 148 1.3 pgoyette 149 1.3 pgoyette MODULE(MODULE_CLASS_EXEC, compat_netbsd32_quota, "compat_netbsd32"); 150 1.3 pgoyette 151 1.3 pgoyette static int 152 1.3 pgoyette compat_netbsd32_quota_modcmd(modcmd_t cmd, void *arg) 153 1.3 pgoyette { 154 1.3 pgoyette int ret; 155 1.3 pgoyette 156 1.3 pgoyette switch (cmd) { 157 1.3 pgoyette case MODULE_CMD_INIT: 158 1.3 pgoyette ret = syscall_establish(&emul_netbsd32, 159 1.3 pgoyette compat_netbsd32_quota_syscalls); 160 1.3 pgoyette return ret; 161 1.3 pgoyette case MODULE_CMD_FINI: 162 1.3 pgoyette ret = syscall_disestablish(&emul_netbsd32, 163 1.3 pgoyette compat_netbsd32_quota_syscalls); 164 1.3 pgoyette return ret; 165 1.3 pgoyette default: 166 1.3 pgoyette return ENOTTY; 167 1.3 pgoyette } 168 1.3 pgoyette } 169 1.2 christos #endif 170