Sync usage with man page.
[netbsd-mini2440.git] / sys / compat / osf1 / osf1_cvt.c
blob6bdd49b3df056d088296355d1aa050d702535f50
1 /* $NetBSD: osf1_cvt.c,v 1.25 2007/12/08 18:36:20 dsl Exp $ */
3 /*
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
35 * All rights reserved.
37 * Author: Chris G. Demetriou
39 * Permission to use, copy, modify and distribute this software and
40 * its documentation is hereby granted, provided that both the copyright
41 * notice and this permission notice appear in all copies of the
42 * software, derivative works or modified versions, and any portions
43 * thereof, and that both notices appear in supporting documentation.
45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
47 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49 * Carnegie Mellon requests users of this software to return to
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science
53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890
56 * any improvements or extensions that they make and grant Carnegie the
57 * rights to redistribute these changes.
60 #include <sys/cdefs.h>
61 __KERNEL_RCSID(0, "$NetBSD: osf1_cvt.c,v 1.25 2007/12/08 18:36:20 dsl Exp $");
63 #include <sys/param.h>
64 #include <sys/systm.h>
65 #include <sys/namei.h>
66 #include <sys/proc.h>
67 #include <sys/file.h>
68 #include <sys/stat.h>
69 #include <sys/filedesc.h>
70 #include <sys/kernel.h>
71 #include <sys/malloc.h>
72 #include <sys/mman.h>
73 #include <sys/mount.h>
74 #include <sys/signal.h>
75 #include <sys/signalvar.h>
76 #include <sys/reboot.h>
77 #include <sys/syscallargs.h>
78 #include <sys/exec.h>
79 #include <sys/vnode.h>
80 #include <sys/socket.h>
81 #include <sys/socketvar.h>
82 #include <sys/resource.h>
83 #include <sys/resourcevar.h>
84 #include <sys/wait.h>
85 #include <uvm/uvm.h> /* XXX see mmap emulation */
87 #include <nfs/rpcv2.h>
88 #include <nfs/nfsproto.h>
89 #include <nfs/nfs.h>
90 #include <nfs/nfsmount.h>
92 #include <compat/osf1/osf1.h>
93 #include <compat/common/compat_util.h>
94 #include <compat/osf1/osf1_cvt.h>
96 const struct emul_flags_xtab osf1_access_flags_xtab[] = {
97 #if 0 /* pseudo-flag */
98 { OSF1_F_OK, OSF1_F_OK, F_OK },
99 #endif
100 { OSF1_X_OK, OSF1_X_OK, X_OK },
101 { OSF1_W_OK, OSF1_W_OK, W_OK },
102 { OSF1_R_OK, OSF1_R_OK, R_OK },
103 { 0 }
106 const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_rxtab[] = {
107 { FD_CLOEXEC, FD_CLOEXEC, OSF1_FD_CLOEXEC },
108 { 0 }
111 const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_xtab[] = {
112 { OSF1_FD_CLOEXEC, OSF1_FD_CLOEXEC, FD_CLOEXEC },
113 { 0 }
116 /* flags specific to GETFL/SETFL; also uses open rxtab */
117 const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_rxtab[] = {
118 { FASYNC, FASYNC, OSF1_FASYNC },
119 { 0 }
122 /* flags specific to GETFL/SETFL; also uses open xtab */
123 const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_xtab[] = {
124 { OSF1_FASYNC, OSF1_FASYNC, FASYNC },
125 { 0 }
128 const struct emul_flags_xtab osf1_mmap_flags_xtab[] = {
129 { OSF1_MAP_SHARED, OSF1_MAP_SHARED, MAP_SHARED },
130 { OSF1_MAP_PRIVATE, OSF1_MAP_PRIVATE, MAP_PRIVATE },
131 { OSF1_MAP_TYPE, OSF1_MAP_FILE, MAP_FILE },
132 { OSF1_MAP_TYPE, OSF1_MAP_ANON, MAP_ANON },
133 { OSF1_MAP_FIXED, OSF1_MAP_FIXED, MAP_FIXED },
134 #if 0 /* pseudo-flag, and the default */
135 { OSF1_MAP_VARIABLE, OSF1_MAP_VARIABLE, 0 },
136 #endif
137 { OSF1_MAP_HASSEMAPHORE, OSF1_MAP_HASSEMAPHORE, MAP_HASSEMAPHORE },
138 { OSF1_MAP_INHERIT, OSF1_MAP_INHERIT, MAP_INHERIT },
139 #if 0 /* no equivalent +++ */
140 { OSF1_MAP_UNALIGNED, OSF1_MAP_UNALIGNED, ??? },
141 #endif
142 { 0 }
145 const struct emul_flags_xtab osf1_mmap_prot_xtab[] = {
146 #if 0 /* pseudo-flag */
147 { OSF1_PROT_NONE, OSF1_PROT_NONE, PROT_NONE },
148 #endif
149 { OSF1_PROT_READ, OSF1_PROT_READ, PROT_READ },
150 { OSF1_PROT_WRITE, OSF1_PROT_WRITE, PROT_READ|PROT_WRITE },
151 { OSF1_PROT_EXEC, OSF1_PROT_EXEC, PROT_READ|PROT_EXEC },
152 { 0 }
155 const struct emul_flags_xtab osf1_nfs_mount_flags_xtab[] = {
156 { OSF1_NFSMNT_SOFT, OSF1_NFSMNT_SOFT, NFSMNT_SOFT, },
157 { OSF1_NFSMNT_WSIZE, OSF1_NFSMNT_WSIZE, NFSMNT_WSIZE, },
158 { OSF1_NFSMNT_RSIZE, OSF1_NFSMNT_RSIZE, NFSMNT_RSIZE, },
159 { OSF1_NFSMNT_TIMEO, OSF1_NFSMNT_TIMEO, NFSMNT_TIMEO, },
160 { OSF1_NFSMNT_RETRANS, OSF1_NFSMNT_RETRANS, NFSMNT_RETRANS, },
161 #if 0 /* no equivalent; needs special handling, see below */
162 { OSF1_NFSMNT_HOSTNAME, OSF1_NFSMNT_HOSTNAME, ???, },
163 #endif
164 { OSF1_NFSMNT_INT, OSF1_NFSMNT_INT, NFSMNT_INT, },
165 { OSF1_NFSMNT_NOCONN, OSF1_NFSMNT_NOCONN, NFSMNT_NOCONN, },
166 #if 0 /* no equivalents */
167 { OSF1_NFSMNT_NOAC, OSF1_NFSMNT_NOAC, ???, },
168 { OSF1_NFSMNT_ACREGMIN, OSF1_NFSMNT_ACREGMIN, ???, },
169 { OSF1_NFSMNT_ACREGMAX, OSF1_NFSMNT_ACREGMAX, ???, },
170 { OSF1_NFSMNT_ACDIRMIN, OSF1_NFSMNT_ACDIRMIN, ???, },
171 { OSF1_NFSMNT_ACDIRMAX, OSF1_NFSMNT_ACDIRMAX, ???, },
172 { OSF1_NFSMNT_NOCTO, OSF1_NFSMNT_NOCTO, ???, },
173 { OSF1_NFSMNT_POSIX, OSF1_NFSMNT_POSIX, ???, },
174 { OSF1_NFSMNT_AUTO, OSF1_NFSMNT_AUTO, ???, },
175 { OSF1_NFSMNT_SEC, OSF1_NFSMNT_SEC, ???, },
176 { OSF1_NFSMNT_TCP, OSF1_NFSMNT_TCP, ???, },
177 { OSF1_NFSMNT_PROPLIST, OSF1_NFSMNT_PROPLIST, ???, },
178 #endif
179 { 0 }
182 const struct emul_flags_xtab osf1_open_flags_rxtab[] = {
183 { O_ACCMODE, O_RDONLY, OSF1_O_RDONLY },
184 { O_ACCMODE, O_WRONLY, OSF1_O_WRONLY },
185 { O_ACCMODE, O_RDWR, OSF1_O_RDWR },
186 { O_NONBLOCK, O_NONBLOCK, OSF1_O_NONBLOCK },
187 { O_APPEND, O_APPEND, OSF1_O_APPEND },
188 #if 0 /* no equivalent +++ */
189 { ???, ???, O_DEFER },
190 #endif
191 { O_CREAT, O_CREAT, OSF1_O_CREAT },
192 { O_TRUNC, O_TRUNC, OSF1_O_TRUNC },
193 { O_EXCL, O_EXCL, OSF1_O_EXCL },
194 { O_NOCTTY, O_NOCTTY, OSF1_O_NOCTTY },
195 { O_SYNC, O_SYNC, OSF1_O_SYNC },
196 { O_NDELAY, O_NDELAY, OSF1_O_NDELAY },
197 #if 0 /* no equivalent, also same value as O_NDELAY! */
198 { ???, ???, O_DRD },
199 #endif
200 { O_DSYNC, O_DSYNC, OSF1_O_DSYNC },
201 { O_RSYNC, O_RSYNC, OSF1_O_RSYNC },
202 { 0 }
205 const struct emul_flags_xtab osf1_open_flags_xtab[] = {
206 { OSF1_O_ACCMODE, OSF1_O_RDONLY, O_RDONLY },
207 { OSF1_O_ACCMODE, OSF1_O_WRONLY, O_WRONLY },
208 { OSF1_O_ACCMODE, OSF1_O_RDWR, O_RDWR },
209 { OSF1_O_NONBLOCK, OSF1_O_NONBLOCK, O_NONBLOCK },
210 { OSF1_O_APPEND, OSF1_O_APPEND, O_APPEND },
211 #if 0 /* no equivalent +++ */
212 { OSF1_O_DEFER, OSF1_O_DEFER, ??? },
213 #endif
214 { OSF1_O_CREAT, OSF1_O_CREAT, O_CREAT },
215 { OSF1_O_TRUNC, OSF1_O_TRUNC, O_TRUNC },
216 { OSF1_O_EXCL, OSF1_O_EXCL, O_EXCL },
217 { OSF1_O_NOCTTY, OSF1_O_NOCTTY, O_NOCTTY },
218 { OSF1_O_SYNC, OSF1_O_SYNC, O_SYNC },
219 { OSF1_O_NDELAY, OSF1_O_NDELAY, O_NDELAY },
220 #if 0 /* no equivalent, also same value as O_NDELAY! */
221 { OSF1_O_DRD, OSF1_O_DRD, ??? },
222 #endif
223 { OSF1_O_DSYNC, OSF1_O_DSYNC, O_DSYNC },
224 { OSF1_O_RSYNC, OSF1_O_RSYNC, O_RSYNC },
225 { 0 }
228 const struct emul_flags_xtab osf1_reboot_opt_xtab[] = {
229 #if 0 /* pseudo-flag */
230 { OSF1_RB_AUTOBOOT, OSF1_RB_AUTOBOOT, RB_AUTOBOOT },
231 #endif
232 { OSF1_RB_ASKNAME, OSF1_RB_ASKNAME, RB_ASKNAME },
233 { OSF1_RB_SINGLE, OSF1_RB_SINGLE, RB_SINGLE },
234 { OSF1_RB_NOSYNC, OSF1_RB_NOSYNC, RB_NOSYNC },
235 #if 0 /* same value as O_NDELAY, only used at boot time? */
236 { OSF1_RB_KDB, OSF1_RB_KDB, RB_KDB },
237 #endif
238 { OSF1_RB_HALT, OSF1_RB_HALT, RB_HALT },
239 { OSF1_RB_INITNAME, OSF1_RB_INITNAME, RB_INITNAME },
240 #if 0 /* no equivalents +++ */
241 { OSF1_RB_DFLTROOT, OSF1_RB_DFLTROOT, ??? },
242 { OSF1_RB_ALTBOOT, OSF1_RB_ALTBOOT, ??? },
243 { OSF1_RB_UNIPROC, OSF1_RB_UNIPROC, ??? },
244 { OSF1_RB_PARAM, OSF1_RB_PARAM, ??? },
245 #endif
246 { OSF1_RB_DUMP, OSF1_RB_DUMP, RB_DUMP },
247 { 0 }
250 const struct emul_flags_xtab osf1_sendrecv_msg_flags_xtab[] = {
251 { OSF1_MSG_OOB, OSF1_MSG_OOB, MSG_OOB },
252 { OSF1_MSG_PEEK, OSF1_MSG_PEEK, MSG_PEEK },
253 { OSF1_MSG_DONTROUTE, OSF1_MSG_DONTROUTE, MSG_DONTROUTE },
254 { OSF1_MSG_EOR, OSF1_MSG_EOR, MSG_EOR },
255 { OSF1_MSG_TRUNC, OSF1_MSG_TRUNC, MSG_TRUNC },
256 { OSF1_MSG_CTRUNC, OSF1_MSG_CTRUNC, MSG_CTRUNC },
257 { OSF1_MSG_WAITALL, OSF1_MSG_WAITALL, MSG_WAITALL },
258 { 0 }
261 const struct emul_flags_xtab osf1_sigaction_flags_rxtab[] = {
262 { SA_ONSTACK, SA_ONSTACK, OSF1_SA_ONSTACK },
263 { SA_RESTART, SA_RESTART, OSF1_SA_RESTART },
264 { SA_NOCLDSTOP, SA_NOCLDSTOP, OSF1_SA_NOCLDSTOP },
265 { SA_NODEFER, SA_NODEFER, OSF1_SA_NODEFER },
266 { SA_RESETHAND, SA_RESETHAND, OSF1_SA_RESETHAND },
267 { SA_NOCLDWAIT, SA_NOCLDWAIT, OSF1_SA_NOCLDWAIT },
268 #if 0 /* XXX not yet */
269 { SA_SIGINFO, SA_SIGINFO, OSF1_SA_SIGINFO },
270 #endif
271 { 0 },
274 const struct emul_flags_xtab osf1_sigaction_flags_xtab[] = {
275 { OSF1_SA_ONSTACK, OSF1_SA_ONSTACK, SA_ONSTACK },
276 { OSF1_SA_RESTART, OSF1_SA_RESTART, SA_RESTART },
277 { OSF1_SA_NOCLDSTOP, OSF1_SA_NOCLDSTOP, SA_NOCLDSTOP },
278 { OSF1_SA_NODEFER, OSF1_SA_NODEFER, SA_NODEFER },
279 { OSF1_SA_RESETHAND, OSF1_SA_RESETHAND, SA_RESETHAND },
280 { OSF1_SA_NOCLDWAIT, OSF1_SA_NOCLDWAIT, SA_NOCLDWAIT },
281 #if 0 /* XXX not yet */
282 { OSF1_SA_SIGINFO, OSF1_SA_SIGINFO, SA_SIGINFO },
283 #endif
284 { 0 },
287 const struct emul_flags_xtab osf1_wait_options_xtab[] = {
288 { OSF1_WNOHANG, OSF1_WNOHANG, WNOHANG },
289 { OSF1_WUNTRACED, OSF1_WUNTRACED, WUNTRACED },
290 { 0 }
293 void
294 osf1_cvt_flock_from_native(const struct flock *nf, struct osf1_flock *of)
297 memset(of, 0, sizeof of);
299 of->l_start = nf->l_start;
300 of->l_len = nf->l_len;
301 of->l_pid = nf->l_pid;
303 switch (nf->l_type) {
304 case F_RDLCK:
305 of->l_type = OSF1_F_RDLCK;
306 break;
308 case F_WRLCK:
309 of->l_type = OSF1_F_WRLCK;
310 break;
312 case F_UNLCK:
313 of->l_type = OSF1_F_UNLCK;
314 break;
317 switch (nf->l_whence) {
318 case SEEK_SET:
319 of->l_whence = OSF1_SEEK_SET;
320 break;
322 case SEEK_CUR:
323 of->l_whence = OSF1_SEEK_CUR;
324 break;
326 case SEEK_END:
327 of->l_whence = OSF1_SEEK_END;
328 break;
333 osf1_cvt_flock_to_native(const struct osf1_flock *of, struct flock *nf)
336 memset(nf, 0, sizeof nf);
338 nf->l_start = of->l_start;
339 nf->l_len = of->l_len;
340 nf->l_pid = of->l_pid;
342 switch (of->l_type) {
343 case OSF1_F_RDLCK:
344 nf->l_type = F_RDLCK;
345 break;
347 case OSF1_F_WRLCK:
348 nf->l_type = F_WRLCK;
349 break;
351 case OSF1_F_UNLCK:
352 nf->l_type = F_UNLCK;
353 break;
355 default:
356 return (EINVAL);
359 switch (of->l_whence) {
360 case OSF1_SEEK_SET:
361 nf->l_whence = SEEK_SET;
362 break;
364 case OSF1_SEEK_CUR:
365 nf->l_whence = SEEK_CUR;
366 break;
368 case OSF1_SEEK_END:
369 nf->l_whence = SEEK_END;
370 break;
372 default:
373 return (EINVAL);
376 return (0);
380 osf1_cvt_msghdr_xopen_to_native(const struct osf1_msghdr_xopen *omh, struct msghdr *bmh)
382 unsigned long leftovers;
384 memset(bmh, 0, sizeof bmh);
385 bmh->msg_name = omh->msg_name; /* XXX sockaddr translation */
386 bmh->msg_namelen = omh->msg_namelen;
387 bmh->msg_iov = NULL; /* iovec xlation separate */
388 bmh->msg_iovlen = omh->msg_iovlen;
390 /* XXX we don't translate control messages (yet) */
391 if (bmh->msg_control != NULL || bmh->msg_controllen != 0)
393 printf("osf1_cvt_msghdr_xopen_to_native: control\n");
394 return (EINVAL);
397 /* translate flags */
398 bmh->msg_flags = emul_flags_translate(osf1_sendrecv_msg_flags_xtab,
399 omh->msg_flags, &leftovers);
400 if (leftovers != 0)
402 printf("osf1_cvt_msghdr_xopen_to_native: leftovers 0x%lx\n", leftovers);
403 return (EINVAL);
406 return (0);
410 osf1_cvt_pathconf_name_to_native(int oname, int *bnamep)
412 int error;
414 error = 0;
415 switch (oname) {
416 case OSF1__PC_CHOWN_RESTRICTED:
417 *bnamep = _PC_CHOWN_RESTRICTED;
418 break;
420 case OSF1__PC_LINK_MAX:
421 *bnamep = _PC_LINK_MAX;
422 break;
424 case OSF1__PC_MAX_CANON:
425 *bnamep = _PC_MAX_CANON;
426 break;
428 case OSF1__PC_MAX_INPUT:
429 *bnamep = _PC_MAX_INPUT;
430 break;
432 case OSF1__PC_NAME_MAX:
433 *bnamep = _PC_NAME_MAX;
434 break;
436 case OSF1__PC_NO_TRUNC:
437 *bnamep = _PC_NO_TRUNC;
438 break;
440 case OSF1__PC_PATH_MAX:
441 *bnamep = _PC_PATH_MAX;
442 break;
444 case OSF1__PC_PIPE_BUF:
445 *bnamep = _PC_PIPE_BUF;
446 break;
448 case OSF1__PC_VDISABLE:
449 *bnamep = _PC_VDISABLE;
450 break;
452 default:
453 error = EINVAL;
454 break;
457 return (error);
461 * Convert from as rusage structure to an osf1 rusage structure.
463 void
464 osf1_cvt_rusage_from_native(const struct rusage *ru, struct osf1_rusage *oru)
467 oru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
468 oru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
470 oru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
471 oru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
473 oru->ru_maxrss = ru->ru_maxrss;
474 oru->ru_ixrss = ru->ru_ixrss;
475 oru->ru_idrss = ru->ru_idrss;
476 oru->ru_isrss = ru->ru_isrss;
477 oru->ru_minflt = ru->ru_minflt;
478 oru->ru_majflt = ru->ru_majflt;
479 oru->ru_nswap = ru->ru_nswap;
480 oru->ru_inblock = ru->ru_inblock;
481 oru->ru_oublock = ru->ru_oublock;
482 oru->ru_msgsnd = ru->ru_msgsnd;
483 oru->ru_msgrcv = ru->ru_msgrcv;
484 oru->ru_nsignals = ru->ru_nsignals;
485 oru->ru_nvcsw = ru->ru_nvcsw;
486 oru->ru_nivcsw = ru->ru_nivcsw;
490 * XXX: Only a subset of the flags is currently implemented.
492 void
493 osf1_cvt_sigaction_from_native(const struct sigaction *bsa, struct osf1_sigaction *osa)
496 osa->osf1_sa_handler = bsa->sa_handler;
497 osf1_cvt_sigset_from_native(&bsa->sa_mask, &osa->osf1_sa_mask);
499 /* translate flags */
500 osa->osf1_sa_flags = emul_flags_translate(osf1_sigaction_flags_rxtab,
501 bsa->sa_flags, NULL);
505 osf1_cvt_sigaction_to_native(const struct osf1_sigaction *osa, struct sigaction *bsa)
508 bsa->sa_handler = osa->osf1_sa_handler;
509 osf1_cvt_sigset_to_native(&osa->osf1_sa_mask, &bsa->sa_mask);
511 /* translate flags */
512 bsa->sa_flags = emul_flags_translate(osf1_sigaction_flags_xtab,
513 osa->osf1_sa_flags, NULL);
514 /* XXX error if we can't translate */
516 return (0);
519 void
520 osf1_cvt_sigset_from_native(const sigset_t *bss, osf1_sigset_t *oss)
522 int i, newsig;
524 osf1_sigemptyset(oss);
525 for (i = 1; i < NSIG; i++) {
526 if (sigismember(bss, i)) {
527 newsig = native_to_osf1_signo[i];
528 if (newsig)
529 osf1_sigaddset(oss, newsig);
535 osf1_cvt_sigset_to_native(const osf1_sigset_t *oss, sigset_t *bss)
537 int i, newsig;
539 sigemptyset(bss);
540 for (i = 1; i < OSF1_NSIG; i++) {
541 if (osf1_sigismember(oss, i)) {
542 newsig = osf1_to_native_signo[i];
543 if (newsig)
544 sigaddset(bss, newsig);
547 return (0);
551 * Convert from a stat structure to an osf1 stat structure.
553 void
554 osf1_cvt_stat_from_native(const struct stat *st, struct osf1_stat *ost)
557 ost->st_dev = osf1_cvt_dev_from_native(st->st_dev);
558 ost->st_ino = st->st_ino;
559 ost->st_mode = st->st_mode;
560 ost->st_nlink = st->st_nlink;
561 ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid;
562 ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid;
563 ost->st_rdev = osf1_cvt_dev_from_native(st->st_rdev);
564 ost->st_size = st->st_size;
565 ost->st_atime_sec = st->st_atime;
566 ost->st_spare1 = 0;
567 ost->st_mtime_sec = st->st_mtime;
568 ost->st_spare2 = 0;
569 ost->st_ctime_sec = st->st_ctime;
570 ost->st_spare3 = 0;
571 ost->st_blksize = st->st_blksize;
572 ost->st_blocks = st->st_blocks;
573 ost->st_flags = st->st_flags;
574 ost->st_gen = st->st_gen;
578 * Convert from a stat structure to an osf1 stat structure.
580 void
581 osf1_cvt_stat2_from_native(const struct stat *st, struct osf1_stat2 *ost)
584 memset(ost, 0, sizeof *ost);
585 ost->st_dev = osf1_cvt_dev_from_native(st->st_dev);
586 ost->st_ino = st->st_ino;
587 ost->st_mode = st->st_mode;
588 ost->st_nlink = st->st_nlink;
589 ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid;
590 ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid;
591 ost->st_rdev = osf1_cvt_dev_from_native(st->st_rdev);
592 ost->st_size = st->st_size;
593 ost->st_atime_sec = st->st_atime;
594 ost->st_mtime_sec = st->st_mtime;
595 ost->st_ctime_sec = st->st_ctime;
596 ost->st_blocksize = st->st_blksize;
597 ost->st_blocks = st->st_blocks;
598 ost->st_flags = st->st_flags;
599 ost->st_generation = st->st_gen;
602 void
603 osf1_cvt_statfs_from_native(const struct statvfs *bsfs, struct osf1_statfs *osfs)
606 memset(osfs, 0, sizeof (struct osf1_statfs));
607 if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
608 osfs->f_type = OSF1_MOUNT_UFS;
609 else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
610 osfs->f_type = OSF1_MOUNT_NFS;
611 else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
612 osfs->f_type = OSF1_MOUNT_MFS;
613 else
614 /* uh oh... XXX = PC, CDFS, PROCFS, etc. */
615 osfs->f_type = OSF1_MOUNT_ADDON;
616 osfs->f_flags = bsfs->f_flag; /* XXX translate */
617 osfs->f_fsize = bsfs->f_frsize;
618 osfs->f_bsize = bsfs->f_bsize;
619 osfs->f_blocks = bsfs->f_blocks;
620 osfs->f_bfree = bsfs->f_bfree;
621 osfs->f_bavail = bsfs->f_bavail;
622 osfs->f_files = bsfs->f_files;
623 osfs->f_ffree = bsfs->f_ffree;
624 memcpy(&osfs->f_fsid, &bsfs->f_fsidx, sizeof osfs->f_fsid);
625 /* osfs->f_spare zeroed above */
626 memcpy(osfs->f_mntonname, bsfs->f_mntonname, sizeof osfs->f_mntonname);
627 memcpy(osfs->f_mntfromname, bsfs->f_mntfromname,
628 sizeof osfs->f_mntfromname);
629 /* XXX osfs->f_xxx should be filled in... */