etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / fpathconf.c
blob23f6f3f901c0e62121b2e64692bd5c2224dae0bc
1 /* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */
3 #include <sys/cdefs.h>
4 #include "namespace.h"
5 #include <lib.h>
7 #include <sys/stat.h>
8 #include <errno.h>
9 #include <limits.h>
10 #include <unistd.h>
11 #include <termios.h>
13 long fpathconf(fd, name)
14 int fd; /* file descriptor being interrogated */
15 int name; /* property being inspected */
17 /* POSIX allows some of the values in <limits.h> to be increased at
18 * run time. The pathconf and fpathconf functions allow these values
19 * to be checked at run time. MINIX does not use this facility.
20 * The run-time limits are those given in <limits.h>.
23 struct stat stbuf;
25 switch(name) {
26 case _PC_LINK_MAX:
27 /* Fstat the file. If that fails, return -1. */
28 if (fstat(fd, &stbuf) != 0) return(-1);
29 if (S_ISDIR(stbuf.st_mode))
30 return(1L); /* no links to directories */
31 else
32 return( (long) LINK_MAX);
34 case _PC_MAX_CANON:
35 return( (long) MAX_CANON);
37 case _PC_MAX_INPUT:
38 return( (long) MAX_INPUT);
40 case _PC_NAME_MAX:
41 return( (long) NAME_MAX);
43 case _PC_PATH_MAX:
44 return( (long) PATH_MAX);
46 case _PC_PIPE_BUF:
47 return( (long) PIPE_BUF);
49 case _PC_CHOWN_RESTRICTED:
50 return( (long) _POSIX_CHOWN_RESTRICTED);
52 case _PC_NO_TRUNC:
53 return( (long) _POSIX_NO_TRUNC);
55 case _PC_VDISABLE:
56 return( (long) _POSIX_VDISABLE);
58 default:
59 errno = EINVAL;
60 return(-1);