Update.
[glibc.git] / sysdeps / posix / fpathconf.c
blob1a2c3742e961337c1cd978ecc12122e34922c1c7
1 /* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <errno.h>
20 #include <stddef.h>
21 #include <unistd.h>
22 #include <limits.h>
23 #include <sys/statfs.h>
26 /* Get file-specific information about descriptor FD. */
27 long int
28 __fpathconf (fd, name)
29 int fd;
30 int name;
32 if (fd < 0)
34 __set_errno (EBADF);
35 return -1;
38 switch (name)
40 default:
41 __set_errno (EINVAL);
42 return -1;
44 case _PC_LINK_MAX:
45 #ifdef LINK_MAX
46 return LINK_MAX;
47 #else
48 __set_errno (ENOSYS);
49 return -1;
50 #endif
52 case _PC_MAX_CANON:
53 #ifdef MAX_CANON
54 return MAX_CANON;
55 #else
56 __set_errno (ENOSYS);
57 return -1;
58 #endif
60 case _PC_MAX_INPUT:
61 #ifdef MAX_INPUT
62 return MAX_INPUT;
63 #else
64 __set_errno (ENOSYS);
65 return -1;
66 #endif
68 case _PC_NAME_MAX:
69 #ifdef NAME_MAX
71 struct statfs buf;
73 if (__fstatfs (fd, &buf) < 0)
74 return errno == ENOSYS ? NAME_MAX : -1;
75 else
76 return buf.f_namelen;
78 #else
79 __set_errno (ENOSYS);
80 return -1;
81 #endif
83 case _PC_PATH_MAX:
84 #ifdef PATH_MAX
85 return PATH_MAX;
86 #else
87 __set_errno (ENOSYS);
88 return -1;
89 #endif
91 case _PC_PIPE_BUF:
92 #ifdef PIPE_BUF
93 return PIPE_BUF;
94 #else
95 __set_errno (ENOSYS);
96 return -1;
97 #endif
99 case _PC_CHOWN_RESTRICTED:
100 #ifdef _POSIX_CHOWN_RESTRICTED
101 return _POSIX_CHOWN_RESTRICTED;
102 #else
103 return -1;
104 #endif
106 case _PC_NO_TRUNC:
107 #ifdef _POSIX_NO_TRUNC
108 return _POSIX_NO_TRUNC;
109 #else
110 return -1;
111 #endif
113 case _PC_VDISABLE:
114 #ifdef _POSIX_VDISABLE
115 return _POSIX_VDISABLE;
116 #else
117 return -1;
118 #endif
120 case _PC_SYNC_IO:
121 #ifdef _POSIX_SYNC_IO
122 return _POSIX_SYNC_IO;
123 #else
124 return -1;
125 #endif
127 case _PC_ASYNC_IO:
128 #ifdef _POSIX_ASYNC_IO
129 return _POSIX_ASYNC_IO;
130 #else
131 return -1;
132 #endif
134 case _PC_PRIO_IO:
135 #ifdef _POSIX_PRIO_IO
136 return _POSIX_PRIO_IO;
137 #else
138 return -1;
139 #endif
141 case _PC_SOCK_MAXBUF:
142 #ifdef SOCK_MAXBUF
143 return SOCK_MAXBUF;
144 #else
145 __set_errno (ENOSYS);
146 return -1;
147 #endif
150 __set_errno (ENOSYS);
151 return -1;
154 weak_alias (__fpathconf, fpathconf)