1*433d6423SLionel Sambuc /* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */ 2*433d6423SLionel Sambuc 3*433d6423SLionel Sambuc #include <sys/cdefs.h> 4*433d6423SLionel Sambuc #include "namespace.h" 5*433d6423SLionel Sambuc #include <lib.h> 6*433d6423SLionel Sambuc 7*433d6423SLionel Sambuc #include <sys/stat.h> 8*433d6423SLionel Sambuc #include <errno.h> 9*433d6423SLionel Sambuc #include <limits.h> 10*433d6423SLionel Sambuc #include <unistd.h> 11*433d6423SLionel Sambuc #include <termios.h> 12*433d6423SLionel Sambuc fpathconf(fd,name)13*433d6423SLionel Sambuclong fpathconf(fd, name) 14*433d6423SLionel Sambuc int fd; /* file descriptor being interrogated */ 15*433d6423SLionel Sambuc int name; /* property being inspected */ 16*433d6423SLionel Sambuc { 17*433d6423SLionel Sambuc /* POSIX allows some of the values in <limits.h> to be increased at 18*433d6423SLionel Sambuc * run time. The pathconf and fpathconf functions allow these values 19*433d6423SLionel Sambuc * to be checked at run time. MINIX does not use this facility. 20*433d6423SLionel Sambuc * The run-time limits are those given in <limits.h>. 21*433d6423SLionel Sambuc */ 22*433d6423SLionel Sambuc 23*433d6423SLionel Sambuc struct stat stbuf; 24*433d6423SLionel Sambuc 25*433d6423SLionel Sambuc switch(name) { 26*433d6423SLionel Sambuc case _PC_LINK_MAX: 27*433d6423SLionel Sambuc /* Fstat the file. If that fails, return -1. */ 28*433d6423SLionel Sambuc if (fstat(fd, &stbuf) != 0) return(-1); 29*433d6423SLionel Sambuc if (S_ISDIR(stbuf.st_mode)) 30*433d6423SLionel Sambuc return(1L); /* no links to directories */ 31*433d6423SLionel Sambuc else 32*433d6423SLionel Sambuc return( (long) LINK_MAX); 33*433d6423SLionel Sambuc 34*433d6423SLionel Sambuc case _PC_MAX_CANON: 35*433d6423SLionel Sambuc return( (long) MAX_CANON); 36*433d6423SLionel Sambuc 37*433d6423SLionel Sambuc case _PC_MAX_INPUT: 38*433d6423SLionel Sambuc return( (long) MAX_INPUT); 39*433d6423SLionel Sambuc 40*433d6423SLionel Sambuc case _PC_NAME_MAX: 41*433d6423SLionel Sambuc return( (long) NAME_MAX); 42*433d6423SLionel Sambuc 43*433d6423SLionel Sambuc case _PC_PATH_MAX: 44*433d6423SLionel Sambuc return( (long) PATH_MAX); 45*433d6423SLionel Sambuc 46*433d6423SLionel Sambuc case _PC_PIPE_BUF: 47*433d6423SLionel Sambuc return( (long) PIPE_BUF); 48*433d6423SLionel Sambuc 49*433d6423SLionel Sambuc case _PC_CHOWN_RESTRICTED: 50*433d6423SLionel Sambuc return( (long) _POSIX_CHOWN_RESTRICTED); 51*433d6423SLionel Sambuc 52*433d6423SLionel Sambuc case _PC_NO_TRUNC: 53*433d6423SLionel Sambuc return( (long) _POSIX_NO_TRUNC); 54*433d6423SLionel Sambuc 55*433d6423SLionel Sambuc case _PC_VDISABLE: 56*433d6423SLionel Sambuc return( (long) _POSIX_VDISABLE); 57*433d6423SLionel Sambuc 58*433d6423SLionel Sambuc default: 59*433d6423SLionel Sambuc errno = EINVAL; 60*433d6423SLionel Sambuc return(-1); 61*433d6423SLionel Sambuc } 62*433d6423SLionel Sambuc } 63