secondary cache feature in vm.
[minix.git] / lib / libc / posix / _fpathconf.c
blob72c45073c9d504d95dd7516b12e125f28576a579
1 /* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */
3 #include <lib.h>
4 #define fstat _fstat
5 #define fpathconf _fpathconf
6 #include <sys/stat.h>
7 #include <errno.h>
8 #include <limits.h>
9 #include <unistd.h>
10 #include <termios.h>
12 PUBLIC long fpathconf(fd, name)
13 int fd; /* file descriptor being interrogated */
14 int name; /* property being inspected */
16 /* POSIX allows some of the values in <limits.h> to be increased at
17 * run time. The pathconf and fpathconf functions allow these values
18 * to be checked at run time. MINIX does not use this facility.
19 * The run-time limits are those given in <limits.h>.
22 struct stat stbuf;
24 switch(name) {
25 case _PC_LINK_MAX:
26 /* Fstat the file. If that fails, return -1. */
27 if (fstat(fd, &stbuf) != 0) return(-1);
28 if (S_ISDIR(stbuf.st_mode))
29 return(1L); /* no links to directories */
30 else
31 return( (long) LINK_MAX);
33 case _PC_MAX_CANON:
34 return( (long) MAX_CANON);
36 case _PC_MAX_INPUT:
37 return( (long) MAX_INPUT);
39 case _PC_NAME_MAX:
40 return( (long) NAME_MAX);
42 case _PC_PATH_MAX:
43 return( (long) PATH_MAX);
45 case _PC_PIPE_BUF:
46 return( (long) PIPE_BUF);
48 case _PC_CHOWN_RESTRICTED:
49 return( (long) _POSIX_CHOWN_RESTRICTED);
51 case _PC_NO_TRUNC:
52 return( (long) _POSIX_NO_TRUNC);
54 case _PC_VDISABLE:
55 return( (long) _POSIX_VDISABLE);
57 default:
58 errno = EINVAL;
59 return(-1);