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>
30 #ifndef __USE_FILE_OFFSET64
31 extern int fstatfs (int __fildes
, struct statfs
*__buf
)
32 __THROW
__nonnull ((2));
34 # ifdef __REDIRECT_NTH
35 extern int __REDIRECT_NTH (fstatfs
, (int __fildes
, struct statfs
*__buf
),
36 fstatfs64
) __nonnull ((2));
38 # define fstatfs fstatfs64
42 extern __typeof(fstatfs
) __libc_fstatfs
;
44 /* The Linux kernel headers mention this as a kind of generic value. */
45 #define LINUX_LINK_MAX 127
48 /* Get file-specific information about descriptor FD. */
49 long int fpathconf(int fd
, int name
)
57 if (name
== _PC_LINK_MAX
)
59 /* Cut some corners */
63 /* Determine the filesystem type. */
64 if (__libc_fstatfs (fd
, &fsbuf
) < 0)
67 /* not possible, return the default value. */
68 return LINUX_LINK_MAX
;
70 /* Some error occured. */
76 case EXT2_SUPER_MAGIC
:
79 case MINIX_SUPER_MAGIC
:
80 case MINIX_SUPER_MAGIC2
:
81 return MINIX_LINK_MAX
;
83 case MINIX2_SUPER_MAGIC
:
84 case MINIX2_SUPER_MAGIC2
:
85 return MINIX2_LINK_MAX
;
87 case XENIX_SUPER_MAGIC
:
88 return XENIX_LINK_MAX
;
90 case SYSV4_SUPER_MAGIC
:
91 case SYSV2_SUPER_MAGIC
:
101 case REISERFS_SUPER_MAGIC
:
102 return REISERFS_LINK_MAX
;
105 return LINUX_LINK_MAX
;
108 return LINUX_LINK_MAX
;
115 __set_errno (EINVAL
);
136 int save_errno
= errno
;
138 if (__libc_fstatfs (fd
, &buf
) < 0)
149 #ifdef _STATFS_F_NAMELEN
150 return buf
.f_namelen
;
152 # ifdef _STATFS_F_NAME_MAX
153 return buf
.f_name_max
;
178 case _PC_CHOWN_RESTRICTED
:
179 #ifdef _POSIX_CHOWN_RESTRICTED
180 return _POSIX_CHOWN_RESTRICTED
;
186 #ifdef _POSIX_NO_TRUNC
187 return _POSIX_NO_TRUNC
;
193 #ifdef _POSIX_VDISABLE
194 return _POSIX_VDISABLE
;
200 #ifdef _POSIX_SYNC_IO
201 return _POSIX_SYNC_IO
;
207 #if defined _POSIX_ASYNC_IO
209 /* AIO is only allowed on regular files and block devices. */
212 if (FSTAT (fd
, &st
) < 0 || (! S_ISREG (st
.st_mode
) && ! S_ISBLK (st
.st_mode
)))
222 #ifdef _POSIX_PRIO_IO
223 return _POSIX_PRIO_IO
;
228 case _PC_SOCK_MAXBUF
:
235 case _PC_FILESIZEBITS
:
239 /* We let platforms with larger file sizes overwrite this value. */
243 /* Be lazy -- skip these */
244 case _PC_REC_INCR_XFER_SIZE
:
245 case _PC_REC_MAX_XFER_SIZE
:
246 case _PC_REC_MIN_XFER_SIZE
:
247 case _PC_REC_XFER_ALIGN
:
248 case _PC_ALLOC_SIZE_MIN
:
249 case _PC_SYMLINK_MAX
: