fpathconf.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Get file-specific information about descriptor FD. Linux version.
  2. Copyright (C) 1991-2019 Free Software Foundation, Inc.
  3. 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 Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <fcntl.h>
  16. #include "pathconf.h"
  17. static long int posix_fpathconf (int fd, int name);
  18. /* Define this first, so it can be inlined. */
  19. #define __fpathconf static posix_fpathconf
  20. #include <sysdeps/posix/fpathconf.c>
  21. /* Get file-specific information about descriptor FD. */
  22. long int
  23. __fpathconf (int fd, int name)
  24. {
  25. struct statfs fsbuf;
  26. switch (name)
  27. {
  28. case _PC_LINK_MAX:
  29. return __statfs_link_max (__fstatfs (fd, &fsbuf), &fsbuf, NULL, fd);
  30. case _PC_FILESIZEBITS:
  31. return __statfs_filesize_max (__fstatfs (fd, &fsbuf), &fsbuf);
  32. case _PC_2_SYMLINKS:
  33. return __statfs_symlinks (__fstatfs (fd, &fsbuf), &fsbuf);
  34. case _PC_CHOWN_RESTRICTED:
  35. return __statfs_chown_restricted (__fstatfs (fd, &fsbuf), &fsbuf);
  36. default:
  37. return posix_fpathconf (fd, name);
  38. }
  39. }