1 /* fpathconf -- adjusted for busybox
2 Copyright (C) 1991,95,96,98,99,2000,2001 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
25 #include <sys/statfs.h>
28 #ifndef __USE_FILE_OFFSET64
29 extern int fstatfs (int __fildes
, struct statfs
*__buf
)
30 __THROW
__nonnull ((2));
32 # ifdef __REDIRECT_NTH
33 extern int __REDIRECT_NTH (fstatfs
, (int __fildes
, struct statfs
*__buf
),
34 fstatfs64
) __nonnull ((2));
36 # define fstatfs fstatfs64
40 extern __typeof(fstatfs
) __libc_fstatfs
;
42 /* The Linux kernel headers mention this as a kind of generic value. */
43 #define LINUX_LINK_MAX 127
46 /* Get file-specific information about descriptor FD. */
47 long int fpathconf(int fd
, int name
)
55 if (name
== _PC_LINK_MAX
)
57 /* Cut some corners */
61 /* Determine the filesystem type. */
62 if (__libc_fstatfs (fd
, &fsbuf
) < 0)
65 /* not possible, return the default value. */
66 return LINUX_LINK_MAX
;
68 /* Some error occured. */
74 case EXT2_SUPER_MAGIC
:
77 case MINIX_SUPER_MAGIC
:
78 case MINIX_SUPER_MAGIC2
:
79 return MINIX_LINK_MAX
;
81 case MINIX2_SUPER_MAGIC
:
82 case MINIX2_SUPER_MAGIC2
:
83 return MINIX2_LINK_MAX
;
85 case XENIX_SUPER_MAGIC
:
86 return XENIX_LINK_MAX
;
88 case SYSV4_SUPER_MAGIC
:
89 case SYSV2_SUPER_MAGIC
:
99 case REISERFS_SUPER_MAGIC
:
100 return REISERFS_LINK_MAX
;
103 return LINUX_LINK_MAX
;
106 return LINUX_LINK_MAX
;
113 __set_errno (EINVAL
);
134 int save_errno
= errno
;
136 if (__libc_fstatfs (fd
, &buf
) < 0)
147 #ifdef _STATFS_F_NAMELEN
148 return buf
.f_namelen
;
150 # ifdef _STATFS_F_NAME_MAX
151 return buf
.f_name_max
;
176 case _PC_CHOWN_RESTRICTED
:
177 #ifdef _POSIX_CHOWN_RESTRICTED
178 return _POSIX_CHOWN_RESTRICTED
;
184 #ifdef _POSIX_NO_TRUNC
185 return _POSIX_NO_TRUNC
;
191 #ifdef _POSIX_VDISABLE
192 return _POSIX_VDISABLE
;
198 #ifdef _POSIX_SYNC_IO
199 return _POSIX_SYNC_IO
;
205 #if defined _POSIX_ASYNC_IO
207 /* AIO is only allowed on regular files and block devices. */
210 if (fstat (fd
, &st
) < 0 || (! S_ISREG (st
.st_mode
) && ! S_ISBLK (st
.st_mode
)))
220 #ifdef _POSIX_PRIO_IO
221 return _POSIX_PRIO_IO
;
226 case _PC_SOCK_MAXBUF
:
233 case _PC_FILESIZEBITS
:
237 /* We let platforms with larger file sizes overwrite this value. */
241 /* Be lazy -- skip these */
242 case _PC_REC_INCR_XFER_SIZE
:
243 case _PC_REC_MAX_XFER_SIZE
:
244 case _PC_REC_MIN_XFER_SIZE
:
245 case _PC_REC_XFER_ALIGN
:
246 case _PC_ALLOC_SIZE_MIN
:
247 case _PC_SYMLINK_MAX
: