.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" This manpage is Copyright (C) 1992 Drew Eckhardt; .\" 1993 Michael Haardt .\" 1993,1994 Ian Jackson. .\" You may distribute it under the terms of the GNU General .\" Public License. It comes with NO WARRANTY. .\" .\" Modified 1996-08-18 by urs .\" Modified 2003-04-23 by Michael Kerrisk .\" Modified 2004-06-23 by Michael Kerrisk .\" .\" .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki .\" all rights reserved. .\" Translated 1997-06-26, SUTO, Mitsuaki .\" Updated & Modified 1999-03-01, NAKANO Takeo .\" Updated & Modified 2001-06-04, Yuichi SATO .\" Updated & Modified 2003-07-26, Yuichi SATO .\" Updated & Modified 2004-12-31, Yuichi SATO .\" Updated 2005-09-06, Akihiro MOTOKI .\" .\"WORD: node ノード .\"WORD: permission 許可属性 .\"WORD: resolve (パス名を) 解決する .\" .TH MKNOD 2 2008-12-01 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O mknod \- create a special or ordinary file mknod \- 特殊ファイルや通常のファイルを作成する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .B #include .B #include .B #include .sp .BI "int mknod(const char *" pathname ", mode_t " mode ", dev_t " dev ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR mknod (): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 .\"O .SH DESCRIPTION .SH 説明 .\"O The system call .\"O .BR mknod () .\"O creates a file system node (file, device special file or .\"O named pipe) named .\"O .IR pathname , .\"O with attributes specified by .\"O .I mode .\"O and .\"O .IR dev . システムコール .BR mknod () は .I pathname という名前のファイルシステム・ノード (ファイル、デバイススペシャルファイル、名前付きパイプ) を、 属性 .I mode と .I dev の指定にしたがって作成する。 .\"O The .\"O .I mode .\"O argument specifies both the permissions to use and the type of node .\"O to be created. .I mode 引き数には、作成するノードの許可属性 (permission) とタイプを指定する。 .\"O It should be a combination (using bitwise OR) of one of the file types .\"O listed below and the permissions for the new node. .I mode の指定は以下にあげるファイルタイプのうちの 1 つと、 許可属性の組合せ (ビットごとの OR を使用) で行う。 .\"O The permissions are modified by the process's .\"O .I umask .\"O in the usual way: the permissions of the created node are .\"O .IR "(mode & ~umask)" . 許可属性は通常通り、プロセスの .I umask によって修正され、作成されたノードの許可属性は .I "(mode & ~umask)" となる。 .\"O The file type must be one of .\"O .BR S_IFREG , .\"O .BR S_IFCHR , .\"O .BR S_IFBLK , .\"O .B S_IFIFO .\"O or .\"O .B S_IFSOCK .\"O .\" (S_IFSOCK since Linux 1.2.4) .\"O to specify a regular file (which will be created empty), character .\"O special file, block special file, FIFO (named pipe), or Unix domain socket, .\"O respectively. .\"O (Zero file type is equivalent to type .\"O .BR S_IFREG .) ファイルタイプには .BR S_IFREG , .BR S_IFCHR , .BR S_IFBLK , .BR S_IFIFO , .B S_IFSOCK .\" (S_IFSOCK は Linux 1.2.4 から存在する) のいずれかを指定しなければならない。 それぞれ順に、通常のファイル (空のファイルとして作成される)・ キャラクタスペシャルファイル・ブロックスペシャルファイル・ FIFO (名前付きパイプ)・Unix ドメインソケットである (ファイルタイプ 0 は .B S_IFREG と同じである)。 .\"O If the file type is .\"O .B S_IFCHR .\"O or .\"O .B S_IFBLK .\"O then .\"O .I dev .\"O specifies the major and minor numbers of the newly created device .\"O special file .\"O .RB ( makedev (3) .\"O may be useful to build the value for .\"O .IR dev ); .\"O otherwise it is ignored. ファイルタイプが .B S_IFCHR または .B S_IFBLK のとき、 .I dev には作成するデバイススペシャルファイルのメジャー番号と マイナー番号を指定する .RB ( makedev (3) は .I dev のこれらの番号を作成する際に役立つだろう)。 それ以外の場合は .I dev は無視される。 .\"O If .\"O .I pathname .\"O already exists, or is a symbolic link, this call fails with an .\"O .B EEXIST .\"O error. .I pathname が既に存在する場合、またはシンボリックリンクの場合、 この呼び出しは .B EEXIST エラーで失敗する。 .\"O The newly created node will be owned by the effective user ID of the .\"O process. .\"O If the directory containing the node has the set-group-ID .\"O bit set, or if the file system is mounted with BSD group semantics, the .\"O new node will inherit the group ownership from its parent directory; .\"O otherwise it will be owned by the effective group ID of the process. 新しく作成されたノードの所有者はプロセスの実効ユーザ ID にセットされる。 新たに作られたノードを保持する 親ディレクトリの set-group-ID ビットがセットされていたり、 ファイルシステムが BSD のグループセマンティクスにしたがって マウントされている場合には、新しいノードのグループ所有権は親ディレクトリの グループ所有権を継承する (親ディレクトリと同じになる)。 また、そうでなかった場合の所有グループはプロセスの実効グループ ID となる。 .\"O .SH RETURN VALUE .SH 返り値 .\"O .BR mknod () .\"O returns zero on success, or \-1 if an error occurred (in which case, .\"O .I errno .\"O is set appropriately). .BR mknod () は成功した場合 0 を、失敗した場合 \-1 を返す (失敗した場合 .I errno がエラーの内容にしたがってセットされる)。 .\"O .SH ERRORS .SH エラー .TP .B EACCES .\"O The parent directory does not allow write permission to the process, .\"O or one of the directories in the path prefix of .\"O .I pathname .\"O did not allow search permission. .\"O (See also .\"O .BR path_resolution (7).) プロセスが親ディレクトリへの書き込み許可を持たない。 もしくはパス名 .I pathname 中のディレクトリ部分のどれかに検索許可属性が無い .RB ( path_resolution (7) も参照すること)。 .TP .B EEXIST .\"O .I pathname .\"O already exists. .\"O This includes the case where .\"O .I pathname .\"O is a symbolic link, dangling or not. .I pathname が既に存在する。 これには .I pathname がシンボリック・リンクである場合も含まれる (シンボリック・リンクが壊れているか (dangling) どうかは関係ない)。 .TP .B EFAULT .\"O .IR pathname " points outside your accessible address space." .I pathname がそのプロセスのアクセス可能なアドレス空間の外を指している。 .TP .B EINVAL .\"O .I mode .\"O requested creation of something other than a regular file, device .\"O special file, FIFO or socket. .I mode が通常のファイル・デバイススペシャルファイル・FIFO・ソケット以外を 作成するようにセットされている。 .TP .B ELOOP .\"O Too many symbolic links were encountered in resolving .\"O .IR pathname . パス名 .I pathname を解決するときに、含まれているシンボリックリンクが多すぎた。 .TP .B ENAMETOOLONG .\"O .IR pathname " was too long." .I pathname が長過ぎる。 .TP .B ENOENT .\"O A directory component in .\"O .I pathname .\"O does not exist or is a dangling symbolic link. .I pathname 中で指定されているディレクトリが存在しないか、 またはリンク先の無いシンボリックリンクである。 .TP .B ENOMEM .\"O Insufficient kernel memory was available. 十分なカーネルメモリが無い。 .TP .B ENOSPC .\"O The device containing .\"O .I pathname .\"O has no room for the new node. .I pathname のあるデバイスに新たにノードを作成する空きが無い。 .TP .B ENOTDIR .\"O A component used as a directory in .\"O .I pathname .\"O is not, in fact, a directory. .I pathname 中のディレクトリ要素が、実際にはディレクトリでない。 .TP .B EPERM .\"O .I mode .\"O requested creation of something other than a regular file, .\"O FIFO (named pipe), or Unix domain socket, and the caller .\"O is not privileged (Linux: does not have the .\"O .B CAP_MKNOD .\"O capability); .\"O .\" For Unix domain sockets and regular files, EPERM is only returned in .\"O .\" Linux 2.2 and earlier; in Linux 2.4 and later, unprivileged can .\"O .\" use mknod() to make these files. .\"O also returned if the file system containing .\"O .I pathname .\"O does not support the type of node requested. .I mode は通常のファイル・FIFO (名前付きパイプ)・Unix ドメインソケット以外を 作成するようにセットされているが、実行者が特権 (Linux では .B CAP_MKNOD ケーパビリティ (capability)) を持っていない。 .\" Unix ドメインソケットと通常ファイルに対して mknod() を行うと、 .\" Linux 2.2 以前では EPERM を返すだけである。 .\" Linux 2.4 以降では特権を持っていなくてもこれらのファイルを .\" 作成するのに mknod() を使用することができる。 または .I pathname を保持するファイルシステムが、指定されたノード形式をサポートしていない。 .TP .B EROFS .\"O .I pathname .\"O refers to a file on a read-only file system. .I pathname が読み出し専用ファイルシステム上のファイルを指している。 .\"O .SH CONFORMING TO .SH 準拠 .\"O SVr4, 4.4BSD, POSIX.1-2001 (but see below). .\"O .\" The Linux version differs from the SVr4 version in that it .\"O .\" does not require root permission to create pipes, also in that no .\"O .\" EMULTIHOP, ENOLINK, or EINTR error is documented. SVr4, 4.4BSD, POSIX.1-2001 (下記も参照). .\" Linux の実装は SVr4 の実装と異なり、パイプの作成には root 権限が不要である。 .\" また EMULTIHOP と ENOLINK と EINTR のエラーについては記述されていない。 .\"O .SH NOTES .SH 注意 .\"O POSIX.1-2001 says: "The only portable use of .\"O .BR mknod () .\"O is to create a FIFO-special file. .\"O If .\"O .I mode .\"O is not .\"O .B S_IFIFO .\"O or .\"O .I dev .\"O is not 0, the behavior of .\"O .BR mknod () .\"O is unspecified." POSIX.1-2001 では次のように書いている: .RB 「 mknod () の唯一の移植性のある使用法は、FIFO スペシャルファイルを作成することである。 .I mode が .B S_IFIFO ではない場合、または .I dev が 0 ではない場合、 .BR mknod () の挙動は規定されていない。」 .\"O However, nowadays one should never use .\"O .BR mknod () .\"O for this purpose; one should use .\"O .BR mkfifo (3), .\"O a function especially defined for this purpose. しかしながら、現在ではこの目的のために .BR mknod () を使用すべきではない。この目的のために特別に定義された関数である .BR mkfifo () を使用すべきである。 .\"O Under Linux, this call cannot be used to create directories. Linux では、ディレクトリを作成するために この呼び出しを使用することはできない。 .\"O One should make directories with .\"O .BR mkdir (2). ディレクトリは .BR mkdir (2) で作成すべきである。 .\"O .\" and one should make Unix domain sockets with socket(2) and bind(2). .\" Unix ドメインソケットは socket(2) と bind(2) で作成すべきである。 .\"O There are many infelicities in the protocol underlying NFS. .\"O Some of these affect .\"O .BR mknod (). NFS を実現しているプロトコルには多くの不備が存在し、 それらのいくつかは .BR mknod () に影響を与える。 .\"O .SH SEE ALSO .SH 関連項目 .BR chmod (2), .BR chown (2), .BR fcntl (2), .BR mkdir (2), .BR mknodat (2), .BR mount (2), .BR socket (2), .BR stat (2), .BR umask (2), .BR unlink (2), .BR makedev (3), .BR mkfifo (3), .BR path_resolution (7)