4 * $Id: osi_misc.c,v 1.4 2003/10/09 16:13:16 rees Exp $
9 the regents of the university of michigan
12 permission is granted to use, copy, create derivative works
13 and redistribute this software and such derivative works
14 for any purpose, so long as the name of the university of
15 michigan is not used in any advertising or publicity
16 pertaining to the use or distribution of this software
17 without specific, written prior authorization. if the
18 above copyright notice or any other identification of the
19 university of michigan is included in any copy of any
20 portion of this software, then the disclaimer below must
23 this software is provided as is, without representation
24 from the university of michigan as to its fitness for any
25 purpose, and without warranty by the university of
26 michigan of any kind, either express or implied, including
27 without limitation the implied warranties of
28 merchantability and fitness for a particular purpose. the
29 regents of the university of michigan shall not be liable
30 for any damages, including special, indirect, incidental, or
31 consequential damages, with respect to any claim arising
32 out of or in connection with the use of the software, even
33 if it has been or is hereafter advised of the possibility of
38 * Copyright 2000, International Business Machines Corporation and others.
39 * All Rights Reserved.
41 * This software has been released under the terms of the IBM Public
42 * License. For details, see the LICENSE file in the top-level source
43 * directory or online at http://www.openafs.org/dl/license10.html
46 #include <afsconfig.h>
47 #include "afs/param.h"
51 #include "afs/sysincludes.h" /* Standard vendor system headers */
52 #include "afs/afsincludes.h" /* Afs-based standard headers */
55 * afs_suser() returns true if the caller is superuser, false otherwise.
57 * Note that it must NOT set errno.
61 * Modern NetBSD version of afs_osi_suser(). For cognate code calling
62 * traditional BSD suser, see OBSD/osi_misc.c.
65 afs_osi_suser(void *credp)
68 code = kauth_authorize_generic(credp,
69 KAUTH_GENERIC_ISSUSER,
75 * Support Alloc_NoSleep. This should propagate back to OBSD.
79 osi_nbsd_Alloc(size_t asize, int cansleep)
85 glocked = ISAFS_GLOCK();
88 MALLOC(p, void *, asize, M_AFSGENERIC, M_WAITOK);
92 MALLOC(p, void *, asize, M_AFSGENERIC, M_NOWAIT);
99 osi_nbsd_Free(void *p, size_t asize)
101 FREE(p, M_AFSGENERIC);
105 afs_osi_Alloc(size_t asize) {
106 return (osi_nbsd_Alloc(asize, 1));
110 afs_osi_Alloc_NoSleep(size_t asize) {
111 return (osi_nbsd_Alloc(asize, 0));
115 afs_osi_Free(void *buf, size_t asize) {
116 osi_nbsd_Free(buf, asize);
120 afs_osi_FreeStr(char *x)
122 afs_osi_Free(x, strlen(x) + 1);
125 /* XXXX OpenBSD avoids space pool, presumably Rees believed the kernel
126 * allocator did as well or better */
129 osi_FreeLargeSpace(void *p)
134 /* XXXX OpenBSD avoids space pool, presumably Rees believed the kernel
135 * allocator did as well or better */
138 osi_FreeSmallSpace(void *p)
144 osi_AllocLargeSpace(size_t size)
147 AFS_STATCNT(osi_AllocLargeSpace);
148 return (osi_nbsd_Alloc(size, 1));
152 osi_AllocSmallSpace(size_t size)
155 AFS_STATCNT(osi_AllocSmallSpace);
156 return (osi_nbsd_Alloc(size, 1));
159 #endif /* Space undef */
162 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
164 long dev, near_inode, param1, param2, param3, param4;
169 #endif /* Space undef */
172 afs_syscall_iopen(dev, inode, usrmod, retval)
174 int dev, inode, usrmod;
180 afs_syscall_iincdec(dev, inode, inode_p1, amount)
181 int dev, inode, inode_p1, amount;
187 osi_crgroupbyid(afs_ucred_t *acred, int gindex)
189 struct kauth_cred *cr = acred;
190 return (cr->cr_groups[gindex]);
194 * just calls kern_time.c:settime()
197 afs_osi_SetTime(osi_timeval_t *atv)
200 printf("afs attempted to set clock; use \"afsd -nosettime\"\n");
204 ts.tv_sec = atv->tv_sec;
205 ts.tv_nsec = atv->tv_usec * 1000;
206 settime(osi_curproc()->l_proc, &ts); /* really takes a process */