freebsd_misc.c revision 1.3.2.1 1 /* $NetBSD: freebsd_misc.c,v 1.3.2.1 1998/09/30 18:16:38 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1995 Frank van der Linden
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 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the NetBSD Project
18 * by Frank van der Linden
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * FreeBSD compatibility module. Try to deal with various FreeBSD system calls.
36 */
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/proc.h>
41 #include <sys/mount.h>
42
43 #include <sys/syscallargs.h>
44
45 #include <compat/freebsd/freebsd_syscallargs.h>
46 #include <compat/freebsd/freebsd_util.h>
47 #include <compat/freebsd/freebsd_rtprio.h>
48 #include <compat/freebsd/freebsd_timex.h>
49
50 int
51 freebsd_sys_msync(p, v, retval)
52 struct proc *p;
53 void *v;
54 register_t *retval;
55 {
56 struct freebsd_sys_msync_args /* {
57 syscallarg(caddr_t) addr;
58 syscallarg(size_t) len;
59 syscallarg(int) flags;
60 } */ *uap = v;
61 struct sys___msync13_args bma;
62
63 /*
64 * FreeBSD-2.0-RELEASE's msync(2) is compatible with NetBSD's.
65 * FreeBSD-2.0.5-RELEASE's msync(2) has addtional argument `flags',
66 * but syscall number is not changed. :-<
67 */
68 SCARG(&bma, addr) = SCARG(uap, addr);
69 SCARG(&bma, len) = SCARG(uap, len);
70 SCARG(&bma, flags) = SCARG(uap, flags);
71 return sys___msync13(p, &bma, retval);
72 }
73
74 /* just a place holder */
75
76 int
77 freebsd_sys_rtprio(p, v, retval)
78 struct proc *p;
79 void *v;
80 register_t *retval;
81 {
82 #ifdef notyet
83 struct freebsd_sys_rtprio_args /* {
84 syscallarg(int) function;
85 syscallarg(pid_t) pid;
86 syscallarg(struct freebsd_rtprio *) rtp;
87 } */ *uap = v;
88 #endif
89
90 return ENOSYS; /* XXX */
91 }
92
93 int
94 freebsd_ntp_adjtime(p, v, retval)
95 struct proc *p;
96 void *v;
97 register_t *retval;
98 {
99 #ifdef notyet
100 struct freebsd_ntp_adjtime_args /* {
101 syscallarg(struct freebsd_timex *) tp;
102 } */ *uap = v;
103 #endif
104
105 return ENOSYS; /* XXX */
106 }
107
108 int
109 freebsd_sys_issetugid(p, v, retval)
110 struct proc *p;
111 void *v;
112 register_t *retval;
113 {
114 /*
115 * Note: OpenBSD sets a P_SUGIDEXEC flag set at execve() time,
116 * we use P_SUGID because we consider changing the owners as
117 * "tainting" as well.
118 * This is significant for procs that start as root and "become"
119 * a user without an exec - programs cannot know *everything*
120 * that libc *might* have put in their data segment.
121 */
122 *retval = (p->p_flag & P_SUGID) != 0;
123 return 0;
124 }
125