minix/lib/libc/sys-minix/fpathconf.c
Ben Gras 2fe8fb192f Full switch to clang/ELF. Drop ack. Simplify.
There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
2012-02-14 14:52:02 +01:00

67 lines
1.4 KiB
C

/* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <sys/stat.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#include <termios.h>
#ifdef __weak_alias
__weak_alias(fpathconf, _fpathconf)
#endif
PUBLIC long fpathconf(fd, name)
int fd; /* file descriptor being interrogated */
int name; /* property being inspected */
{
/* POSIX allows some of the values in <limits.h> to be increased at
* run time. The pathconf and fpathconf functions allow these values
* to be checked at run time. MINIX does not use this facility.
* The run-time limits are those given in <limits.h>.
*/
struct stat stbuf;
switch(name) {
case _PC_LINK_MAX:
/* Fstat the file. If that fails, return -1. */
if (fstat(fd, &stbuf) != 0) return(-1);
if (S_ISDIR(stbuf.st_mode))
return(1L); /* no links to directories */
else
return( (long) LINK_MAX);
case _PC_MAX_CANON:
return( (long) MAX_CANON);
case _PC_MAX_INPUT:
return( (long) MAX_INPUT);
case _PC_NAME_MAX:
return( (long) NAME_MAX);
case _PC_PATH_MAX:
return( (long) PATH_MAX);
case _PC_PIPE_BUF:
return( (long) PIPE_BUF);
case _PC_CHOWN_RESTRICTED:
return( (long) _POSIX_CHOWN_RESTRICTED);
case _PC_NO_TRUNC:
return( (long) _POSIX_NO_TRUNC);
case _PC_VDISABLE:
return( (long) _POSIX_VDISABLE);
default:
errno = EINVAL;
return(-1);
}
}