source: trunk/minix/lib/posix/_fpathconf.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.3 KB
Line 
1/* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */
2
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>
11
12PUBLIC long fpathconf(fd, name)
13int fd; /* file descriptor being interrogated */
14int name; /* property being inspected */
15{
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>.
20 */
21
22 struct stat stbuf;
23
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);
32
33 case _PC_MAX_CANON:
34 return( (long) MAX_CANON);
35
36 case _PC_MAX_INPUT:
37 return( (long) MAX_INPUT);
38
39 case _PC_NAME_MAX:
40 return( (long) NAME_MAX);
41
42 case _PC_PATH_MAX:
43 return( (long) PATH_MAX);
44
45 case _PC_PIPE_BUF:
46 return( (long) PIPE_BUF);
47
48 case _PC_CHOWN_RESTRICTED:
49 return( (long) _POSIX_CHOWN_RESTRICTED);
50
51 case _PC_NO_TRUNC:
52 return( (long) _POSIX_NO_TRUNC);
53
54 case _PC_VDISABLE:
55 return( (long) _POSIX_VDISABLE);
56
57 default:
58 errno = EINVAL;
59 return(-1);
60 }
61}
Note: See TracBrowser for help on using the repository browser.