1 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Written 11 April 1996 by Andries Brouwer <aeb@cwi.nl>
24 .\" 960412: Added comments from Stephen Tweedie
25 .\" Modified Tue Oct 22 22:28:41 1996 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified Mon Jan 5 20:31:04 1998 by aeb.
28 .\" Japanese Version Copyright (c) 1997-1998 HANATAKA Shinya
29 .\" all rights reserved.
30 .\" Translated 1997-12-12, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
31 .\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
32 .\" Updated 2007-10-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.66
34 .\"WORD: parameter パラメーター
36 .\"WORD: hostname ホストネーム
38 .\"WORD: directory ディレクトリ
41 .TH SYSCTL 2 2008-11-20 "Linux" "Linux Programmer's Manual"
43 sysctl \- システム・パラメーターを読み書きする
46 .B #include <unistd.h>
48 .B #include <linux/sysctl.h>
50 .BI "int _sysctl(struct __sysctl_args *" args );
57 コールはカーネルパラメーターを読み書きする。例えば、
58 ホストネームや同時にオープンできるファイルの最大数など。
63 struct __sysctl_args {
64 int *name; /* integer vector describing variable */
65 int nlen; /* length of this vector */
66 void *oldval; /* 0 or address where to store old value */
67 size_t *oldlenp; /* available room for old value,
68 overwritten by actual size of old value */
69 void *newval; /* 0 or address of new value */
70 size_t newlen; /* size of new value */
77 の下のディレクトリ・ツリーに似た木構造(tree structure)を検索する。
78 そして、要求された項目が見つかった場合は適切なルーチンを呼び出して
83 は 0 を返す。失敗した場合、\-1 が返され、
90 に NULL でない値を設定して、以前の値を要求しているのに、
99 「ディレクトリ」のどれかに検索許可がなかったか、
101 が 0 でないのに読み込み許可がなかったか、
103 が 0 でないのに書き込み許可がなかった。
105 このコールは Linux 特有であり、移植を意図したプログラムで使用しては
110 Linux のバージョン 1.3.57 から存在している。
111 これは 4.4BSD に由来している。Linux は
113 に写し(mirror)をもっており、項目の名前の付け方が Linux と 4.4BSD では
118 glibc はこのシステムコールに対するラッパー関数を提供していない。
122 というよりは・・・このシステムコールを呼び出さないこと。
123 長い間このシステムコールの使用は非推奨とされており、
124 「将来のバージョンのカーネルで削除されるようだ」と言われるほどである。
125 .\" http://lwn.net/Articles/247243/ 参照
126 あなたのプログラムにこのシステムコールがあれば、すぐにでも削除すること。
131 オブジェクトの名前は、カーネルのバージョンごとに異なっている。
132 このため、このシステム・コールはアプリケーションにとって
135 全ての可能な項目が正確に記述されているわけではない。
138 .I /proc/sys/kernel/ostype
139 に書き込むことでオペーレーティング・システムを変えることはできない。
144 #include <sys/syscall.h>
148 #include <linux/sysctl.h>
150 int _sysctl(struct __sysctl_args *args );
157 struct __sysctl_args args;
158 char osname[OSNAMESZ];
160 int name[] = { CTL_KERN, KERN_OSTYPE };
162 memset(&args, 0, sizeof(struct __sysctl_args));
164 args.nlen = sizeof(name)/sizeof(name[0]);
165 args.oldval = osname;
166 args.oldlenp = &osnamelth;
168 osnamelth = sizeof(osname);
170 if (syscall(SYS__sysctl, &args) == \-1) {
174 printf("This machine is running %*s\\n", osnamelth, osname);