libc, libutil: remove compat hacks
[minix.git] / lib / libc / sys-minix / fpathconf.c
blobcc4b8a0836565c371c2137aa9f0e4e66dccb3814
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 #ifdef __weak_alias
14 __weak_alias(fpathconf, _fpathconf)
15 #endif
17 long fpathconf(fd, name)
18 int fd; /* file descriptor being interrogated */
19 int name; /* property being inspected */
21 /* POSIX allows some of the values in <limits.h> to be increased at
22 * run time. The pathconf and fpathconf functions allow these values
23 * to be checked at run time. MINIX does not use this facility.
24 * The run-time limits are those given in <limits.h>.
27 struct stat stbuf;
29 switch(name) {
30 case _PC_LINK_MAX:
31 /* Fstat the file. If that fails, return -1. */
32 if (fstat(fd, &stbuf) != 0) return(-1);
33 if (S_ISDIR(stbuf.st_mode))
34 return(1L); /* no links to directories */
35 else
36 return( (long) LINK_MAX);
38 case _PC_MAX_CANON:
39 return( (long) MAX_CANON);
41 case _PC_MAX_INPUT:
42 return( (long) MAX_INPUT);
44 case _PC_NAME_MAX:
45 return( (long) NAME_MAX);
47 case _PC_PATH_MAX:
48 return( (long) PATH_MAX);
50 case _PC_PIPE_BUF:
51 return( (long) PIPE_BUF);
53 case _PC_CHOWN_RESTRICTED:
54 return( (long) _POSIX_CHOWN_RESTRICTED);
56 case _PC_NO_TRUNC:
57 return( (long) _POSIX_NO_TRUNC);
59 case _PC_VDISABLE:
60 return( (long) _POSIX_VDISABLE);
62 default:
63 errno = EINVAL;
64 return(-1);