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 2012-12-22 "Linux" "Linux Programmer's Manual"
32 sysctl \- read/write system parameters
35 .B #include <unistd.h>
37 .B #include <linux/sysctl.h>
39 .BI "int _sysctl(struct __sysctl_args *" args );
43 There is no glibc wrapper for this system call; see NOTES.
45 .B Do not use this system call!
50 call reads and/or writes kernel parameters.
51 For example, the hostname,
52 or the maximum number of open files.
53 The argument has the form
57 struct __sysctl_args {
58 int *name; /* integer vector describing variable */
59 int nlen; /* length of this vector */
60 void *oldval; /* 0 or address where to store old value */
61 size_t *oldlenp; /* available room for old value,
62 overwritten by actual size of old value */
63 void *newval; /* 0 or address of new value */
64 size_t newlen; /* size of new value */
69 This call does a search in a tree structure, possibly resembling
70 a directory tree under
72 and if the requested item is found calls some appropriate routine
73 to read or modify the value.
75 Upon successful completion,
78 Otherwise, a value of \-1 is returned and
80 is set to indicate the error.
84 The invocation asked for the previous value by setting
86 non-NULL, but allowed zero room in
94 No search permission for one of the encountered "directories",
95 or no read permission where
97 was nonzero, or no write permission where
101 This call is Linux-specific, and should not be used in programs
102 intended to be portable.
105 call has been present in Linux since version 1.3.57.
110 mirror, and the object naming schemes differ between Linux and 4.4BSD,
111 but the declaration of the
113 function is the same in both.
115 Glibc does not provide a wrapper for this system call; call it using
120 use of this system call has long been discouraged,
121 and it is so unloved that
122 \fBit is likely to disappear in a future kernel version\fP.
123 .\" See http://lwn.net/Articles/247243/
125 uses of this system call result in warnings in the kernel log.
126 .\" Though comments in suggest that it is needed by old glibc binaries,
127 .\" so maybe it's not going away.
128 Remove it from your programs now; use the
132 This system call is available only if the kernel was configured with the
133 .B CONFIG_SYSCTL_SYSCALL
136 The object names vary between kernel versions,
137 making this system call worthless for applications.
139 Not all available objects are properly documented.
141 It is not yet possible to change operating system by writing to
142 .IR /proc/sys/kernel/ostype .
147 #include <sys/syscall.h>
151 #include <linux/sysctl.h>
153 int _sysctl(struct __sysctl_args *args );
160 struct __sysctl_args args;
161 char osname[OSNAMESZ];
163 int name[] = { CTL_KERN, KERN_OSTYPE };
165 memset(&args, 0, sizeof(struct __sysctl_args));
167 args.nlen = sizeof(name)/sizeof(name[0]);
168 args.oldval = osname;
169 args.oldlenp = &osnamelth;
171 osnamelth = sizeof(osname);
173 if (syscall(SYS__sysctl, &args) == \-1) {
177 printf("This machine is running %*s\\n", osnamelth, osname);
184 This page is part of release 3.79 of the Linux
187 A description of the project,
188 information about reporting bugs,
189 and the latest version of this page,
191 \%http://www.kernel.org/doc/man\-pages/.