OSDN Git Service

(split) DP: release pages (catch up to 3.50).
[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 \fINote\fP: There is no glibc wrapper for this system call; see NOTES.
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 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.
98
99 This system call is available only if the kernel was configured with the
100 \fBCONFIG_SYSCTL_SYSCALL\fP option.
101 .SH バグ
102 オブジェクトの名前は、カーネルのバージョンごとに異なっている。 このため、このシステム・コールはアプリケーションにとって 無価値なものとなっている。
103 .PP
104 全ての可能な項目が正確に記述されているわけではない。
105 .PP
106 今のところ \fI/proc/sys/kernel/ostype\fP に書き込むことでオペーレーティング・システムを変えることはできない。
107 .SH 例
108 .nf
109 #define _GNU_SOURCE
110 #include <unistd.h>
111 #include <sys/syscall.h>
112 #include <string.h>
113 #include <stdio.h>
114 #include <stdlib.h>
115 #include <linux/sysctl.h>
116
117 int _sysctl(struct __sysctl_args *args );
118
119 #define OSNAMESZ 100
120
121 int
122 main(void)
123 {
124     struct __sysctl_args args;
125     char osname[OSNAMESZ];
126     size_t osnamelth;
127     int name[] = { CTL_KERN, KERN_OSTYPE };
128
129     memset(&args, 0, sizeof(struct __sysctl_args));
130     args.name = name;
131     args.nlen = sizeof(name)/sizeof(name[0]);
132     args.oldval = osname;
133     args.oldlenp = &osnamelth;
134
135     osnamelth = sizeof(osname);
136
137     if (syscall(SYS__sysctl, &args) == \-1) {
138         perror("_sysctl");
139         exit(EXIT_FAILURE);
140     }
141     printf("This machine is running %*s\en", osnamelth, osname);
142     exit(EXIT_SUCCESS);
143 }
144 .fi
145 .SH 関連項目
146 \fBproc\fP(5)
147 .SH この文書について
148 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
149 である。プロジェクトの説明とバグ報告に関する情報は
150 http://www.kernel.org/doc/man\-pages/ に書かれている。