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 .\"*******************************************************************
36 .\" Japanese Version Copyright (c) 1997-1998 HANATAKA Shinya
37 .\" all rights reserved.
38 .\" Translated 1997-12-12, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
39 .\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
40 .\" Updated 2007-10-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.66
41 .\" Updated 2013-05-01, Akihiro MOTOKI <amotoki@gmail.com>
43 .TH SYSCTL 2 2012\-12\-22 Linux "Linux Programmer's Manual"
45 sysctl \- システムパラメーターを読み書きする
48 \fB#include <unistd.h>\fP
50 \fB#include <linux/sysctl.h>\fP
52 \fBint _sysctl(struct __sysctl_args *\fP\fIargs\fP\fB);\fP
55 \fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。
57 \fBこのシステムコールを使用しないこと!\fP 「注意」の節を参照。
59 \fB_sysctl\fP() コールはカーネルパラメーターを読み書きする。例えば、 ホストネームや同時にオープンできるファイルの最大数など。
64 struct __sysctl_args {
65 int *name; /* integer vector describing variable */
66 int nlen; /* length of this vector */
67 void *oldval; /* 0 or address where to store old value */
68 size_t *oldlenp; /* available room for old value,
69 overwritten by actual size of old value */
70 void *newval; /* 0 or address of new value */
71 size_t newlen; /* size of new value */
76 このコールは \fI/proc/sys\fP の下のディレクトリツリーに似た木構造(tree structure)を検索する。
77 そして、要求された項目が見つかった場合は適切なルーチンを呼び出して 値を読んだり修正したりする。
79 成功した場合は \fB_sysctl\fP() は 0 を返す。失敗した場合、\-1 が返され、 \fIerrno\fP がそのエラーを示す値に設定される。
83 \fIoldval\fP に NULL でない値を設定して、以前の値を要求しているのに、 \fIoldlenp\fP に空きがない。
88 \fBEACCES\fP か \fBEPERM\fP
89 「ディレクトリ」のどれかに検索許可がなかったか、 \fIoldval\fP が 0 でないのに読み込み許可がなかったか、 \fInewval\fP が 0
92 このコールは Linux 特有であり、移植を意図したプログラムで使用しては いけない。 \fBsysctl\fP() コールは Linux のバージョン
93 1.3.57 から存在している。 これは 4.4BSD に由来している。Linux は \fI/proc/sys\fP
94 に写し(mirror)をもっており、項目の名前の付け方が Linux と 4.4BSD では 異っている。しかし \fBsysctl\fP()
97 .\" See http://lwn.net/Articles/247243/
98 .\" Though comments in suggest that it is needed by old glibc binaries,
99 .\" so maybe it's not going away.
100 glibc はこのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2)
101 を使って呼び出すこと。というよりは・・・このシステムコールを呼び出さないこと。 長い間このシステムコールの使用は非推奨とされており、
102 「将来のバージョンのカーネルで削除されるようだ」と言われるほどである。 あなたのプログラムにこのシステムコールがあれば、すぐにでも削除すること。
103 代わりに \fI/proc/sys\fP インターフェースを使用すること。
105 このシステムコールは、カーネルの \fBCONFIG_SYSCTL_SYSCALL\fP オプションが有効になっている場合のみ利用できる。
107 オブジェクトの名前は、カーネルのバージョンごとに異なっている。 このため、このシステムコールはアプリケーションにとって 無価値なものとなっている。
109 全ての可能な項目が正確に記述されているわけではない。
111 今のところ \fI/proc/sys/kernel/ostype\fP に書き込むことでオペーレーティングシステムを変えることはできない。
116 #include <sys/syscall.h>
120 #include <linux/sysctl.h>
122 int _sysctl(struct __sysctl_args *args );
129 struct __sysctl_args args;
130 char osname[OSNAMESZ];
132 int name[] = { CTL_KERN, KERN_OSTYPE };
134 memset(&args, 0, sizeof(struct __sysctl_args));
136 args.nlen = sizeof(name)/sizeof(name[0]);
137 args.oldval = osname;
138 args.oldlenp = &osnamelth;
140 osnamelth = sizeof(osname);
142 if (syscall(SYS__sysctl, &args) == \-1) {
146 printf("This machine is running %*s\en", osnamelth, osname);
153 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
154 である。プロジェクトの説明とバグ報告に関する情報は
155 http://www.kernel.org/doc/man\-pages/ に書かれている。