Wed Jul 3 16:29:41 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / sysdeps / posix / fpathconf.c
blob9b54b5f04aa18331e973e575781df6598e6c4e65
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
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
19 #include <ansidecl.h>
20 #include <errno.h>
21 #include <stddef.h>
22 #include <unistd.h>
23 #include <limits.h>
24 #include <sys/statfs.h>
27 /* Get file-specific information about descriptor FD. */
28 long int
29 DEFUN(__fpathconf, (fd, name), int fd AND int name)
31 if (fd < 0)
33 errno = EBADF;
34 return -1;
37 switch (name)
39 default:
40 errno = EINVAL;
41 return -1;
43 case _PC_LINK_MAX:
44 #ifdef LINK_MAX
45 return LINK_MAX;
46 #else
47 errno = ENOSYS;
48 return -1;
49 #endif
51 case _PC_MAX_CANON:
52 #ifdef MAX_CANON
53 return MAX_CANON;
54 #else
55 errno = ENOSYS;
56 return -1;
57 #endif
59 case _PC_MAX_INPUT:
60 #ifdef MAX_INPUT
61 return MAX_INPUT;
62 #else
63 errno = ENOSYS;
64 return -1;
65 #endif
67 case _PC_NAME_MAX:
68 #ifdef NAME_MAX
69 return NAME_MAX;
70 #else
71 errno = ENOSYS;
72 return -1;
73 #endif
75 case _PC_PATH_MAX:
76 #ifdef PATH_MAX
78 struct statfs buf;
80 if (__fstatfs (fd, &buf) < 0)
81 return errno == ENOSYS ? PATH_MAX : -1;
82 else
83 return buf.f_namelen;
85 #else
86 errno = ENOSYS;
87 return -1;
88 #endif
90 case _PC_PIPE_BUF:
91 #ifdef PIPE_BUF
92 return PIPE_BUF;
93 #else
94 errno = ENOSYS;
95 return -1;
96 #endif
98 case _PC_CHOWN_RESTRICTED:
99 #ifdef _POSIX_CHOWN_RESTRICTED
100 return _POSIX_CHOWN_RESTRICTED;
101 #else
102 return -1;
103 #endif
105 case _PC_NO_TRUNC:
106 #ifdef _POSIX_NO_TRUNC
107 return _POSIX_NO_TRUNC;
108 #else
109 return -1;
110 #endif
112 case _PC_VDISABLE:
113 #ifdef _POSIX_VDISABLE
114 return _POSIX_VDISABLE;
115 #else
116 return -1;
117 #endif
119 case _PC_SYNC_IO:
120 #ifdef _POSIX_SYNC_IO
121 return _POSIX_SYNC_IO;
122 #else
123 return -1;
124 #endif
126 case _PC_ASYNC_IO:
127 #ifdef _POSIX_ASYNC_IO
128 return _POSIX_ASYNC_IO;
129 #else
130 return -1;
131 #endif
133 case _PC_PRIO_IO:
134 #ifdef _POSIX_PRIO_IO
135 return _POSIX_PRIO_IO;
136 #else
137 return -1;
138 #endif
140 case _PC_SOCK_MAXBUF:
141 #ifdef SOCK_MAXBUF
142 return SOCK_MAXBUF;
143 #else
144 errno = ENOSYS;
145 return -1;
146 #endif
149 errno = ENOSYS;
150 return -1;
153 weak_alias (__fpathconf, fpathconf)