1 /* $NetBSD: netbsd32_compat_50_quota.c,v 1.2 2021/01/19 03:20:13 simonb Exp $ */ 2 3 /*- 4 * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Christos Zoulas. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 #include <sys/cdefs.h> 32 __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50_quota.c,v 1.2 2021/01/19 03:20:13 simonb Exp $"); 33 34 #if defined(_KERNEL_OPT) 35 #include "opt_compat_netbsd.h" 36 #include "opt_compat_netbsd32.h" 37 #include "opt_quota.h" 38 #endif 39 40 41 #include <sys/param.h> 42 #include <sys/systm.h> 43 #include <sys/module.h> 44 #include <sys/syscallargs.h> 45 #include <sys/syscallvar.h> 46 47 #include <compat/netbsd32/netbsd32.h> 48 #include <compat/netbsd32/netbsd32_syscall.h> 49 #include <compat/netbsd32/netbsd32_syscallargs.h> 50 51 #if defined(COMPAT_50) && defined(QUOTA) 52 53 int 54 compat_50_netbsd32_quotactl(struct lwp *l, const struct compat_50_netbsd32_quotactl_args *uap, register_t *retval) 55 { 56 /* { 57 syscallarg(const netbsd32_charp) path; 58 syscallarg(int) cmd; 59 syscallarg(int) uid; 60 syscallarg(netbsd32_voidp) arg; 61 } */ 62 struct compat_50_sys_quotactl_args ua; 63 64 NETBSD32TOP_UAP(path, const char); 65 NETBSD32TO64_UAP(cmd); 66 NETBSD32TO64_UAP(uid); 67 NETBSD32TOP_UAP(arg, void *); 68 return compat_50_sys_quotactl(l, &ua, retval); 69 } 70 71 static struct syscall_package compat_netbsd32_quota_50_syscalls[] = { 72 { NETBSD32_SYS_compat_50_netbsd32_quotactl, 0, 73 (sy_call_t *)compat_50_netbsd32_quotactl }, 74 { 0, 0, NULL } 75 }; 76 77 MODULE(MODULE_CLASS_EXEC, compat_netbsd32_quota_50, 78 "compat_netbsd32_50,compat_50,compat_50_quota"); 79 80 static int 81 compat_netbsd32_quota_50_modcmd(modcmd_t cmd, void *arg) 82 { 83 int ret; 84 85 switch (cmd) { 86 case MODULE_CMD_INIT: 87 ret = syscall_establish(&emul_netbsd32, 88 compat_netbsd32_quota_50_syscalls); 89 return ret; 90 91 case MODULE_CMD_FINI: 92 ret = syscall_disestablish(&emul_netbsd32, 93 compat_netbsd32_quota_50_syscalls); 94 return ret; 95 96 default: 97 return ENOTTY; 98 } 99 } 100 #endif /* COMPAT_50 && QUOTA */ 101