#define SC_PAGESIZE 1 // Page size of the system. #define SC_OPEN_MAX 2 // Maximum amount of files per process. #define SC_HOST_NAME_MAX 3 // Maximum length of hostnames. #define SC_AVPHYS_PAGES 4 // Number of free physical pages. #define SC_PHYS_PAGES 5 // Number of total available pages. #define SC_NPROCESSORS_ONLN 6 // Number of processors active and used. #define SC_TOTAL_PAGES 7 // Total amount of installed memory pages. #define SC_LIST_PROCS 8 // List all processes of the system. #define SC_LIST_MOUNTS 9 // List all mountpoints of the system. #define SC_UNAME 10 // Fetch basic system information. #define SC_CHILD_MAX 11 // Maximum number of children for the user. #define SC_LIST_THREADS 12 // List all threads of the system. #define SC_LIST_CLUSTERS 13 // List all thread clusters of the system. #define SC_LIST_NETINTER 14 // List all network interfaces. #define SC_DUMPLOGS 15 // Dump kernel logging to a buffer. #define SC_NGROUPS_MAX 16 // Max number of supplementary groups. #define SC_SYMLOOP_MAX 17 // Max number of symbolic loops to follow. #define SC_LIST_FILELOCKS 18 // List all advisory file locks. #define SC_LOADAVG 19 // Dump load averages. #define SC_MEMINFO 20 // Dump memory information. long int sysconf(int request, uintptr_t addr, uintptr_t len);
This syscalls fetches the requested information in request
and returns
it.
Depending on the request, addr
and len
may be used for
determining the address of a buffer and its length for reporting information
that doesn’t fit on the usual return value. The options where they have meaning
are:
SC_LIST_PROCS
: addr
points to an array of items, and len
is the count of bytes reserved in the array. The items have the structure:
struct procinfo { char id[20]; uint16_t id_len; uint16_t ppid; uint16_t pid; uint32_t uid; uint32_t flags; } __attribute__((packed));
The total number of processes is returned, even if it doesnt fit in the passed array.
SC_LIST_MOUNTS
: addr
points to an array of items, and len
is the count of bytes reserved in the array. The items have the structure:
struct mountinfo { uint32_t fs_type; uint32_t flags; char source[20]; uint32_t source_len; char location[20]; uint32_t location_len; };
The total number of mounts is returned, even if it doesnt fit in the passed array.
SC_UNAME
: addr
points to the following structure, and len
is the length in bytes of said structure:
struct utsname { char sysname[65]; // Kernel name (e.g., "Ironclad") char nodename[65]; // Hostname of the machine. char release[65]; // Kernel release (e.g., "2.6.28") char version[65]; // Kernel release, again. char machine[65]; // Hardware identifier (e.g., "x86") };
In success, the returned value will be 0
.
SC_LIST_THREADS
: addr
points to an array of items, and len
is the count of bytes reserved in the array. The items have the structure:
struct threadinfo { uint16_t tid; int16_t niceness; uint16_t tcid; uint16_t pid; };
The total number of threads is returned, even if it doesnt fit in the passed array.
SC_LIST_CLUSTERS
: addr
points to an array of items, and
len
is the count of bytes reserved in the array. The items have the
structure:
struct tclusterinfo { uint16_t tcid; uint16_t tflags; uint16_t tquantum; };
The total number of thread clusters is returned, even if it doesnt fit in the passed array.
SC_LIST_NETINTER
: addr
points to an array of items, and
len
is the count of bytes reserved in the array. The items have the
structure:
struct netinterface { char device[64]; // null terminated. uint64_t flags; uint8_t mac_addr[6]; uint8_t ip4_addr[4]; uint8_t ip4_subnet[4]; uint8_t ip6_addr[16]; uint8_t ip6_subnet[16]; };
SC_DUMPLOGS
: addr
points to a string to store the buffer, which
is an array of 80-char long strings. len
is the length of the buffer.
The total length of the kernel buffer is returned, regardless of whether it
fits or not.
SC_LIST_FILELOCKS
: addr
points to an array of items, and
len
is the count of bytes reserved in the array. The items have the
structure:
struct flock_info { uint32_t pid; uint32_t mode; uint64_t start; uint64_t length; uint64_t dev_id; uint64_t inode; };
SC_LOADAVG
: addr
points to an array of at least 3 integers, and
len
is the count of bytes reserved in the array. The array has the
structure:
uint32_t array[3];
The values the number of threads in the system run queue averaged over various periods of time. The 3 samples correspond to the averages of 1, 5, and 15 minutes, respectively. It can be used as a measure of relative load. The values are to be divided by 100 before being used.
SC_MEMINFO
: len
is ignored and addr
points to a structure
as such:
struct mem_info { // All data is in bytes. uint64_t phys_total; // Total physical memory of the system. uint64_t phys_available; // Non-reserved memory managed by the system. uint64_t phys_free; // Free memory available to the system. uint64_t shared_usage; // Amount of shared memory in the system. uint64_t kernel_usage; // Amount of memory in use by the kernel. uint64_t table_usage; // Of the kernel, amount in use for page tables. uint64_t poison_usage; // Memory marked by the hardware as faulty. };
0
is returned on success.
The syscall return the requested information on success and -1
on
failure. If the requested value can also be -1
, errno must be checked.
The errno codes set on failure are:
EINVAL
: Invalid request.