home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / __fpathconf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-30  |  2.5 KB  |  132 lines

  1. /* Copyright (C) 1991 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  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.
  8.  
  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.
  13.  
  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.  */
  18.  
  19. #include <ansidecl.h>
  20. #include <errno.h>
  21. #include <stddef.h>
  22. #include <unistd.h>
  23. #include <stdlib.h>
  24. #include <limits.h>
  25. #ifdef __linux__
  26. #include <sys/vfs.h>
  27. #endif
  28.  
  29.  
  30. /* Get file-specific information about descriptor FD.  */
  31. long int
  32. DEFUN(__fpathconf, (fd, name), int fd AND int name)
  33. {
  34.   if (fd < 0)
  35.     {
  36.       errno = EBADF;
  37.       return -1;
  38.     }
  39.  
  40.   switch (name)
  41.     {
  42.     default:
  43.       errno = EINVAL;
  44.       return -1;
  45.  
  46.     case _PC_LINK_MAX:
  47. #ifdef    LINK_MAX
  48.       return LINK_MAX;
  49. #else
  50.       errno = ENOSYS;
  51.       return -1;
  52. #endif
  53.  
  54.     case _PC_MAX_CANON:
  55. #ifdef    MAX_CANON
  56.       return MAX_CANON;
  57. #else
  58.       errno = ENOSYS;
  59.       return -1;
  60. #endif
  61.  
  62.     case _PC_MAX_INPUT:
  63. #ifdef    MAX_INPUT
  64.       return MAX_INPUT;
  65. #else
  66.       errno = ENOSYS;
  67.       return -1;
  68. #endif
  69.  
  70.     case _PC_NAME_MAX:
  71. #ifdef __linux__
  72.       {
  73.         struct statfs buf;
  74.     if (__fstatfs (fd, &buf) < 0) return -1;
  75.     else return buf.f_namelen;
  76.       }
  77. #else
  78. #ifdef    NAME_MAX
  79.       return NAME_MAX;
  80. #else
  81.       errno = ENOSYS;
  82.       return -1;
  83. #endif
  84. #endif
  85.  
  86.     case _PC_PATH_MAX:
  87. #ifdef    PATH_MAX
  88.       return PATH_MAX;
  89. #else
  90.       errno = ENOSYS;
  91.       return -1;
  92. #endif
  93.  
  94.     case _PC_PIPE_BUF:
  95. #ifdef    PIPE_BUF
  96.       return PIPE_BUF;
  97. #else
  98.       errno = ENOSYS;
  99.       return -1;
  100. #endif
  101.  
  102.     case _PC_CHOWN_RESTRICTED:
  103. #ifdef    _POSIX_CHOWN_RESTRICTED
  104.       return _POSIX_CHOWN_RESTRICTED;
  105. #else
  106.       return -1;
  107. #endif
  108.  
  109.     case _PC_NO_TRUNC:
  110. #ifdef    _POSIX_NO_TRUNC
  111.       return _POSIX_NO_TRUNC;
  112. #else
  113.       return -1;
  114. #endif
  115.  
  116.     case _PC_VDISABLE:
  117. #ifdef    _POSIX_VDISABLE
  118.       return _POSIX_VDISABLE;
  119. #else
  120.       return -1;
  121. #endif
  122.     }
  123.  
  124.   errno = ENOSYS;
  125.   return -1;
  126. }
  127.  
  128. #include <gnu-stabs.h>
  129. #ifdef weak_alias
  130. weak_alias (__fpathconf, fpathconf);
  131. #endif
  132.