1sysctl(2) System Calls Manual sysctl(2)
2
3
4
6 sysctl - read/write system parameters
7
9 #include <unistd.h>
10 #include <linux/sysctl.h>
11
12 [[deprecated]] int _sysctl(struct __sysctl_args *args);
13
15 This system call no longer exists on current kernels! See NOTES.
16
17 The _sysctl() call reads and/or writes kernel parameters. For example,
18 the hostname, or the maximum number of open files. The argument has
19 the form
20
21 struct __sysctl_args {
22 int *name; /* integer vector describing variable */
23 int nlen; /* length of this vector */
24 void *oldval; /* 0 or address where to store old value */
25 size_t *oldlenp; /* available room for old value,
26 overwritten by actual size of old value */
27 void *newval; /* 0 or address of new value */
28 size_t newlen; /* size of new value */
29 };
30
31 This call does a search in a tree structure, possibly resembling a di‐
32 rectory tree under /proc/sys, and if the requested item is found calls
33 some appropriate routine to read or modify the value.
34
36 Upon successful completion, _sysctl() returns 0. Otherwise, a value of
37 -1 is returned and errno is set to indicate the error.
38
40 EACCES, EPERM
41 No search permission for one of the encountered "directories",
42 or no read permission where oldval was nonzero, or no write per‐
43 mission where newval was nonzero.
44
45 EFAULT The invocation asked for the previous value by setting oldval
46 non-NULL, but allowed zero room in oldlenp.
47
48 ENOTDIR
49 name was not found.
50
52 Linux.
53
55 Linux 1.3.57. Removed in Linux 5.5, glibc 2.32.
56
57 It originated in 4.4BSD. Only Linux has the /proc/sys mirror, and the
58 object naming schemes differ between Linux and 4.4BSD, but the declara‐
59 tion of the sysctl() function is the same in both.
60
62 Use of this system call was long discouraged: since Linux 2.6.24, uses
63 of this system call result in warnings in the kernel log, and in Linux
64 5.5, the system call was finally removed. Use the /proc/sys interface
65 instead.
66
67 Note that on older kernels where this system call still exists, it is
68 available only if the kernel was configured with the CON‐
69 FIG_SYSCTL_SYSCALL option. Furthermore, glibc does not provide a wrap‐
70 per for this system call, necessitating the use of syscall(2).
71
73 The object names vary between kernel versions, making this system call
74 worthless for applications.
7