.\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" 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. .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" 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 .\" Updated 2013-05-01, Akihiro MOTOKI .\" .TH SYSCTL 2 2020\-11\-01 Linux "Linux Programmer's Manual" .SH 名前 sysctl \- システムパラメーターを読み書きする .SH 書式 .nf \fB#include \fP \fB#include \fP .PP \fBint _sysctl(struct __sysctl_args *\fP\fIargs\fP\fB);\fP .fi .SH 説明 \fBThis system call no longer exists on current kernels!\fP See NOTES. .PP \fB_sysctl\fP() コールはカーネルパラメーターを読み書きする。例えば、 ホストネームや同時にオープンできるファイルの最大数など。 引数は以下の形式である。 .PP .in +4n .EX 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 */ }; .EE .in .PP このコールは \fI/proc/sys\fP の下のディレクトリツリーに似た木構造(tree structure)を検索する。 そして、要求された項目が見つかった場合は適切なルーチンを呼び出して 値を読んだり修正したりする。 .SH 返り値 成功した場合は \fB_sysctl\fP() は 0 を返す。失敗した場合、\-1 が返され、 \fIerrno\fP がそのエラーを示す値に設定される。 .SH エラー .TP \fBEACCES\fP か \fBEPERM\fP 「ディレクトリ」のどれかに検索許可がなかったか、 \fIoldval\fP が 0 でないのに読み込み許可がなかったか、 \fInewval\fP が 0 でないのに書き込み許可がなかった。 .TP \fBEFAULT\fP \fIoldval\fP に NULL でない値を設定して、以前の値を要求しているのに、 \fIoldlenp\fP に空きがない。 .TP \fBENOTDIR\fP \fIname\fP が見つからなかった。 .SH バージョン This system call first appeared in Linux 1.3.57. It was removed in Linux 5.5; glibc support was removed in version 2.32. .SH 準拠 このコールは Linux 特有であり、移植を意図したプログラムで使用しては いけない。これは 4.4BSD に由来している。Linux は \fI/proc/sys\fP に写し(mirror)をもっており、項目の名前の付け方が Linux と 4.4BSD では 異っている。しかし \fBsysctl\fP() 関数の宣言は両方で同じである。 .SH 注意 Use of this system call was long discouraged: since Linux 2.6.24, uses of this system call result in warnings in the kernel log, and in Linux 5.5, the system call was finally removed. Use the \fI/proc/sys\fP interface instead. .PP Note that on older kernels where this system call still exists, it is available only if the kernel was configured with the \fBCONFIG_SYSCTL_SYSCALL\fP option. Furthermore, glibc does not provide a wrapper for this system call, necessitating the use of \fBsyscall\fP(2). .SH バグ オブジェクトの名前は、カーネルのバージョンごとに異なっている。 このため、このシステムコールはアプリケーションにとって 無価値なものとなっている。 .PP 全ての可能な項目が正確に記述されているわけではない。 .PP 今のところ \fI/proc/sys/kernel/ostype\fP に書き込むことでオペーレーティングシステムを変えることはできない。 .SH 例 .EX #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(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\en", osnamelth, osname); exit(EXIT_SUCCESS); } .EE .SH 関連項目 \fBproc\fP(5) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。