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 .\"*******************************************************************
32 .\" This file was generated with po4a. Translate the source file.
34 .\"*******************************************************************
35 .TH SYSCTL 2 2012\-12\-22 Linux "Linux Programmer's Manual"
37 sysctl \- システム・パラメーターを読み書きする
40 \fB#include <unistd.h>\fP
42 \fB#include <linux/sysctl.h>\fP
44 \fBint _sysctl(struct __sysctl_args *\fP\fIargs\fP\fB);\fP
47 \fINote\fP: There is no glibc wrapper for this system call; see NOTES.
49 \fBこのシステムコールを使用しないこと!\fP 「注意」の節を参照。
51 \fB_sysctl\fP() コールはカーネルパラメーターを読み書きする。例えば、 ホストネームや同時にオープンできるファイルの最大数など。
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 このコールは \fI/proc/sys\fP の下のディレクトリ・ツリーに似た木構造(tree structure)を検索する。
69 そして、要求された項目が見つかった場合は適切なルーチンを呼び出して 値を読んだり修正したりする。
71 成功した場合は \fB_sysctl\fP() は 0 を返す。失敗した場合、\-1 が返され、 \fIerrno\fP がそのエラーを示す値に設定される。
75 \fIoldval\fP に NULL でない値を設定して、以前の値を要求しているのに、 \fIoldlenp\fP に空きがない。
80 \fBEACCES\fP か \fBEPERM\fP
81 「ディレクトリ」のどれかに検索許可がなかったか、 \fIoldval\fP が 0 でないのに読み込み許可がなかったか、 \fInewval\fP が 0
84 このコールは Linux 特有であり、移植を意図したプログラムで使用しては いけない。 \fBsysctl\fP() コールは Linux のバージョン
85 1.3.57 から存在している。 これは 4.4BSD に由来している。Linux は \fI/proc/sys\fP
86 に写し(mirror)をもっており、項目の名前の付け方が Linux と 4.4BSD では 異っている。しかし \fBsysctl\fP()
89 .\" See http://lwn.net/Articles/247243/
90 .\" Though comments in suggest that it is needed by old glibc binaries,
91 .\" so maybe it's not going away.
92 Glibc does not provide a wrapper for this system call; call it using
93 \fBsyscall\fP(2). Or rather... \fIdon't\fP call it: use of this system call has
94 long been discouraged, and it is so unloved that \fBit is likely to disappear
95 in a future kernel version\fP. Since Linux 2.6.24, uses of this system call
96 result in warnings in the kernel log. Remove it from your programs now; use
97 the \fI/proc/sys\fP interface instead.
99 This system call is available only if the kernel was configured with the
100 \fBCONFIG_SYSCTL_SYSCALL\fP option.
102 オブジェクトの名前は、カーネルのバージョンごとに異なっている。 このため、このシステム・コールはアプリケーションにとって 無価値なものとなっている。
104 全ての可能な項目が正確に記述されているわけではない。
106 今のところ \fI/proc/sys/kernel/ostype\fP に書き込むことでオペーレーティング・システムを変えることはできない。
111 #include <sys/syscall.h>
115 #include <linux/sysctl.h>
117 int _sysctl(struct __sysctl_args *args );
124 struct __sysctl_args args;
125 char osname[OSNAMESZ];
127 int name[] = { CTL_KERN, KERN_OSTYPE };
129 memset(&args, 0, sizeof(struct __sysctl_args));
131 args.nlen = sizeof(name)/sizeof(name[0]);
132 args.oldval = osname;
133 args.oldlenp = &osnamelth;
135 osnamelth = sizeof(osname);
137 if (syscall(SYS__sysctl, &args) == \-1) {
141 printf("This machine is running %*s\en", osnamelth, osname);
148 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
149 である。プロジェクトの説明とバグ報告に関する情報は
150 http://www.kernel.org/doc/man\-pages/ に書かれている。