.\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Written 11 April 1996 by Andries Brouwer .\" 960412: Added comments from Stephen Tweedie .\" Modified Tue Oct 22 22:28:41 1996 by Eric S. Raymond .\" Modified Mon Jan 5 20:31:04 1998 by aeb. .\" .\" Japanese Version Copyright (c) 1997-1998 HANATAKA Shinya .\" all rights reserved. .\" Translated 1997-12-12, HANATAKA Shinya .\" Modified 1998-05-11, HANATAKA Shinya .\" Updated 2007-10-11, Akihiro MOTOKI , LDP v2.66 .\" .\"WORD: parameter パラメーター .\"WORD: kernel カーネル .\"WORD: hostname ホストネーム .\"WORD: open オープン .\"WORD: directory ディレクトリ .\"WORD: tree ツリー .\" .TH SYSCTL 2 2008-11-20 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O sysctl \- read/write system parameters sysctl \- システム・パラメーターを読み書きする .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .br .B #include .sp .BI "int _sysctl(struct __sysctl_args *" args ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O .B Do not use this system call! .\"O See NOTES. .B このシステムコールを使用しないこと! 「注意」の節を参照。 .\"O The .\"O .BR _sysctl () .\"O call reads and/or writes kernel parameters. .\"O For example, the hostname, .\"O or the maximum number of open files. .\"O The argument has the form .BR _sysctl () コールはカーネルパラメーターを読み書きする。例えば、 ホストネームや同時にオープンできるファイルの最大数など。 引き数は以下の形式である。 .PP .in +4n .nf struct __sysctl_args { int *name; /* integer vector describing variable */ int nlen; /* length of this vector */ void *oldval; /* 0 or address where to store old value */ size_t *oldlenp; /* available room for old value, overwritten by actual size of old value */ void *newval; /* 0 or address of new value */ size_t newlen; /* size of new value */ }; .fi .in .PP .\"O This call does a search in a tree structure, possibly resembling .\"O a directory tree under .\"O .IR /proc/sys , .\"O and if the requested item is found calls some appropriate routine .\"O to read or modify the value. このコールは .I /proc/sys の下のディレクトリ・ツリーに似た木構造(tree structure)を検索する。 そして、要求された項目が見つかった場合は適切なルーチンを呼び出して 値を読んだり修正したりする。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O Upon successful completion, .\"O .BR _sysctl () .\"O returns 0. .\"O Otherwise, a value of \-1 is returned and .\"O .I errno .\"O is set to indicate the error. 成功した場合は .BR _sysctl () は 0 を返す。失敗した場合、\-1 が返され、 .I errno がそのエラーを示す値に設定される。 .\"O .SH ERRORS .SH エラー .TP .B EFAULT .\"O The invocation asked for the previous value by setting .\"O .I oldval .\"O non-NULL, but allowed zero room in .\"O .IR oldlenp . .I oldval に NULL でない値を設定して、以前の値を要求しているのに、 .I oldlenp に空きがない。 .TP .B ENOTDIR .\"O .I name .\"O was not found. .I name が見つからなかった。 .TP .B EPERM .\"O No search permission for one of the encountered "directories", .\"O or no read permission where .\"O .I oldval .\"O was nonzero, or no write permission where .\"O .I newval .\"O was nonzero. 「ディレクトリ」のどれかに検索許可がなかったか、 .I oldval が 0 でないのに読み込み許可がなかったか、 .I newval が 0 でないのに書き込み許可がなかった。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O This call is Linux-specific, and should not be used in programs .\"O intended to be portable. このコールは Linux 特有であり、移植を意図したプログラムで使用しては いけない。 .\"O A .\"O .BR sysctl () .\"O call has been present in Linux since version 1.3.57. .\"O It originated in .\"O 4.4BSD. .\"O Only Linux has the .\"O .I /proc/sys .\"O mirror, and the object naming schemes differ between Linux and 4.4BSD, .\"O but the declaration of the .\"O .BR sysctl () .\"O function is the same in both. .SH 歴史 .BR sysctl () コールは Linux のバージョン 1.3.57 から存在している。 これは 4.4BSD に由来している。Linux は .I /proc/sys に写し(mirror)をもっており、項目の名前の付け方が Linux と 4.4BSD では 異っている。しかし .BR sysctl () 関数の宣言は両方で同じである。 .\"O .SH NOTES .SH 注意 .\"O Glibc does not provide a wrapper for this system call; call it using .\"O .BR syscall (2). glibc はこのシステムコールに対するラッパー関数を提供していない。 .BR syscall (2) を使って呼び出すこと。 .\"O Or rather... don't call it: .\"O use of this system call has long been discouraged, .\"O and it is so unloved that .\"O \fBit is likely to disappear in a future kernel version\fP. .\"O .\" See http://lwn.net/Articles/247243/ .\"O Remove it from your programs now; use the .\"O .I /proc/sys .\"O interface instead. というよりは・・・このシステムコールを呼び出さないこと。 長い間このシステムコールの使用は非推奨とされており、 「将来のバージョンのカーネルで削除されるようだ」と言われるほどである。 .\" http://lwn.net/Articles/247243/ 参照 あなたのプログラムにこのシステムコールがあれば、すぐにでも削除すること。 代わりに .I /proc/sys インターフェースを使用すること。 .\"O .SH BUGS .SH バグ .\"O The object names vary between kernel versions, .\"O making this system call worthless for applications. オブジェクトの名前は、カーネルのバージョンごとに異なっている。 このため、このシステム・コールはアプリケーションにとって 無価値なものとなっている。 .PP .\"O Not all available objects are properly documented. 全ての可能な項目が正確に記述されているわけではない。 .PP .\"O It is not yet possible to change operating system by writing to .\"O .IR /proc/sys/kernel/ostype . 今のところ .I /proc/sys/kernel/ostype に書き込むことでオペーレーティング・システムを変えることはできない。 .\"O .SH EXAMPLE .SH 例 .nf #define _GNU_SOURCE #include #include #include #include #include #include int _sysctl(struct __sysctl_args *args ); #define OSNAMESZ 100 int main(void) { struct __sysctl_args args; char osname[OSNAMESZ]; size_t osnamelth; int name[] = { CTL_KERN, KERN_OSTYPE }; memset(&args, 0, sizeof(struct __sysctl_args)); args.name = name; args.nlen = sizeof(name)/sizeof(name[0]); args.oldval = osname; args.oldlenp = &osnamelth; osnamelth = sizeof(osname); if (syscall(SYS__sysctl, &args) == \-1) { perror("_sysctl"); exit(EXIT_FAILURE); } printf("This machine is running %*s\\n", osnamelth, osname); exit(EXIT_SUCCESS); } .fi .\"O .SH "SEE ALSO" .SH 関連項目 .BR proc (5)