proc->thread stage 4: rework the VFS and DEVICE subsystems to take thread
[dragonfly.git] / sys / emulation / svr4 / svr4_stat.c
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1998 Mark Newton
3 * Copyright (c) 1994 Christos Zoulas
4 * All rights reserved.
5 *
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. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: src/sys/svr4/svr4_stat.c,v 1.6 1999/12/08 12:00:48 newton Exp $
dadab5e9 29 * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stat.c,v 1.4 2003/06/25 03:56:10 dillon Exp $
984263bc
MD
30 */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/proc.h>
35#include <sys/stat.h>
36#include <sys/filedesc.h>
37#include <sys/kernel.h>
38#include <sys/unistd.h>
39#include <sys/time.h>
40#include <sys/sysctl.h>
41#include <sys/sysproto.h>
42
43#include <vm/vm.h>
44
45#include <netinet/in.h>
46
47#include <svr4/svr4.h>
48#include <svr4/svr4_types.h>
49#include <svr4/svr4_signal.h>
50#include <svr4/svr4_proto.h>
51#include <svr4/svr4_util.h>
52#include <svr4/svr4_stat.h>
53#include <svr4/svr4_ustat.h>
54#include <svr4/svr4_utsname.h>
55#include <svr4/svr4_systeminfo.h>
56#include <svr4/svr4_socket.h>
57#include <svr4/svr4_time.h>
58#if defined(NOTYET)
59#include "svr4_fuser.h"
60#endif
61
62#ifdef sparc
63/*
64 * Solaris-2.4 on the sparc has the old stat call using the new
65 * stat data structure...
66 */
67# define SVR4_NO_OSTAT
68#endif
69
70struct svr4_ustat_args {
71 svr4_dev_t dev;
72 struct svr4_ustat * name;
73};
74
75static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *));
76static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *));
41c20dac 77int svr4_ustat __P((struct svr4_ustat_args *));
984263bc
MD
78static int svr4_to_bsd_pathconf __P((int));
79
80/*
81 * SVR4 uses named pipes as named sockets, so we tell programs
82 * that sockets are named pipes with mode 0
83 */
84#define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
85
86
87#ifndef SVR4_NO_OSTAT
88static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
89
90static void
91bsd_to_svr4_stat(st, st4)
92 struct stat *st;
93 struct svr4_stat *st4;
94{
95 memset(st4, 0, sizeof(*st4));
96 st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
97 st4->st_ino = st->st_ino;
98 st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
99 st4->st_nlink = st->st_nlink;
100 st4->st_uid = st->st_uid;
101 st4->st_gid = st->st_gid;
102 st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
103 st4->st_size = st->st_size;
104 st4->st_atim = st->st_atimespec.tv_sec;
105 st4->st_mtim = st->st_mtimespec.tv_sec;
106 st4->st_ctim = st->st_ctimespec.tv_sec;
107}
108#endif
109
110
111static void
112bsd_to_svr4_xstat(st, st4)
113 struct stat *st;
114 struct svr4_xstat *st4;
115{
116 memset(st4, 0, sizeof(*st4));
117 st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
118 st4->st_ino = st->st_ino;
119 st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
120 st4->st_nlink = st->st_nlink;
121 st4->st_uid = st->st_uid;
122 st4->st_gid = st->st_gid;
123 st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
124 st4->st_size = st->st_size;
125 st4->st_atim = st->st_atimespec;
126 st4->st_mtim = st->st_mtimespec;
127 st4->st_ctim = st->st_ctimespec;
128 st4->st_blksize = st->st_blksize;
129 st4->st_blocks = st->st_blocks;
130 strcpy(st4->st_fstype, "unknown");
131}
132
133
134static void
135bsd_to_svr4_stat64(st, st4)
136 struct stat *st;
137 struct svr4_stat64 *st4;
138{
139 memset(st4, 0, sizeof(*st4));
140 st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
141 st4->st_ino = st->st_ino;
142 st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
143 st4->st_nlink = st->st_nlink;
144 st4->st_uid = st->st_uid;
145 st4->st_gid = st->st_gid;
146 st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
147 st4->st_size = st->st_size;
148 st4->st_atim = st->st_atimespec;
149 st4->st_mtim = st->st_mtimespec;
150 st4->st_ctim = st->st_ctimespec;
151 st4->st_blksize = st->st_blksize;
152 st4->st_blocks = st->st_blocks;
153 strcpy(st4->st_fstype, "unknown");
154}
155
156int
41c20dac 157svr4_sys_stat(struct svr4_sys_stat_args *uap)
984263bc 158{
dadab5e9 159 struct thread *td = curthread;
984263bc
MD
160 struct stat st;
161 struct svr4_stat svr4_st;
162 struct stat_args cup;
163 int error;
164 caddr_t sg = stackgap_init();
165
41c20dac 166 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
167
168 SCARG(&cup, path) = SCARG(uap, path);
169 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
170
171
41c20dac 172 if ((error = stat(&cup)) != 0)
984263bc
MD
173 return error;
174
175 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
176 return error;
177
178 bsd_to_svr4_stat(&st, &svr4_st);
179
180 if (S_ISSOCK(st.st_mode))
dadab5e9 181 (void) svr4_add_socket(td, SCARG(uap, path), &st);
984263bc
MD
182
183 if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
184 return error;
185
186 return 0;
187}
188
189
190int
41c20dac 191svr4_sys_lstat(struct svr4_sys_lstat_args *uap)
984263bc 192{
dadab5e9 193 struct thread *td = curthread;
984263bc
MD
194 struct stat st;
195 struct svr4_stat svr4_st;
196 struct lstat_args cup;
197 int error;
198 caddr_t sg = stackgap_init();
199
41c20dac 200 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
201
202 SCARG(&cup, path) = SCARG(uap, path);
203 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
204
41c20dac 205 if ((error = lstat(&cup)) != 0)
984263bc
MD
206 return error;
207
208 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
209 return error;
210
211 bsd_to_svr4_stat(&st, &svr4_st);
212
213 if (S_ISSOCK(st.st_mode))
dadab5e9 214 (void) svr4_add_socket(td, SCARG(uap, path), &st);
984263bc
MD
215
216 if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
217 return error;
218
219 return 0;
220}
221
222
223int
41c20dac 224svr4_sys_fstat(struct svr4_sys_fstat_args *uap)
984263bc
MD
225{
226 struct stat st;
227 struct svr4_stat svr4_st;
228 struct fstat_args cup;
229 int error;
230 caddr_t sg = stackgap_init();
231
232 SCARG(&cup, fd) = SCARG(uap, fd);
233 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
234
41c20dac 235 if ((error = fstat(&cup)) != 0)
984263bc
MD
236 return error;
237
238 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
239 return error;
240
241 bsd_to_svr4_stat(&st, &svr4_st);
242
243 if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
244 return error;
245
246 return 0;
247}
248
249
250int
41c20dac 251svr4_sys_xstat(struct svr4_sys_xstat_args *uap)
984263bc
MD
252{
253 struct stat st;
254 struct svr4_xstat svr4_st;
255 struct stat_args cup;
256 int error;
257
258 caddr_t sg = stackgap_init();
41c20dac 259 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
260
261 SCARG(&cup, path) = SCARG(uap, path);
262 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
263
41c20dac 264 if ((error = stat(&cup)) != 0)
984263bc
MD
265 return error;
266
267 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
268 return error;
269
270 bsd_to_svr4_xstat(&st, &svr4_st);
271
272#if defined(SOCKET_NOTYET)
273 if (S_ISSOCK(st.st_mode))
274 (void) svr4_add_socket(p, SCARG(uap, path), &st);
275#endif
276
277 if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
278 return error;
279
280 return 0;
281}
282
283int
41c20dac 284svr4_sys_lxstat(struct svr4_sys_lxstat_args *uap)
984263bc
MD
285{
286 struct stat st;
287 struct svr4_xstat svr4_st;
288 struct lstat_args cup;
289 int error;
290 caddr_t sg = stackgap_init();
41c20dac 291 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
292
293 SCARG(&cup, path) = SCARG(uap, path);
294 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
295
41c20dac 296 if ((error = lstat(&cup)) != 0)
984263bc
MD
297 return error;
298
299 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
300 return error;
301
302 bsd_to_svr4_xstat(&st, &svr4_st);
303
304#if defined(SOCKET_NOTYET)
305 if (S_ISSOCK(st.st_mode))
306 (void) svr4_add_socket(p, SCARG(uap, path), &st);
307#endif
308 if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
309 return error;
310
311 return 0;
312}
313
314
315int
41c20dac 316svr4_sys_fxstat(struct svr4_sys_fxstat_args *uap)
984263bc
MD
317{
318 struct stat st;
319 struct svr4_xstat svr4_st;
320 struct fstat_args cup;
321 int error;
322
323 caddr_t sg = stackgap_init();
324
325 SCARG(&cup, fd) = SCARG(uap, fd);
326 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
327
41c20dac 328 if ((error = fstat(&cup)) != 0)
984263bc
MD
329 return error;
330
331 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
332 return error;
333
334 bsd_to_svr4_xstat(&st, &svr4_st);
335
336 if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
337 return error;
338
339 return 0;
340}
341
342int
41c20dac 343svr4_sys_stat64(struct svr4_sys_stat64_args *uap)
984263bc 344{
dadab5e9 345 struct thread *td = curthread;
984263bc
MD
346 struct stat st;
347 struct svr4_stat64 svr4_st;
348 struct stat_args cup;
349 int error;
350 caddr_t sg = stackgap_init();
351
41c20dac 352 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
353
354 SCARG(&cup, path) = SCARG(uap, path);
355 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
356
41c20dac 357 if ((error = stat(&cup)) != 0)
984263bc
MD
358 return error;
359
360 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
361 return error;
362
363 bsd_to_svr4_stat64(&st, &svr4_st);
364
365 if (S_ISSOCK(st.st_mode))
dadab5e9 366 (void) svr4_add_socket(td, SCARG(uap, path), &st);
984263bc
MD
367
368 if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
369 return error;
370
371 return 0;
372}
373
374
375int
41c20dac 376svr4_sys_lstat64(struct svr4_sys_lstat64_args *uap)
984263bc 377{
dadab5e9 378 struct thread *td = curthread;
984263bc
MD
379 struct stat st;
380 struct svr4_stat64 svr4_st;
381 struct stat_args cup;
382 int error;
383 caddr_t sg = stackgap_init();
384
41c20dac 385 CHECKALTEXIST(&sg, (char *) SCARG(uap, path));
984263bc
MD
386
387 SCARG(&cup, path) = SCARG(uap, path);
388 SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
389
41c20dac 390 if ((error = lstat((struct lstat_args *)&cup)) != 0)
984263bc
MD
391 return error;
392
393 if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
394 return error;
395
396 bsd_to_svr4_stat64(&st, &svr4_st);
397
398 if (S_ISSOCK(st.st_mode))
dadab5e9 399 (void) svr4_add_socket(td, SCARG(uap, path), &st);
984263bc
MD
400
401 if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
402 return error;
403
404 return 0;
405}
406
407
408int
41c20dac 409svr4_sys_fstat64(struct svr4_sys_fstat64_args *uap)
984263bc
MD
410{
411 struct stat st;
412 struct svr4_stat64 svr4_st;
413 struct fstat_args cup;
414 int error;
415 caddr_t sg = stackgap_init();
416
417 SCARG(&cup, fd) = SCARG(uap, fd);
418 SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
419
41c20dac 420 if ((error = fstat(&cup)) != 0)
984263bc
MD
421 return error;
422
423 if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
424 return error;
425
426 bsd_to_svr4_stat64(&st, &svr4_st);
427
428 if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
429 return error;
430
431 return 0;
432}
433
434
435int
41c20dac 436svr4_ustat(struct svr4_ustat_args *uap)
984263bc
MD
437{
438 struct svr4_ustat us;
439 int error;
440
441 memset(&us, 0, sizeof us);
442
443 /*
444 * XXX: should set f_tfree and f_tinode at least
445 * How do we translate dev -> fstat? (and then to svr4_ustat)
446 */
447 if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
448 return (error);
449
450 return 0;
451}
452
453/*extern char ostype[], hostname[], osrelease[], version[], machine[];*/
454
455int
41c20dac 456svr4_sys_uname(struct svr4_sys_uname_args *uap)
984263bc
MD
457{
458 struct svr4_utsname sut;
459
984263bc
MD
460 memset(&sut, 0, sizeof(sut));
461
462 strncpy(sut.sysname, ostype, sizeof(sut.sysname));
463 sut.sysname[sizeof(sut.sysname) - 1] = '\0';
464
465 strncpy(sut.nodename, hostname, sizeof(sut.nodename));
466 sut.nodename[sizeof(sut.nodename) - 1] = '\0';
467
468 strncpy(sut.release, osrelease, sizeof(sut.release));
469 sut.release[sizeof(sut.release) - 1] = '\0';
470
471 strncpy(sut.version, version, sizeof(sut.version));
472 sut.version[sizeof(sut.version) - 1] = '\0';
473
474 strncpy(sut.machine, machine, sizeof(sut.machine));
475 sut.machine[sizeof(sut.machine) - 1] = '\0';
476
477 return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
478 sizeof(struct svr4_utsname));
479}
480
481int
41c20dac 482svr4_sys_systeminfo(struct svr4_sys_systeminfo_args *uap)
984263bc 483{
dadab5e9
MD
484 struct thread *td = curthread;
485 struct proc *p = td->td_proc;
984263bc
MD
486 char *str = NULL;
487 int error = 0;
488 register_t *retval = p->p_retval;
489 size_t len = 0;
490 char buf[1]; /* XXX NetBSD uses 256, but that seems
491 like awfully excessive kstack usage
492 for an empty string... */
493 u_int rlen = SCARG(uap, len);
494
495 switch (SCARG(uap, what)) {
496 case SVR4_SI_SYSNAME:
497 str = ostype;
498 break;
499
500 case SVR4_SI_HOSTNAME:
501 str = hostname;
502 break;
503
504 case SVR4_SI_RELEASE:
505 str = osrelease;
506 break;
507
508 case SVR4_SI_VERSION:
509 str = version;
510 break;
511
512 case SVR4_SI_MACHINE:
513 str = machine;
514 break;
515
516 case SVR4_SI_ARCHITECTURE:
517 str = machine;
518 break;
519
520 case SVR4_SI_HW_SERIAL:
521 str = "0";
522 break;
523
524 case SVR4_SI_HW_PROVIDER:
525 str = ostype;
526 break;
527
528 case SVR4_SI_SRPC_DOMAIN:
529 str = domainname;
530 break;
531
532 case SVR4_SI_PLATFORM:
533#ifdef __i386__
534 str = "i86pc";
535#else
536 str = "unknown";
537#endif
538 break;
539
540 case SVR4_SI_KERB_REALM:
541 str = "unsupported";
542 break;
543#if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
544 case SVR4_SI_SET_HOSTNAME:
dadab5e9 545 if ((error = suser(td)) != 0)
984263bc
MD
546 return error;
547 name = KERN_HOSTNAME;
548 return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
549
550 case SVR4_SI_SET_SRPC_DOMAIN:
dadab5e9 551 if ((error = suser(td)) != 0)
984263bc
MD
552 return error;
553 name = KERN_NISDOMAINNAME;
554 return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
555#else
556 case SVR4_SI_SET_HOSTNAME:
557 case SVR4_SI_SET_SRPC_DOMAIN:
558 /* FALLTHROUGH */
559#endif
560 case SVR4_SI_SET_KERB_REALM:
561 return 0;
562
563 default:
564 DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
565 return ENOSYS;
566 }
567
568 if (str) {
569 len = strlen(str) + 1;
570 if (len > rlen)
571 len = rlen;
572
573 if (SCARG(uap, buf)) {
574 error = copyout(str, SCARG(uap, buf), len);
575 if (error)
576 return error;
577 /* make sure we are NULL terminated */
578 buf[0] = '\0';
579 error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
580 }
581 else
582 error = 0;
583 }
584 /* XXX NetBSD has hostname setting stuff here. Why would an emulator
585 want to do that? */
586
587 *retval = len;
588 return error;
589}
590
591int
41c20dac 592svr4_sys_utssys(struct svr4_sys_utssys_args *uap)
984263bc
MD
593{
594 switch (SCARG(uap, sel)) {
595 case 0: /* uname(2) */
596 {
597 struct svr4_sys_uname_args ua;
598 SCARG(&ua, name) = SCARG(uap, a1);
41c20dac 599 return svr4_sys_uname(&ua);
984263bc
MD
600 }
601
602 case 2: /* ustat(2) */
603 {
604 struct svr4_ustat_args ua;
605 SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
606 SCARG(&ua, name) = SCARG(uap, a1);
41c20dac 607 return svr4_ustat(&ua);
984263bc
MD
608 }
609
610 case 3: /* fusers(2) */
611 return ENOSYS;
612
613 default:
614 return ENOSYS;
615 }
616 return ENOSYS;
617}
618
619
620int
41c20dac 621svr4_sys_utime(struct svr4_sys_utime_args *uap)
984263bc
MD
622{
623 struct svr4_utimbuf ub;
624 struct timeval tbuf[2];
625 struct utimes_args ap;
626 int error;
627 caddr_t sg = stackgap_init();
628 void *ttp;
629
41c20dac 630 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
631 SCARG(&ap, path) = SCARG(uap, path);
632 if (SCARG(uap, ubuf) != NULL) {
633 if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
634 return error;
635 tbuf[0].tv_sec = ub.actime;
636 tbuf[0].tv_usec = 0;
637 tbuf[1].tv_sec = ub.modtime;
638 tbuf[1].tv_usec = 0;
639 ttp = stackgap_alloc(&sg, sizeof(tbuf));
640 error = copyout(tbuf, ttp, sizeof(tbuf));
641 if (error)
642 return error;
643 SCARG(&ap, tptr) = ttp;
644 }
645 else
646 SCARG(&ap, tptr) = NULL;
41c20dac 647 return utimes(&ap);
984263bc
MD
648}
649
650
651int
41c20dac 652svr4_sys_utimes(struct svr4_sys_utimes_args *uap)
984263bc
MD
653{
654 caddr_t sg = stackgap_init();
41c20dac
MD
655 CHECKALTEXIST(&sg, SCARG(uap, path));
656 return utimes((struct utimes_args *)uap);
984263bc
MD
657}
658
659static int
660svr4_to_bsd_pathconf(name)
661 int name;
662{
663 switch (name) {
664 case SVR4_PC_LINK_MAX:
665 return _PC_LINK_MAX;
666
667 case SVR4_PC_MAX_CANON:
668 return _PC_MAX_CANON;
669
670 case SVR4_PC_MAX_INPUT:
671 return _PC_MAX_INPUT;
672
673 case SVR4_PC_NAME_MAX:
674 return _PC_NAME_MAX;
675
676 case SVR4_PC_PATH_MAX:
677 return _PC_PATH_MAX;
678
679 case SVR4_PC_PIPE_BUF:
680 return _PC_PIPE_BUF;
681
682 case SVR4_PC_NO_TRUNC:
683 return _PC_NO_TRUNC;
684
685 case SVR4_PC_VDISABLE:
686 return _PC_VDISABLE;
687
688 case SVR4_PC_CHOWN_RESTRICTED:
689 return _PC_CHOWN_RESTRICTED;
690 case SVR4_PC_SYNC_IO:
691#if defined(_PC_SYNC_IO)
692 return _PC_SYNC_IO;
693#else
694 return 0;
695#endif
696 case SVR4_PC_ASYNC_IO:
697 case SVR4_PC_PRIO_IO:
698 /* Not supported */
699 return 0;
700
701 default:
702 /* Invalid */
703 return -1;
704 }
705}
706
707
708int
41c20dac 709svr4_sys_pathconf(struct svr4_sys_pathconf_args *uap)
984263bc 710{
41c20dac 711 struct proc *p = curproc;
984263bc
MD
712 caddr_t sg = stackgap_init();
713 register_t *retval = p->p_retval;
714
41c20dac 715 CHECKALTEXIST(&sg, SCARG(uap, path));
984263bc
MD
716
717 SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
718
719 switch (SCARG(uap, name)) {
720 case -1:
721 *retval = -1;
722 return EINVAL;
723 case 0:
724 *retval = 0;
725 return 0;
726 default:
41c20dac 727 return pathconf((struct pathconf_args *)uap);
984263bc
MD
728 }
729}
730
731
732int
41c20dac 733svr4_sys_fpathconf(struct svr4_sys_fpathconf_args *uap)
984263bc 734{
41c20dac 735 struct proc *p = curproc;
984263bc
MD
736 register_t *retval = p->p_retval;
737
738 SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
739
740 switch (SCARG(uap, name)) {
741 case -1:
742 *retval = -1;
743 return EINVAL;
744 case 0:
745 *retval = 0;
746 return 0;
747 default:
41c20dac 748 return fpathconf((struct fpathconf_args *)uap);
984263bc
MD
749 }
750}