pathconf.c 706 B

123456789101112131415161718192021222324252627
  1. /* POSIX pathconf (Sec. 5.7.1) Author: Andy Tanenbaum */
  2. #include <lib.h>
  3. #include <sys/types.h>
  4. #define open _open
  5. #include <fcntl.h>
  6. #include <errno.h>
  7. #define close _close
  8. PUBLIC long pathconf(path, name)
  9. char *path; /* name of file being interrogated */
  10. int name; /* property being inspected */
  11. {
  12. /* POSIX allows some of the values in <limits.h> to be increased at
  13. * run time. The pathconf and fpathconf functions allow these values
  14. * to be checked at run time. MINIX does not use this facility.
  15. * The run-time limits are those given in <limits.h>.
  16. */
  17. int fd;
  18. long val;
  19. if ( (fd = open(path, O_RDONLY)) < 0) return(-1L);
  20. val = fpathconf(fd, name);
  21. close(fd);
  22. return(val);
  23. }