1 /* $NetBSD: svr4_stat.c,v 1.70 2014/08/14 17:29:30 maxv Exp $ */
2
3 /*-
4 * Copyright (c) 1994, 2008 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
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.70 2014/08/14 17:29:30 maxv Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/namei.h>
38 #include <sys/proc.h>
39 #include <sys/file.h>
40 #include <sys/stat.h>
41 #include <sys/filedesc.h>
42 #include <sys/ioctl.h>
43 #include <sys/kernel.h>
44 #include <sys/mount.h>
45 #include <sys/malloc.h>
46 #include <sys/namei.h>
47 #include <sys/unistd.h>
48
49 #include <sys/time.h>
50 #include <sys/ucred.h>
51 #include <uvm/uvm_extern.h>
52 #include <sys/sysctl.h>
53
54 #include <sys/syscallargs.h>
55 #include <sys/vfs_syscalls.h>
56
57 #include <compat/svr4/svr4_types.h>
58 #include <compat/svr4/svr4_signal.h>
59 #include <compat/svr4/svr4_lwp.h>
60 #include <compat/svr4/svr4_ucontext.h>
61 #include <compat/svr4/svr4_syscallargs.h>
62 #include <compat/svr4/svr4_util.h>
63 #include <compat/svr4/svr4_stat.h>
64 #include <compat/svr4/svr4_ustat.h>
65 #include <compat/svr4/svr4_fuser.h>
66 #include <compat/svr4/svr4_utsname.h>
67 #include <compat/svr4/svr4_systeminfo.h>
68 #include <compat/svr4/svr4_time.h>
69 #include <compat/svr4/svr4_socket.h>
70
71 #ifdef __sparc__
72 /*
73 * Solaris-2.4 on the sparc has the old stat call using the new
74 * stat data structure...
75 */
76 # define SVR4_NO_OSTAT
77 #endif
78
79 static void bsd_to_svr4_xstat(struct stat *, struct svr4_xstat *);
80 static void bsd_to_svr4_stat64(struct stat *, struct svr4_stat64 *);
81
82 struct svr4_ustat_args {
83 syscallarg(svr4_dev_t) dev;
84 syscallarg(struct svr4_ustat *) name;
85 };
86
87 int svr4_ustat(struct lwp *, const struct svr4_ustat_args *, register_t *);
88 static int svr4_to_bsd_pathconf(int);
89
90 /*
91 * SVR4 uses named pipes as named sockets, so we tell programs
92 * that sockets are named pipes with mode 0
93 */
94 #define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
95
96
97 #ifndef SVR4_NO_OSTAT
98 static void bsd_to_svr4_stat(struct stat *, struct svr4_stat *);
99
100 static void
bsd_to_svr4_stat(struct stat * st,struct svr4_stat * st4)101 bsd_to_svr4_stat(struct stat *st, struct svr4_stat *st4)
102 {
103 memset(st4, 0, sizeof(*st4));
104 st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
105 st4->st_ino = st->st_ino;
106 st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
107 st4->st_nlink = st->st_nlink;
108 st4->st_uid = st->st_uid;
109 st4->st_gid = st->st_gid;
110 st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
111 st4->st_size = st->st_size;
112 st4->st_atim = st->st_atimespec.tv_sec;
113 st4->st_mtim = st->st_mtimespec.tv_sec;
114 st4->st_ctim = st->st_ctimespec.tv_sec;
115 }
116 #endif
117
118
119 static void
bsd_to_svr4_xstat(struct stat * st,struct svr4_xstat * st4)120 bsd_to_svr4_xstat(struct stat *st, struct svr4_xstat *st4)
121 {
122 memset(st4, 0, sizeof(*st4));
123 st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
124 st4->st_ino = st->st_ino;
125 st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
126 st4->st_nlink = st->st_nlink;
127 st4->st_uid = st->st_uid;
128 st4->st_gid = st->st_gid;
129 st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
130 st4->st_size = st->st_size;
131 st4->st_atim.tv_sec = st->st_atimespec.tv_sec;
132 st4->st_atim.tv_nsec = st->st_atimespec.tv_nsec;
133 st4->st_mtim.tv_sec = st->st_mtimespec.tv_sec;
134 st4->st_mtim.tv_nsec = st->st_mtimespec.tv_nsec;
135 st4->st_ctim.tv_sec = st->st_ctimespec.tv_sec;
136 st4->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
137 st4->st_blksize = st->st_blksize;
138 st4->st_blocks = st->st_blocks;
139 strlcpy(st4->st_fstype, "unknown", sizeof(st4->st_fstype));
140 }
141
142
143 static void
bsd_to_svr4_stat64(struct stat * st,struct svr4_stat64 * st4)144 bsd_to_svr4_stat64(struct stat *st, struct svr4_stat64 *st4)
145 {
146 memset(st4, 0, sizeof(*st4));
147 st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
148 st4->st_ino = st->st_ino;
149 st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
150 st4->st_nlink = st->st_nlink;
151 st4->st_uid = st->st_uid;
152 st4->st_gid = st->st_gid;
153 st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
154 st4->st_size = st->st_size;
155 st4->st_atim.tv_sec = st->st_atimespec.tv_sec;
156 st4->st_atim.tv_nsec = st->st_atimespec.tv_nsec;
157 st4->st_mtim.tv_sec = st->st_mtimespec.tv_sec;
158 st4->st_mtim.tv_nsec = st->st_mtimespec.tv_nsec;
159 st4->st_ctim.tv_sec = st->st_ctimespec.tv_sec;
160 st4->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
161 st4->st_blksize = st->st_blksize;
162 st4->st_blocks = st->st_blocks;
163 strlcpy(st4->st_fstype, "unknown", sizeof(st4->st_fstype));
164 }
165
166
167 int
svr4_sys_stat(struct lwp * l,const struct svr4_sys_stat_args * uap,register_t * retval)168 svr4_sys_stat(struct lwp *l, const struct svr4_sys_stat_args *uap, register_t *retval)
169 {
170 #ifdef SVR4_NO_OSTAT
171 struct svr4_sys_xstat_args cup;
172
173 SCARG(&cup, two) = 2;
174 SCARG(&cup, path) = SCARG(uap, path);
175 SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub);
176 return svr4_sys_xstat(l, &cup, retval);
177 #else
178 struct stat st;
179 struct svr4_stat svr4_st;
180 int error;
181
182 error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
183 if (error != 0)
184 return error;
185
186 bsd_to_svr4_stat(&st, &svr4_st);
187
188 if (S_ISSOCK(st.st_mode))
189 (void) svr4_add_socket(l->l_proc, SCARG(uap, path), &st);
190
191 return copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st);
192 #endif
193 }
194
195
196 int
svr4_sys_lstat(struct lwp * l,const struct svr4_sys_lstat_args * uap,register_t * retval)197 svr4_sys_lstat(struct lwp *l, const struct svr4_sys_lstat_args *uap, register_t *retval)
198 {
199 #ifdef SVR4_NO_OSTAT
200 struct svr4_sys_lxstat_args cup;
201
202 SCARG(&cup, two) = 2;
203 SCARG(&cup, path) = SCARG(uap, path);
204 SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub);
205 return svr4_sys_lxstat(l, &cup, retval);
206 #else
207 struct stat st;
208 struct svr4_stat svr4_st;
209 int error;
210
211 error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
212 if (error != 0)
213 return error;
214
215 bsd_to_svr4_stat(&st, &svr4_st);
216
217 if (S_ISSOCK(st.st_mode))
218 (void) svr4_add_socket(l->l_proc, SCARG(uap, path), &st);
219
220 return copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st);
221 #endif
222 }
223
224
225 int
svr4_sys_fstat(struct lwp * l,const struct svr4_sys_fstat_args * uap,register_t * retval)226 svr4_sys_fstat(struct lwp *l, const struct svr4_sys_fstat_args *uap, register_t *retval)
227 {
228 #ifdef SVR4_NO_OSTAT
229 struct svr4_sys_fxstat_args cup;
230
231 SCARG(&cup, two) = 2;
232 SCARG(&cup, fd) = SCARG(uap, fd);
233 SCARG(&cup, sb) = (struct svr4_xstat *) SCARG(uap, sb);
234 return svr4_sys_fxstat(l, &cup, retval);
235 #else
236 struct stat st;
237 struct svr4_stat svr4_st;
238 int error;
239
240 error = do_sys_fstat(SCARG(uap, fd), &st);
241 if (error != 0)
242 return error;
243
244 bsd_to_svr4_stat(&st, &svr4_st);
245
246 return copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st);
247 #endif
248 }
249
250
251 int
svr4_sys_xstat(struct lwp * l,const struct svr4_sys_xstat_args * uap,register_t * retval)252 svr4_sys_xstat(struct lwp *l, const struct svr4_sys_xstat_args *uap, register_t *retval)
253 {
254 struct stat st;
255 struct svr4_xstat svr4_st;
256 int error;
257
258 error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
259 if (error != 0)
260 return error;
261
262 bsd_to_svr4_xstat(&st, &svr4_st);
263
264 if (S_ISSOCK(st.st_mode))
265 (void) svr4_add_socket(l->l_proc, SCARG(uap, path), &st);
266
267 return copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st);
268 }
269
270
271 int
svr4_sys_lxstat(struct lwp * l,const struct svr4_sys_lxstat_args * uap,register_t * retval)272 svr4_sys_lxstat(struct lwp *l, const struct svr4_sys_lxstat_args *uap, register_t *retval)
273 {
274 struct stat st;
275 struct svr4_xstat svr4_st;
276 int error;
277
278 error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
279 if (error != 0)
280 return error;
281
282 bsd_to_svr4_xstat(&st, &svr4_st);
283
284 if (S_ISSOCK(st.st_mode))
285 (void) svr4_add_socket(l->l_proc, SCARG(uap, path), &st);
286
287 return copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st);
288 }
289
290
291 int
svr4_sys_fxstat(struct lwp * l,const struct svr4_sys_fxstat_args * uap,register_t * retval)292 svr4_sys_fxstat(struct lwp *l, const struct svr4_sys_fxstat_args *uap, register_t *retval)
293 {
294 struct stat st;
295 struct svr4_xstat svr4_st;
296 int error;
297
298 error = do_sys_fstat(SCARG(uap, fd), &st);
299 if (error != 0)
300 return error;
301
302 bsd_to_svr4_xstat(&st, &svr4_st);
303
304 return copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st);
305 }
306
307
308 int
svr4_sys_stat64(struct lwp * l,const struct svr4_sys_stat64_args * uap,register_t * retval)309 svr4_sys_stat64(struct lwp *l, const struct svr4_sys_stat64_args *uap, register_t *retval)
310 {
311 struct stat st;
312 struct svr4_stat64 svr4_st;
313 int error;
314
315 error = do_sys_stat(SCARG(uap, path), FOLLOW, &st);
316 if (error != 0)
317 return error;
318
319 bsd_to_svr4_stat64(&st, &svr4_st);
320
321 if (S_ISSOCK(st.st_mode))
322 (void) svr4_add_socket(l->l_proc, SCARG(uap, path), &st);
323
324 return copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st);
325 }
326
327
328 int
svr4_sys_lstat64(struct lwp * l,const struct svr4_sys_lstat64_args * uap,register_t * retval)329 svr4_sys_lstat64(struct lwp *l, const struct svr4_sys_lstat64_args *uap, register_t *retval)
330 {
331 struct stat st;
332 struct svr4_stat64 svr4_st;
333 int error;
334
335 error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &st);
336 if (error != 0)
337 return error;
338
339 bsd_to_svr4_stat64(&st, &svr4_st);
340
341 if (S_ISSOCK(st.st_mode))
342 (void) svr4_add_socket(l->l_proc, SCARG(uap, path), &st);
343
344 return copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st);
345 }
346
347
348 int
svr4_sys_fstat64(struct lwp * l,const struct svr4_sys_fstat64_args * uap,register_t * retval)349 svr4_sys_fstat64(struct lwp *l, const struct svr4_sys_fstat64_args *uap, register_t *retval)
350 {
351 struct svr4_stat64 svr4_st;
352 struct stat st;
353 int error;
354
355 error = do_sys_fstat(SCARG(uap, fd), &st);
356 if (error != 0)
357 return error;
358
359 bsd_to_svr4_stat64(&st, &svr4_st);
360
361 return copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st);
362 }
363
364
365 int
svr4_ustat(struct lwp * l,const struct svr4_ustat_args * uap,register_t * retval)366 svr4_ustat(struct lwp *l, const struct svr4_ustat_args *uap, register_t *retval)
367 {
368 /* {
369 syscallarg(svr4_dev_t) dev;
370 syscallarg(struct svr4_ustat *) name;
371 } */
372 struct svr4_ustat us;
373 int error;
374
375 memset(&us, 0, sizeof us);
376
377 /*
378 * XXX: should set f_tfree and f_tinode at least
379 * How do we translate dev -> fstat? (and then to svr4_ustat)
380 */
381 if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
382 return (error);
383
384 return 0;
385 }
386
387
388
389 int
svr4_sys_uname(struct lwp * l,const struct svr4_sys_uname_args * uap,register_t * retval)390 svr4_sys_uname(struct lwp *l, const struct svr4_sys_uname_args *uap, register_t *retval)
391 {
392 struct svr4_utsname *sut;
393 int error;
394
395 sut = malloc(sizeof(*sut), M_TEMP, M_WAITOK|M_ZERO);
396
397 (void)strncpy(sut->sysname, ostype, sizeof(sut->sysname));
398 sut->sysname[sizeof(sut->sysname) - 1] = '\0';
399
400 (void)strncpy(sut->nodename, hostname, sizeof(sut->nodename));
401 sut->nodename[sizeof(sut->nodename) - 1] = '\0';
402
403 (void)strncpy(sut->release, osrelease, sizeof(sut->release));
404 sut->release[sizeof(sut->release) - 1] = '\0';
405
406 (void)strncpy(sut->version, version, sizeof(sut->version));
407 sut->version[sizeof(sut->version) - 1] = '\0';
408
409 (void)strncpy(sut->machine, machine, sizeof(sut->machine));
410 sut->machine[sizeof(sut->machine) - 1] = '\0';
411
412 error = copyout(sut, SCARG(uap, name), sizeof(*sut));
413 free(sut, M_TEMP);
414 return error;
415 }
416
417
418 int
svr4_sys_systeminfo(struct lwp * l,const struct svr4_sys_systeminfo_args * uap,register_t * retval)419 svr4_sys_systeminfo(struct lwp *l, const struct svr4_sys_systeminfo_args *uap, register_t *retval)
420 {
421 const char *str = NULL;
422 int name[2];
423 int error;
424 size_t len;
425 char buf[256];
426
427 u_int rlen = SCARG(uap, len);
428
429 switch (SCARG(uap, what)) {
430 case SVR4_SI_SYSNAME:
431 str = ostype;
432 break;
433
434 case SVR4_SI_HOSTNAME:
435 str = hostname;
436 break;
437
438 case SVR4_SI_RELEASE:
439 str = osrelease;
440 break;
441
442 case SVR4_SI_VERSION:
443 str = version;
444 break;
445
446 case SVR4_SI_MACHINE:
447 str = machine;
448 break;
449
450 case SVR4_SI_ARCHITECTURE:
451 str = machine_arch;
452 break;
453
454 case SVR4_SI_ISALIST:
455 #if defined(__sparc__)
456 str = "sparcv9 sparcv9-fsmuld sparcv8 sparcv8-fsmuld sparcv7 sparc";
457 #elif defined(__i386__)
458 str = "i386";
459 #else
460 str = "unknown";
461 #endif
462 break;
463
464 case SVR4_SI_HW_SERIAL:
465 snprintf(buf, sizeof(buf), "%lu", hostid);
466 str = buf;
467 break;
468
469 case SVR4_SI_HW_PROVIDER:
470 str = ostype;
471 break;
472
473 case SVR4_SI_SRPC_DOMAIN:
474 str = domainname;
475 break;
476
477 case SVR4_SI_PLATFORM:
478 #if defined(__i386__)
479 str = "i86pc";
480 #elif defined(__sparc__)
481 {
482 extern char machine_model[];
483
484 str = machine_model;
485 }
486 #else
487 str = "unknown";
488 #endif
489 break;
490
491 case SVR4_SI_KERB_REALM:
492 str = "unsupported";
493 break;
494
495 case SVR4_SI_SET_HOSTNAME:
496 name[1] = KERN_HOSTNAME;
497 break;
498
499 case SVR4_SI_SET_SRPC_DOMAIN:
500 name[1] = KERN_DOMAINNAME;
501 break;
502
503 case SVR4_SI_SET_KERB_REALM:
504 return 0;
505
506 default:
507 DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
508 return ENOSYS;
509 }
510
511 if (str) {
512 len = strlen(str) + 1;
513 if (len < rlen)
514 rlen = len;
515
516 if (SCARG(uap, buf)) {
517 error = copyout(str, SCARG(uap, buf), rlen);
518 if (error)
519 return error;
520 if (rlen > 0) {
521 /* make sure we are NULL terminated */
522 buf[0] = '\0';
523 error = copyout(buf,
524 &(SCARG(uap, buf)[rlen - 1]), 1);
525 }
526 }
527 else
528 error = 0;
529 }
530 else {
531 /*
532 * looks redundant to do this, but actually it retrieves "len"
533 */
534 error = copyinstr(SCARG(uap, buf), buf, sizeof(buf), &len);
535 if (error)
536 return error;
537 name[0] = CTL_KERN;
538 error = old_sysctl(&name[0], 2, 0, 0, SCARG(uap, buf), len, l);
539 }
540
541 *retval = len;
542 return error;
543 }
544
545
546 int
svr4_sys_utssys(struct lwp * l,const struct svr4_sys_utssys_args * uap,register_t * retval)547 svr4_sys_utssys(struct lwp *l, const struct svr4_sys_utssys_args *uap, register_t *retval)
548 {
549
550 switch (SCARG(uap, sel)) {
551 case 0: /* uname(2) */
552 {
553 struct svr4_sys_uname_args ua;
554 SCARG(&ua, name) = SCARG(uap, a1);
555 return svr4_sys_uname(l, &ua, retval);
556 }
557
558 case 2: /* ustat(2) */
559 {
560 struct svr4_ustat_args ua;
561 SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
562 SCARG(&ua, name) = SCARG(uap, a1);
563 return svr4_ustat(l, &ua, retval);
564 }
565
566 case 3: /* fusers(2) */
567 return ENOSYS;
568
569 default:
570 return ENOSYS;
571 }
572 }
573
574
575 int
svr4_sys_utime(struct lwp * l,const struct svr4_sys_utime_args * uap,register_t * retval)576 svr4_sys_utime(struct lwp *l, const struct svr4_sys_utime_args *uap, register_t *retval)
577 {
578 struct svr4_utimbuf ub;
579 struct timeval tbuf[2], *tvp;
580 int error;
581
582 if (SCARG(uap, ubuf) != NULL) {
583 if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
584 return error;
585 tbuf[0].tv_sec = ub.actime;
586 tbuf[0].tv_usec = 0;
587 tbuf[1].tv_sec = ub.modtime;
588 tbuf[1].tv_usec = 0;
589 tvp = tbuf;
590 } else
591 tvp = NULL;
592
593 return do_sys_utimes(l, NULL, SCARG(uap, path), FOLLOW,
594 tvp, UIO_SYSSPACE);
595 }
596
597
598 int
svr4_sys_utimes(struct lwp * l,const struct svr4_sys_utimes_args * uap,register_t * retval)599 svr4_sys_utimes(struct lwp *l, const struct svr4_sys_utimes_args *uap, register_t *retval)
600 {
601 return compat_50_sys_utimes(l, (const void *)uap, retval);
602 }
603
604
605 static int
svr4_to_bsd_pathconf(int name)606 svr4_to_bsd_pathconf(int name)
607 {
608 switch (name) {
609 case SVR4_PC_LINK_MAX:
610 return _PC_LINK_MAX;
611
612 case SVR4_PC_MAX_CANON:
613 return _PC_MAX_CANON;
614
615 case SVR4_PC_MAX_INPUT:
616 return _PC_MAX_INPUT;
617
618 case SVR4_PC_NAME_MAX:
619 return _PC_NAME_MAX;
620
621 case SVR4_PC_PATH_MAX:
622 return _PC_PATH_MAX;
623
624 case SVR4_PC_PIPE_BUF:
625 return _PC_PIPE_BUF;
626
627 case SVR4_PC_NO_TRUNC:
628 return _PC_NO_TRUNC;
629
630 case SVR4_PC_VDISABLE:
631 return _PC_VDISABLE;
632
633 case SVR4_PC_CHOWN_RESTRICTED:
634 return _PC_CHOWN_RESTRICTED;
635
636 case SVR4_PC_SYNC_IO:
637 return _PC_SYNC_IO;
638
639 case SVR4_PC_FILESIZEBITS:
640 return _PC_FILESIZEBITS;
641
642 case SVR4_PC_ASYNC_IO:
643 case SVR4_PC_PRIO_IO:
644 /* Not supported */
645 return 0;
646
647 default:
648 /* Invalid */
649 return -1;
650 }
651 }
652
653
654 int
svr4_sys_pathconf(struct lwp * l,const struct svr4_sys_pathconf_args * uap,register_t * retval)655 svr4_sys_pathconf(struct lwp *l, const struct svr4_sys_pathconf_args *uap, register_t *retval)
656 {
657 struct sys_pathconf_args bsd_ua;
658
659 SCARG(&bsd_ua, path) = SCARG(uap, path);
660 SCARG(&bsd_ua, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
661
662 switch (SCARG(&bsd_ua, name)) {
663 case -1:
664 *retval = -1;
665 return EINVAL;
666 case 0:
667 *retval = 0;
668 return 0;
669 default:
670 return sys_pathconf(l, &bsd_ua, retval);
671 }
672 }
673
674
675 int
svr4_sys_fpathconf(struct lwp * l,const struct svr4_sys_fpathconf_args * uap,register_t * retval)676 svr4_sys_fpathconf(struct lwp *l, const struct svr4_sys_fpathconf_args *uap, register_t *retval)
677 {
678 struct sys_fpathconf_args bsd_ua;
679
680 SCARG(&bsd_ua, fd) = SCARG(uap, fd);
681 SCARG(&bsd_ua, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
682
683 switch (SCARG(&bsd_ua, name)) {
684 case -1:
685 *retval = -1;
686 return EINVAL;
687 case 0:
688 *retval = 0;
689 return 0;
690 default:
691 return sys_fpathconf(l, &bsd_ua, retval);
692 }
693 }
694