1*650cb29cSsimonb /* $NetBSD: netbsd32_compat_50_quota.c,v 1.2 2021/01/19 03:20:13 simonb Exp $ */
24b5fc12dSpgoyette
34b5fc12dSpgoyette /*-
44b5fc12dSpgoyette * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
54b5fc12dSpgoyette * All rights reserved.
64b5fc12dSpgoyette *
74b5fc12dSpgoyette * This code is derived from software contributed to The NetBSD Foundation
84b5fc12dSpgoyette * by Christos Zoulas.
94b5fc12dSpgoyette *
104b5fc12dSpgoyette * Redistribution and use in source and binary forms, with or without
114b5fc12dSpgoyette * modification, are permitted provided that the following conditions
124b5fc12dSpgoyette * are met:
134b5fc12dSpgoyette * 1. Redistributions of source code must retain the above copyright
144b5fc12dSpgoyette * notice, this list of conditions and the following disclaimer.
154b5fc12dSpgoyette * 2. Redistributions in binary form must reproduce the above copyright
164b5fc12dSpgoyette * notice, this list of conditions and the following disclaimer in the
174b5fc12dSpgoyette * documentation and/or other materials provided with the distribution.
184b5fc12dSpgoyette *
194b5fc12dSpgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
204b5fc12dSpgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
214b5fc12dSpgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
224b5fc12dSpgoyette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
234b5fc12dSpgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
244b5fc12dSpgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
254b5fc12dSpgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
264b5fc12dSpgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
274b5fc12dSpgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
284b5fc12dSpgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
294b5fc12dSpgoyette * POSSIBILITY OF SUCH DAMAGE.
304b5fc12dSpgoyette */
314b5fc12dSpgoyette #include <sys/cdefs.h>
32*650cb29cSsimonb __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50_quota.c,v 1.2 2021/01/19 03:20:13 simonb Exp $");
334b5fc12dSpgoyette
344b5fc12dSpgoyette #if defined(_KERNEL_OPT)
354b5fc12dSpgoyette #include "opt_compat_netbsd.h"
364b5fc12dSpgoyette #include "opt_compat_netbsd32.h"
374b5fc12dSpgoyette #include "opt_quota.h"
384b5fc12dSpgoyette #endif
394b5fc12dSpgoyette
404b5fc12dSpgoyette
414b5fc12dSpgoyette #include <sys/param.h>
424b5fc12dSpgoyette #include <sys/systm.h>
434b5fc12dSpgoyette #include <sys/module.h>
444b5fc12dSpgoyette #include <sys/syscallargs.h>
454b5fc12dSpgoyette #include <sys/syscallvar.h>
464b5fc12dSpgoyette
474b5fc12dSpgoyette #include <compat/netbsd32/netbsd32.h>
484b5fc12dSpgoyette #include <compat/netbsd32/netbsd32_syscall.h>
494b5fc12dSpgoyette #include <compat/netbsd32/netbsd32_syscallargs.h>
504b5fc12dSpgoyette
514b5fc12dSpgoyette #if defined(COMPAT_50) && defined(QUOTA)
524b5fc12dSpgoyette
534b5fc12dSpgoyette int
compat_50_netbsd32_quotactl(struct lwp * l,const struct compat_50_netbsd32_quotactl_args * uap,register_t * retval)544b5fc12dSpgoyette compat_50_netbsd32_quotactl(struct lwp *l, const struct compat_50_netbsd32_quotactl_args *uap, register_t *retval)
554b5fc12dSpgoyette {
564b5fc12dSpgoyette /* {
574b5fc12dSpgoyette syscallarg(const netbsd32_charp) path;
584b5fc12dSpgoyette syscallarg(int) cmd;
594b5fc12dSpgoyette syscallarg(int) uid;
604b5fc12dSpgoyette syscallarg(netbsd32_voidp) arg;
614b5fc12dSpgoyette } */
624b5fc12dSpgoyette struct compat_50_sys_quotactl_args ua;
634b5fc12dSpgoyette
644b5fc12dSpgoyette NETBSD32TOP_UAP(path, const char);
654b5fc12dSpgoyette NETBSD32TO64_UAP(cmd);
664b5fc12dSpgoyette NETBSD32TO64_UAP(uid);
674b5fc12dSpgoyette NETBSD32TOP_UAP(arg, void *);
68*650cb29cSsimonb return compat_50_sys_quotactl(l, &ua, retval);
694b5fc12dSpgoyette }
704b5fc12dSpgoyette
714b5fc12dSpgoyette static struct syscall_package compat_netbsd32_quota_50_syscalls[] = {
724b5fc12dSpgoyette { NETBSD32_SYS_compat_50_netbsd32_quotactl, 0,
734b5fc12dSpgoyette (sy_call_t *)compat_50_netbsd32_quotactl },
744b5fc12dSpgoyette { 0, 0, NULL }
754b5fc12dSpgoyette };
764b5fc12dSpgoyette
774b5fc12dSpgoyette MODULE(MODULE_CLASS_EXEC, compat_netbsd32_quota_50,
784b5fc12dSpgoyette "compat_netbsd32_50,compat_50,compat_50_quota");
794b5fc12dSpgoyette
804b5fc12dSpgoyette static int
compat_netbsd32_quota_50_modcmd(modcmd_t cmd,void * arg)814b5fc12dSpgoyette compat_netbsd32_quota_50_modcmd(modcmd_t cmd, void *arg)
824b5fc12dSpgoyette {
834b5fc12dSpgoyette int ret;
844b5fc12dSpgoyette
854b5fc12dSpgoyette switch (cmd) {
864b5fc12dSpgoyette case MODULE_CMD_INIT:
874b5fc12dSpgoyette ret = syscall_establish(&emul_netbsd32,
884b5fc12dSpgoyette compat_netbsd32_quota_50_syscalls);
894b5fc12dSpgoyette return ret;
904b5fc12dSpgoyette
914b5fc12dSpgoyette case MODULE_CMD_FINI:
924b5fc12dSpgoyette ret = syscall_disestablish(&emul_netbsd32,
934b5fc12dSpgoyette compat_netbsd32_quota_50_syscalls);
944b5fc12dSpgoyette return ret;
954b5fc12dSpgoyette
964b5fc12dSpgoyette default:
974b5fc12dSpgoyette return ENOTTY;
984b5fc12dSpgoyette }
994b5fc12dSpgoyette }
1004b5fc12dSpgoyette #endif /* COMPAT_50 && QUOTA */
101