]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/posix/fpathconf.c
(\set, \value): Allow - and _ in @set variable names.
[thirdparty/glibc.git] / sysdeps / posix / fpathconf.c
CommitLineData
75cd5204 1/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
28f540f4
RM
2This file is part of the GNU C Library.
3
4The GNU C Library is free software; you can redistribute it and/or
5modify it under the terms of the GNU Library General Public License as
6published by the Free Software Foundation; either version 2 of the
7License, or (at your option) any later version.
8
9The GNU C Library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12Library General Public License for more details.
13
14You should have received a copy of the GNU Library General Public
15License along with the GNU C Library; see the file COPYING.LIB. If
16not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17Cambridge, MA 02139, USA. */
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. */
27long 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
c4029823 48 __set_errno (ENOSYS);
28f540f4
RM
49 return -1;
50#endif
51
52 case _PC_MAX_CANON:
53#ifdef MAX_CANON
54 return MAX_CANON;
55#else
c4029823 56 __set_errno (ENOSYS);
28f540f4
RM
57 return -1;
58#endif
59
60 case _PC_MAX_INPUT:
61#ifdef MAX_INPUT
62 return MAX_INPUT;
63#else
c4029823 64 __set_errno (ENOSYS);
28f540f4
RM
65 return -1;
66#endif
67
68 case _PC_NAME_MAX:
69#ifdef NAME_MAX
70 return NAME_MAX;
71#else
c4029823 72 __set_errno (ENOSYS);
28f540f4
RM
73 return -1;
74#endif
75
76 case _PC_PATH_MAX:
77#ifdef PATH_MAX
0e3426bb
RM
78 {
79 struct statfs buf;
80
81 if (__fstatfs (fd, &buf) < 0)
82 return errno == ENOSYS ? PATH_MAX : -1;
83 else
84 return buf.f_namelen;
85 }
28f540f4 86#else
c4029823 87 __set_errno (ENOSYS);
28f540f4
RM
88 return -1;
89#endif
90
91 case _PC_PIPE_BUF:
92#ifdef PIPE_BUF
93 return PIPE_BUF;
94#else
c4029823 95 __set_errno (ENOSYS);
28f540f4
RM
96 return -1;
97#endif
98
99 case _PC_CHOWN_RESTRICTED:
100#ifdef _POSIX_CHOWN_RESTRICTED
101 return _POSIX_CHOWN_RESTRICTED;
102#else
103 return -1;
104#endif
105
106 case _PC_NO_TRUNC:
107#ifdef _POSIX_NO_TRUNC
108 return _POSIX_NO_TRUNC;
109#else
110 return -1;
111#endif
112
113 case _PC_VDISABLE:
114#ifdef _POSIX_VDISABLE
115 return _POSIX_VDISABLE;
116#else
117 return -1;
118#endif
75cd5204
RM
119
120 case _PC_SYNC_IO:
121#ifdef _POSIX_SYNC_IO
122 return _POSIX_SYNC_IO;
123#else
124 return -1;
125#endif
126
127 case _PC_ASYNC_IO:
128#ifdef _POSIX_ASYNC_IO
129 return _POSIX_ASYNC_IO;
130#else
131 return -1;
132#endif
133
134 case _PC_PRIO_IO:
135#ifdef _POSIX_PRIO_IO
136 return _POSIX_PRIO_IO;
137#else
138 return -1;
139#endif
503054c0
RM
140
141 case _PC_SOCK_MAXBUF:
142#ifdef SOCK_MAXBUF
143 return SOCK_MAXBUF;
144#else
c4029823 145 __set_errno (ENOSYS);
503054c0
RM
146 return -1;
147#endif
28f540f4
RM
148 }
149
c4029823 150 __set_errno (ENOSYS);
28f540f4
RM
151 return -1;
152}
153
154weak_alias (__fpathconf, fpathconf)