Files
semi-libc/src/conf/fpathconf.c
T
Szabolcs Nagy b20760c023 support configurable page size on mips, powerpc and microblaze
PAGE_SIZE was hardcoded to 4096, which is historically what most
systems use, but on several archs it is a kernel config parameter,
user space can only know it at execution time from the aux vector.

PAGE_SIZE and PAGESIZE are not defined on archs where page size is
a runtime parameter, applications should use sysconf(_SC_PAGE_SIZE)
to query it. Internally libc code defines PAGE_SIZE to libc.page_size,
which is set to aux[AT_PAGESZ] in __init_libc and early in __dynlink
as well. (Note that libc.page_size can be accessed without GOT, ie.
before relocations are done)

Some fpathconf settings are hardcoded to 4096, these should be actually
queried from the filesystem using statfs.
2013-09-15 02:00:32 +00:00

36 lines
863 B
C

#include <unistd.h>
#include <limits.h>
#include <errno.h>
long fpathconf(int fd, int name)
{
static const short values[] = {
[_PC_LINK_MAX] = _POSIX_LINK_MAX,
[_PC_MAX_CANON] = _POSIX_MAX_CANON,
[_PC_MAX_INPUT] = _POSIX_MAX_INPUT,
[_PC_NAME_MAX] = NAME_MAX,
[_PC_PATH_MAX] = PATH_MAX,
[_PC_PIPE_BUF] = PIPE_BUF,
[_PC_CHOWN_RESTRICTED] = 1,
[_PC_NO_TRUNC] = 1,
[_PC_VDISABLE] = 0,
[_PC_SYNC_IO] = 1,
[_PC_ASYNC_IO] = -1,
[_PC_PRIO_IO] = -1,
[_PC_SOCK_MAXBUF] = -1,
[_PC_FILESIZEBITS] = FILESIZEBITS,
[_PC_REC_INCR_XFER_SIZE] = 4096,
[_PC_REC_MAX_XFER_SIZE] = 4096,
[_PC_REC_MIN_XFER_SIZE] = 4096,
[_PC_REC_XFER_ALIGN] = 4096,
[_PC_ALLOC_SIZE_MIN] = 4096,
[_PC_SYMLINK_MAX] = SYMLINK_MAX,
[_PC_2_SYMLINKS] = 1
};
if (name > sizeof(values)/sizeof(values[0])) {
errno = EINVAL;
return -1;
}
return values[name];
}