Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / emulation / svr4 / svr4_stat.c
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 $
29  * $DragonFly: src/sys/emulation/svr4/Attic/svr4_stat.c,v 1.2 2003/06/17 04:28:57 dillon Exp $
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
70 struct svr4_ustat_args {
71         svr4_dev_t              dev;
72         struct svr4_ustat * name;
73 };
74
75 static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *));
76 static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *));
77 int svr4_ustat __P((struct proc *, struct svr4_ustat_args *));
78 static 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
88 static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
89
90 static void
91 bsd_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
111 static void
112 bsd_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
134 static void
135 bsd_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
156 int
157 svr4_sys_stat(p, uap)
158         struct proc *p;
159         struct svr4_sys_stat_args *uap;
160 {
161         struct stat             st;
162         struct svr4_stat        svr4_st;
163         struct stat_args        cup;
164         int                     error;
165         caddr_t sg = stackgap_init();
166
167         CHECKALTEXIST(p, &sg, SCARG(uap, path));
168
169         SCARG(&cup, path) = SCARG(uap, path);
170         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
171
172
173         if ((error = stat(p, &cup)) != 0)
174                 return error;
175
176         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
177                 return error;
178
179         bsd_to_svr4_stat(&st, &svr4_st);
180
181         if (S_ISSOCK(st.st_mode))
182                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
183
184         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
185                 return error;
186
187         return 0;
188 }
189
190
191 int
192 svr4_sys_lstat(p, uap)
193         register struct proc *p;
194         struct svr4_sys_lstat_args *uap;
195 {
196         struct stat             st;
197         struct svr4_stat        svr4_st;
198         struct lstat_args       cup;
199         int                     error;
200         caddr_t                 sg = stackgap_init();
201
202         CHECKALTEXIST(p, &sg, SCARG(uap, path));
203
204         SCARG(&cup, path) = SCARG(uap, path);
205         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
206
207         if ((error = lstat(p, &cup)) != 0)
208                 return error;
209
210         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
211                 return error;
212
213         bsd_to_svr4_stat(&st, &svr4_st);
214
215         if (S_ISSOCK(st.st_mode))
216                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
217
218         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
219                 return error;
220
221         return 0;
222 }
223
224
225 int
226 svr4_sys_fstat(p, uap)
227         register struct proc *p;
228         struct svr4_sys_fstat_args *uap;
229 {
230         struct stat             st;
231         struct svr4_stat        svr4_st;
232         struct fstat_args       cup;
233         int                     error;
234         caddr_t                 sg = stackgap_init();
235
236         SCARG(&cup, fd) = SCARG(uap, fd);
237         SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
238
239         if ((error = fstat(p, &cup)) != 0)
240                 return error;
241
242         if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
243                 return error;
244
245         bsd_to_svr4_stat(&st, &svr4_st);
246
247         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
248                 return error;
249
250         return 0;
251 }
252
253
254 int
255 svr4_sys_xstat(p, uap)
256         register struct proc *p;
257         struct svr4_sys_xstat_args *uap;
258 {
259         struct stat             st;
260         struct svr4_xstat       svr4_st;
261         struct stat_args        cup;
262         int                     error;
263
264         caddr_t sg = stackgap_init();
265         CHECKALTEXIST(p, &sg, SCARG(uap, path));
266
267         SCARG(&cup, path) = SCARG(uap, path);
268         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
269
270         if ((error = stat(p, &cup)) != 0)
271                 return error;
272
273         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
274                 return error;
275
276         bsd_to_svr4_xstat(&st, &svr4_st);
277
278 #if defined(SOCKET_NOTYET)
279         if (S_ISSOCK(st.st_mode))
280                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
281 #endif
282
283         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
284                 return error;
285
286         return 0;
287 }
288
289 int
290 svr4_sys_lxstat(p, uap)
291         register struct proc *p;
292         struct svr4_sys_lxstat_args *uap;
293 {
294         struct stat             st;
295         struct svr4_xstat       svr4_st;
296         struct lstat_args       cup;
297         int                     error;
298         caddr_t sg = stackgap_init();
299         CHECKALTEXIST(p, &sg, SCARG(uap, path));
300
301         SCARG(&cup, path) = SCARG(uap, path);
302         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
303
304         if ((error = lstat(p, &cup)) != 0)
305                 return error;
306
307         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
308                 return error;
309
310         bsd_to_svr4_xstat(&st, &svr4_st);
311
312 #if defined(SOCKET_NOTYET)
313         if (S_ISSOCK(st.st_mode))
314                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
315 #endif
316         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
317                 return error;
318
319         return 0;
320 }
321
322
323 int
324 svr4_sys_fxstat(p, uap)
325         register struct proc *p;
326         struct svr4_sys_fxstat_args *uap;
327 {
328         struct stat             st;
329         struct svr4_xstat       svr4_st;
330         struct fstat_args       cup;
331         int                     error;
332
333         caddr_t sg = stackgap_init();
334
335         SCARG(&cup, fd) = SCARG(uap, fd);
336         SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
337
338         if ((error = fstat(p, &cup)) != 0)
339                 return error;
340
341         if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
342                 return error;
343
344         bsd_to_svr4_xstat(&st, &svr4_st);
345
346         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
347                 return error;
348
349         return 0;
350 }
351
352 int
353 svr4_sys_stat64(p, uap)
354         register struct proc *p;
355         struct svr4_sys_stat64_args *uap;
356 {
357         struct stat             st;
358         struct svr4_stat64      svr4_st;
359         struct stat_args        cup;
360         int                     error;
361         caddr_t                 sg = stackgap_init();
362
363         CHECKALTEXIST(p, &sg, SCARG(uap, path));
364
365         SCARG(&cup, path) = SCARG(uap, path);
366         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
367
368         if ((error = stat(p, &cup)) != 0)
369                 return error;
370
371         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
372                 return error;
373
374         bsd_to_svr4_stat64(&st, &svr4_st);
375
376         if (S_ISSOCK(st.st_mode))
377                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
378
379         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
380                 return error;
381
382         return 0;
383 }
384
385
386 int
387 svr4_sys_lstat64(p, uap)
388         register struct proc *p;
389         struct svr4_sys_lstat64_args *uap;
390 {
391         struct stat             st;
392         struct svr4_stat64      svr4_st;
393         struct stat_args        cup;
394         int                     error;
395         caddr_t                 sg = stackgap_init();
396
397         CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path));
398
399         SCARG(&cup, path) = SCARG(uap, path);
400         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
401
402         if ((error = lstat(p, (struct lstat_args *)&cup)) != 0)
403                 return error;
404
405         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
406                 return error;
407
408         bsd_to_svr4_stat64(&st, &svr4_st);
409
410         if (S_ISSOCK(st.st_mode))
411                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
412
413         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
414                 return error;
415
416         return 0;
417 }
418
419
420 int
421 svr4_sys_fstat64(p, uap)
422         register struct proc *p;
423         struct svr4_sys_fstat64_args *uap;
424 {
425         struct stat             st;
426         struct svr4_stat64      svr4_st;
427         struct fstat_args       cup;
428         int                     error;
429         caddr_t sg = stackgap_init();
430
431         SCARG(&cup, fd) = SCARG(uap, fd);
432         SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
433
434         if ((error = fstat(p, &cup)) != 0)
435                 return error;
436
437         if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
438                 return error;
439
440         bsd_to_svr4_stat64(&st, &svr4_st);
441
442         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
443                 return error;
444
445         return 0;
446 }
447
448
449 int
450 svr4_ustat(p, uap)
451         register struct proc *p;
452         struct svr4_ustat_args *uap;
453 {
454         struct svr4_ustat       us;
455         int                     error;
456
457         memset(&us, 0, sizeof us);
458
459         /*
460          * XXX: should set f_tfree and f_tinode at least
461          * How do we translate dev -> fstat? (and then to svr4_ustat)
462          */
463         if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
464                 return (error);
465
466         return 0;
467 }
468
469 /*extern char ostype[], hostname[], osrelease[], version[], machine[];*/
470
471 int
472 svr4_sys_uname(p, uap)
473         register struct proc *p;
474         struct svr4_sys_uname_args *uap;
475 {
476         struct svr4_utsname     sut;
477         
478
479         memset(&sut, 0, sizeof(sut));
480
481         strncpy(sut.sysname, ostype, sizeof(sut.sysname));
482         sut.sysname[sizeof(sut.sysname) - 1] = '\0';
483
484         strncpy(sut.nodename, hostname, sizeof(sut.nodename));
485         sut.nodename[sizeof(sut.nodename) - 1] = '\0';
486
487         strncpy(sut.release, osrelease, sizeof(sut.release));
488         sut.release[sizeof(sut.release) - 1] = '\0';
489
490         strncpy(sut.version, version, sizeof(sut.version));
491         sut.version[sizeof(sut.version) - 1] = '\0';
492
493         strncpy(sut.machine, machine, sizeof(sut.machine));
494         sut.machine[sizeof(sut.machine) - 1] = '\0';
495
496         return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
497                        sizeof(struct svr4_utsname));
498 }
499
500 int
501 svr4_sys_systeminfo(p, uap)
502         struct proc *p;
503         struct svr4_sys_systeminfo_args *uap;
504 {
505         char            *str = NULL;
506         int             error = 0;
507         register_t      *retval = p->p_retval;
508         size_t          len = 0;
509         char            buf[1];   /* XXX NetBSD uses 256, but that seems
510                                      like awfully excessive kstack usage
511                                      for an empty string... */
512         u_int           rlen = SCARG(uap, len);
513
514         switch (SCARG(uap, what)) {
515         case SVR4_SI_SYSNAME:
516                 str = ostype;
517                 break;
518
519         case SVR4_SI_HOSTNAME:
520                 str = hostname;
521                 break;
522
523         case SVR4_SI_RELEASE:
524                 str = osrelease;
525                 break;
526
527         case SVR4_SI_VERSION:
528                 str = version;
529                 break;
530
531         case SVR4_SI_MACHINE:
532                 str = machine;
533                 break;
534
535         case SVR4_SI_ARCHITECTURE:
536                 str = machine;
537                 break;
538
539         case SVR4_SI_HW_SERIAL:
540                 str = "0";
541                 break;
542
543         case SVR4_SI_HW_PROVIDER:
544                 str = ostype;
545                 break;
546
547         case SVR4_SI_SRPC_DOMAIN:
548                 str = domainname;
549                 break;
550
551         case SVR4_SI_PLATFORM:
552 #ifdef __i386__
553                 str = "i86pc";
554 #else
555                 str = "unknown";
556 #endif
557                 break;
558
559         case SVR4_SI_KERB_REALM:
560                 str = "unsupported";
561                 break;
562 #if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
563         case SVR4_SI_SET_HOSTNAME:
564                 if ((error = suser(p)) != 0)
565                         return error;
566                 name = KERN_HOSTNAME;
567                 return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
568
569         case SVR4_SI_SET_SRPC_DOMAIN:
570                 if ((error = suser(p)) != 0)
571                         return error;
572                 name = KERN_NISDOMAINNAME;
573                 return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
574 #else
575         case SVR4_SI_SET_HOSTNAME:
576         case SVR4_SI_SET_SRPC_DOMAIN:
577                 /* FALLTHROUGH */
578 #endif
579         case SVR4_SI_SET_KERB_REALM:
580                 return 0;
581
582         default:
583                 DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
584                 return ENOSYS;
585         }
586
587         if (str) {
588                 len = strlen(str) + 1;
589                 if (len > rlen)
590                         len = rlen;
591
592                 if (SCARG(uap, buf)) {
593                         error = copyout(str, SCARG(uap, buf), len);
594                         if (error)
595                                 return error;
596                         /* make sure we are NULL terminated */
597                         buf[0] = '\0';
598                         error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
599                 }
600                 else
601                         error = 0;
602         }
603         /* XXX NetBSD has hostname setting stuff here.  Why would an emulator
604            want to do that? */
605
606         *retval = len;
607         return error;
608 }
609
610 int
611 svr4_sys_utssys(p, uap)
612         register struct proc *p;
613         struct svr4_sys_utssys_args *uap;
614 {
615         switch (SCARG(uap, sel)) {
616         case 0:         /* uname(2)  */
617                 {
618                         struct svr4_sys_uname_args ua;
619                         SCARG(&ua, name) = SCARG(uap, a1);
620                         return svr4_sys_uname(p, &ua);
621                 }
622
623         case 2:         /* ustat(2)  */
624                 {
625                         struct svr4_ustat_args ua;
626                         SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
627                         SCARG(&ua, name) = SCARG(uap, a1);
628                         return svr4_ustat(p, &ua);
629                 }
630
631         case 3:         /* fusers(2) */
632                 return ENOSYS;
633
634         default:
635                 return ENOSYS;
636         }
637         return ENOSYS;
638 }
639
640
641 int
642 svr4_sys_utime(p, uap)
643         register struct proc *p;
644         struct svr4_sys_utime_args *uap;
645 {
646         struct svr4_utimbuf ub;
647         struct timeval tbuf[2];
648         struct utimes_args ap;
649         int error;
650         caddr_t sg = stackgap_init();
651         void *ttp;
652
653         CHECKALTEXIST(p, &sg, SCARG(uap, path));
654         SCARG(&ap, path) = SCARG(uap, path);
655         if (SCARG(uap, ubuf) != NULL) {
656                 if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
657                         return error;
658                 tbuf[0].tv_sec = ub.actime;
659                 tbuf[0].tv_usec = 0;
660                 tbuf[1].tv_sec = ub.modtime;
661                 tbuf[1].tv_usec = 0;
662                 ttp = stackgap_alloc(&sg, sizeof(tbuf));
663                 error = copyout(tbuf, ttp, sizeof(tbuf));
664                 if (error)
665                         return error;
666                 SCARG(&ap, tptr) = ttp;
667         }
668         else
669                 SCARG(&ap, tptr) = NULL;
670         return utimes(p, &ap);
671 }
672
673
674 int
675 svr4_sys_utimes(p, uap)
676         register struct proc *p;
677         struct svr4_sys_utimes_args *uap;
678 {
679         caddr_t sg = stackgap_init();
680         CHECKALTEXIST(p, &sg, SCARG(uap, path));
681         return utimes(p, (struct utimes_args *)uap);
682 }
683
684 static int
685 svr4_to_bsd_pathconf(name)
686         int name;
687 {
688         switch (name) {
689         case SVR4_PC_LINK_MAX:
690                 return _PC_LINK_MAX;
691
692         case SVR4_PC_MAX_CANON:
693                 return _PC_MAX_CANON;
694
695         case SVR4_PC_MAX_INPUT:
696                 return _PC_MAX_INPUT;
697
698         case SVR4_PC_NAME_MAX:
699                 return _PC_NAME_MAX;
700
701         case SVR4_PC_PATH_MAX:
702                 return _PC_PATH_MAX;
703
704         case SVR4_PC_PIPE_BUF:
705                 return _PC_PIPE_BUF;
706
707         case SVR4_PC_NO_TRUNC:
708                 return _PC_NO_TRUNC;
709
710         case SVR4_PC_VDISABLE:
711                 return _PC_VDISABLE;
712
713         case SVR4_PC_CHOWN_RESTRICTED:
714                 return _PC_CHOWN_RESTRICTED;
715         case SVR4_PC_SYNC_IO:
716 #if defined(_PC_SYNC_IO)
717                 return _PC_SYNC_IO;
718 #else
719                 return 0;
720 #endif
721         case SVR4_PC_ASYNC_IO:
722         case SVR4_PC_PRIO_IO:
723                 /* Not supported */
724                 return 0;
725
726         default:
727                 /* Invalid */
728                 return -1;
729         }
730 }
731
732
733 int
734 svr4_sys_pathconf(p, uap)
735         register struct proc *p;
736         struct svr4_sys_pathconf_args *uap;
737 {
738         caddr_t         sg = stackgap_init();
739         register_t      *retval = p->p_retval;
740
741         CHECKALTEXIST(p, &sg, SCARG(uap, path));
742
743         SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
744
745         switch (SCARG(uap, name)) {
746         case -1:
747                 *retval = -1;
748                 return EINVAL;
749         case 0:
750                 *retval = 0;
751                 return 0;
752         default:
753                 return pathconf(p, (struct pathconf_args *)uap);
754         }
755 }
756
757
758 int
759 svr4_sys_fpathconf(p, uap)
760         register struct proc *p;
761         struct svr4_sys_fpathconf_args *uap;
762 {
763         register_t      *retval = p->p_retval;
764
765         SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
766
767         switch (SCARG(uap, name)) {
768         case -1:
769                 *retval = -1;
770                 return EINVAL;
771         case 0:
772                 *retval = 0;
773                 return 0;
774         default:
775                 return fpathconf(p, (struct fpathconf_args *)uap);
776         }
777 }