]>
Commit | Line | Data |
---|---|---|
e918a7fe | 1 | /* Copyright (C) 1991, 1995, 1996, 1998 Free Software Foundation, Inc. |
68dbb3a6 | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
68dbb3a6 UD |
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. | |
28f540f4 | 8 | |
68dbb3a6 UD |
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. | |
28f540f4 | 13 | |
68dbb3a6 UD |
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. */ | |
28f540f4 | 18 | |
28f540f4 RM |
19 | #include <errno.h> |
20 | #include <stddef.h> | |
21 | #include <unistd.h> | |
22 | #include <limits.h> | |
0e3426bb | 23 | #include <sys/statfs.h> |
28f540f4 RM |
24 | |
25 | ||
26 | /* Get file-specific information about descriptor FD. */ | |
27 | long int | |
c4029823 UD |
28 | __fpathconf (fd, name) |
29 | int fd; | |
30 | int name; | |
28f540f4 RM |
31 | { |
32 | if (fd < 0) | |
33 | { | |
c4029823 | 34 | __set_errno (EBADF); |
28f540f4 RM |
35 | return -1; |
36 | } | |
37 | ||
38 | switch (name) | |
39 | { | |
40 | default: | |
c4029823 | 41 | __set_errno (EINVAL); |
28f540f4 RM |
42 | return -1; |
43 | ||
44 | case _PC_LINK_MAX: | |
45 | #ifdef LINK_MAX | |
46 | return LINK_MAX; | |
47 | #else | |
28f540f4 RM |
48 | return -1; |
49 | #endif | |
50 | ||
51 | case _PC_MAX_CANON: | |
52 | #ifdef MAX_CANON | |
53 | return MAX_CANON; | |
54 | #else | |
28f540f4 RM |
55 | return -1; |
56 | #endif | |
57 | ||
58 | case _PC_MAX_INPUT: | |
59 | #ifdef MAX_INPUT | |
60 | return MAX_INPUT; | |
61 | #else | |
28f540f4 RM |
62 | return -1; |
63 | #endif | |
64 | ||
65 | case _PC_NAME_MAX: | |
66 | #ifdef NAME_MAX | |
0e3426bb RM |
67 | { |
68 | struct statfs buf; | |
2eb45444 | 69 | int save_errno = errno; |
0e3426bb RM |
70 | |
71 | if (__fstatfs (fd, &buf) < 0) | |
2eb45444 UD |
72 | { |
73 | if (errno == ENOSYS) | |
74 | { | |
9271a050 | 75 | __set_errno (save_errno); |
2eb45444 UD |
76 | return NAME_MAX; |
77 | } | |
9271a050 UD |
78 | else if (errno == ENODEV) |
79 | __set_errno (EINVAL); | |
80 | ||
2eb45444 UD |
81 | return -1; |
82 | } | |
0e3426bb RM |
83 | else |
84 | return buf.f_namelen; | |
85 | } | |
2303f5fd | 86 | #else |
2303f5fd UD |
87 | return -1; |
88 | #endif | |
89 | ||
90 | case _PC_PATH_MAX: | |
91 | #ifdef PATH_MAX | |
92 | return PATH_MAX; | |
28f540f4 | 93 | #else |
28f540f4 RM |
94 | return -1; |
95 | #endif | |
96 | ||
97 | case _PC_PIPE_BUF: | |
98 | #ifdef PIPE_BUF | |
99 | return PIPE_BUF; | |
100 | #else | |
28f540f4 RM |
101 | return -1; |
102 | #endif | |
103 | ||
104 | case _PC_CHOWN_RESTRICTED: | |
105 | #ifdef _POSIX_CHOWN_RESTRICTED | |
106 | return _POSIX_CHOWN_RESTRICTED; | |
107 | #else | |
108 | return -1; | |
109 | #endif | |
110 | ||
111 | case _PC_NO_TRUNC: | |
112 | #ifdef _POSIX_NO_TRUNC | |
113 | return _POSIX_NO_TRUNC; | |
114 | #else | |
115 | return -1; | |
116 | #endif | |
117 | ||
118 | case _PC_VDISABLE: | |
119 | #ifdef _POSIX_VDISABLE | |
120 | return _POSIX_VDISABLE; | |
121 | #else | |
122 | return -1; | |
123 | #endif | |
75cd5204 RM |
124 | |
125 | case _PC_SYNC_IO: | |
126 | #ifdef _POSIX_SYNC_IO | |
127 | return _POSIX_SYNC_IO; | |
128 | #else | |
129 | return -1; | |
130 | #endif | |
131 | ||
132 | case _PC_ASYNC_IO: | |
133 | #ifdef _POSIX_ASYNC_IO | |
134 | return _POSIX_ASYNC_IO; | |
135 | #else | |
136 | return -1; | |
137 | #endif | |
138 | ||
139 | case _PC_PRIO_IO: | |
140 | #ifdef _POSIX_PRIO_IO | |
141 | return _POSIX_PRIO_IO; | |
142 | #else | |
143 | return -1; | |
144 | #endif | |
503054c0 RM |
145 | |
146 | case _PC_SOCK_MAXBUF: | |
147 | #ifdef SOCK_MAXBUF | |
148 | return SOCK_MAXBUF; | |
149 | #else | |
503054c0 RM |
150 | return -1; |
151 | #endif | |
e918a7fe UD |
152 | |
153 | case _PC_FILESIZEBITS: | |
154 | #ifdef FILESIZEBITS | |
155 | return FILESIZEBITS; | |
156 | #else | |
157 | /* We let platforms with larger file sizes overwrite this value. */ | |
158 | return 32; | |
159 | #endif | |
28f540f4 | 160 | } |
28f540f4 RM |
161 | } |
162 | ||
e918a7fe | 163 | #undef __fpathconf |
28f540f4 | 164 | weak_alias (__fpathconf, fpathconf) |