1 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Written 11 April 1996 by Andries Brouwer <aeb@cwi.nl>
26 .\" 960412: Added comments from Stephen Tweedie
27 .\" Modified Tue Oct 22 22:28:41 1996 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified Mon Jan 5 20:31:04 1998 by aeb.
30 .TH SYSCTL 2 2019-03-06 "Linux" "Linux Programmer's Manual"
32 sysctl \- read/write system parameters
35 .B #include <unistd.h>
36 .B #include <linux/sysctl.h>
38 .BI "int _sysctl(struct __sysctl_args *" args );
42 There is no glibc wrapper for this system call; see NOTES.
44 .B Do not use this system call!
49 call reads and/or writes kernel parameters.
50 For example, the hostname,
51 or the maximum number of open files.
52 The argument has the form
56 struct __sysctl_args {
57 int *name; /* integer vector describing variable */
58 int nlen; /* length of this vector */
59 void *oldval; /* 0 or address where to store old value */
60 size_t *oldlenp; /* available room for old value,
61 overwritten by actual size of old value */
62 void *newval; /* 0 or address of new value */
63 size_t newlen; /* size of new value */
68 This call does a search in a tree structure, possibly resembling
69 a directory tree under
71 and if the requested item is found calls some appropriate routine
72 to read or modify the value.
74 Upon successful completion,
77 Otherwise, a value of \-1 is returned and
79 is set to indicate the error.
83 No search permission for one of the encountered "directories",
84 or no read permission where
86 was nonzero, or no write permission where
91 The invocation asked for the previous value by setting
93 non-NULL, but allowed zero room in
100 This call is Linux-specific, and should not be used in programs
101 intended to be portable.
104 call has been present in Linux since version 1.3.57.
109 mirror, and the object naming schemes differ between Linux and 4.4BSD,
110 but the declaration of the
112 function is the same in both.
114 Glibc does not provide a wrapper for this system call; call it using
119 use of this system call has long been discouraged,
120 and it is so unloved that
121 \fBit is likely to disappear in a future kernel version\fP.
122 .\" See http://lwn.net/Articles/247243/
124 uses of this system call result in warnings in the kernel log.
125 .\" Though comments in suggest that it is needed by old glibc binaries,
126 .\" so maybe it's not going away.
127 Remove it from your programs now; use the
131 This system call is available only if the kernel was configured with the
132 .B CONFIG_SYSCTL_SYSCALL
135 The object names vary between kernel versions,
136 making this system call worthless for applications.
138 Not all available objects are properly documented.
140 It is not yet possible to change operating system by writing to
141 .IR /proc/sys/kernel/ostype .
146 #include <sys/syscall.h>
150 #include <linux/sysctl.h>
152 int _sysctl(struct __sysctl_args *args );
159 struct __sysctl_args args;
160 char osname[OSNAMESZ];
162 int name[] = { CTL_KERN, KERN_OSTYPE };
164 memset(&args, 0, sizeof(struct __sysctl_args));
166 args.nlen = sizeof(name)/sizeof(name[0]);
167 args.oldval = osname;
168 args.oldlenp = &osnamelth;
170 osnamelth = sizeof(osname);
172 if (syscall(SYS__sysctl, &args) == \-1) {
176 printf("This machine is running %*s\en", osnamelth, osname);