OSDN Git Service

(split) LDP: Update release from the latest PO files
[linuxjm/LDP_man-pages.git] / release / man2 / sysctl.2
1 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
2 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
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.
29 .\"
30 .\"*******************************************************************
31 .\"
32 .\" This file was generated with po4a. Translate the source file.
33 .\"
34 .\"*******************************************************************
35 .TH SYSCTL 2 2012\-12\-22 Linux "Linux Programmer's Manual"
36 .SH 名前
37 sysctl \- システム・パラメーターを読み書きする
38 .SH 書式
39 .nf
40 \fB#include <unistd.h>\fP
41 .br
42 \fB#include <linux/sysctl.h>\fP
43 .sp
44 \fBint _sysctl(struct __sysctl_args *\fP\fIargs\fP\fB);\fP
45 .fi
46
47 \fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。
48 .SH 説明
49 \fBこのシステムコールを使用しないこと!\fP 「注意」の節を参照。
50
51 \fB_sysctl\fP()  コールはカーネルパラメーターを読み書きする。例えば、 ホストネームや同時にオープンできるファイルの最大数など。
52 引き数は以下の形式である。
53 .PP
54 .in +4n
55 .nf
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 */
64 };
65 .fi
66 .in
67 .PP
68 このコールは \fI/proc/sys\fP の下のディレクトリ・ツリーに似た木構造(tree structure)を検索する。
69 そして、要求された項目が見つかった場合は適切なルーチンを呼び出して 値を読んだり修正したりする。
70 .SH 返り値
71 成功した場合は \fB_sysctl\fP()  は 0 を返す。失敗した場合、\-1 が返され、 \fIerrno\fP がそのエラーを示す値に設定される。
72 .SH エラー
73 .TP 
74 \fBEFAULT\fP
75 \fIoldval\fP に NULL でない値を設定して、以前の値を要求しているのに、 \fIoldlenp\fP に空きがない。
76 .TP 
77 \fBENOTDIR\fP
78 \fIname\fP が見つからなかった。
79 .TP 
80 \fBEACCES\fP か \fBEPERM\fP
81 「ディレクトリ」のどれかに検索許可がなかったか、 \fIoldval\fP が 0 でないのに読み込み許可がなかったか、 \fInewval\fP が 0
82 でないのに書き込み許可がなかった。
83 .SH 準拠
84 このコールは Linux 特有であり、移植を意図したプログラムで使用しては いけない。 \fBsysctl\fP()  コールは Linux のバージョン
85 1.3.57 から存在している。 これは 4.4BSD に由来している。Linux は \fI/proc/sys\fP
86 に写し(mirror)をもっており、項目の名前の付け方が Linux と 4.4BSD では 異っている。しかし \fBsysctl\fP()
87 関数の宣言は両方で同じである。
88 .SH 注意
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 はこのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2)
93 を使って呼び出すこと。というよりは・・・このシステムコールを呼び出さないこと。 長い間このシステムコールの使用は非推奨とされており、
94 「将来のバージョンのカーネルで削除されるようだ」と言われるほどである。 あなたのプログラムにこのシステムコールがあれば、すぐにでも削除すること。
95 代わりに \fI/proc/sys\fP インターフェースを使用すること。
96
97 このシステムコールは、カーネルの \fBCONFIG_SYSCTL_SYSCALL\fP オプションが有効になっている場合のみ利用できる。
98 .SH バグ
99 オブジェクトの名前は、カーネルのバージョンごとに異なっている。 このため、このシステム・コールはアプリケーションにとって 無価値なものとなっている。
100 .PP
101 全ての可能な項目が正確に記述されているわけではない。
102 .PP
103 今のところ \fI/proc/sys/kernel/ostype\fP に書き込むことでオペーレーティング・システムを変えることはできない。
104 .SH 例
105 .nf
106 #define _GNU_SOURCE
107 #include <unistd.h>
108 #include <sys/syscall.h>
109 #include <string.h>
110 #include <stdio.h>
111 #include <stdlib.h>
112 #include <linux/sysctl.h>
113
114 int _sysctl(struct __sysctl_args *args );
115
116 #define OSNAMESZ 100
117
118 int
119 main(void)
120 {
121     struct __sysctl_args args;
122     char osname[OSNAMESZ];
123     size_t osnamelth;
124     int name[] = { CTL_KERN, KERN_OSTYPE };
125
126     memset(&args, 0, sizeof(struct __sysctl_args));
127     args.name = name;
128     args.nlen = sizeof(name)/sizeof(name[0]);
129     args.oldval = osname;
130     args.oldlenp = &osnamelth;
131
132     osnamelth = sizeof(osname);
133
134     if (syscall(SYS__sysctl, &args) == \-1) {
135         perror("_sysctl");
136         exit(EXIT_FAILURE);
137     }
138     printf("This machine is running %*s\en", osnamelth, osname);
139     exit(EXIT_SUCCESS);
140 }
141 .fi
142 .SH 関連項目
143 \fBproc\fP(5)
144 .SH この文書について
145 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.51 の一部
146 である。プロジェクトの説明とバグ報告に関する情報は
147 http://www.kernel.org/doc/man\-pages/ に書かれている。