.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 2006, 2008, Michael Kerrisk (mtk.manpages@gmail.com) .\" (A few fragments remain from an earlier (1992) version written in .\" 1992 by Drew Eckhardt .) .\" .\" 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. .\" .\" Modified by Michael Haardt .\" Modified Sat Jul 24 12:51:53 1993 by Rik Faith .\" Modified Tue Oct 22 22:39:04 1996 by Eric S. Raymond .\" Modified Thu May 1 06:05:54 UTC 1997 by Nicolás Lichtmaier .\" with Lars Wirzenius suggestion .\" 2006-05-13, mtk, substantial rewrite of description of 'mask' .\" 2008-01-09, mtk, a few rewrites and additions. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH UMASK 2 2008\-01\-09 Linux "Linux Programmer's Manual" .SH 名前 umask \- ファイルモード作成マスクを設定する .SH 書式 \fB#include \fP .br \fB#include \fP .sp \fBmode_t umask(mode_t \fP\fImask\fP\fB);\fP .SH 説明 \fBumask\fP() は、呼び出し元プロセスのファイルモード作成マスク (umask) を \fImask\fP & 0777 に設定し (\fIumask\fP のファイル許可に対応するビットのみを使用する)、 変更前のマスク値を返す。 .\" e.g., mkfifo(), creat(), mknod(), sem_open(), mq_open(), shm_open() .\" but NOT the System V IPC *get() calls umask は、 \fBopen\fP(2), \fBmkdir\fP(2) やファイル作成を行うその他のシステムコールで、 新しく作成されるファイルやディレクトリの許可 (permission) を 修正するために使用される。 具体的には umask に設定されている許可が \fBopen\fP(2) や \fBmkdir\fP(2) の \fImode\fP 引き数から取り消される。 \fImask\fP に指定するのに使用すべき定数については \fBstat\fP(2) で説明されている。 プロセスの umask のよくあるデフォルト値は \fIS_IWGRP\ |\ S_IWOTH\fP (8進で 022) である。 新しいファイルを作成する際に \fBopen\fP(2) の \fImode\fP 引き数に .nf S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH .fi を指定するというよくあるケースでは、作成されたファイルは .nf S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH .fi という許可を持つことになる (なぜなら 0666 & ~022 = 0644、つまり rw\-r\-\-r\-\-)。 .SH 返り値 このシステムコールは必ず成功し、以前の umask 値を返す。 .SH 準拠 SVr4, 4.3BSD, POSIX.1\-2001. .SH 注意 \fBfork\fP(2) で作成された子プロセスは、親プロセスの umask を継承する。 \fBexecve\fP(2) によって umask は変更されない。 umask の設定は、そのプロセスが生成する POSIX IPC オブジェクト (\fBmq_open\fP(3), \fBsem_open\fP(3), \fBshm_open\fP(3)) や FIFO (\fBmkfifo\fP(3))、 UNIX ドメインソケット (\fBunix\fP(7)) に設定される許可にも影響を与える。 一方、umask は、そのプロセスが (\fBmsgget\fP(2), \fBsemget\fP(2), \fBshmget\fP(2) を使って) 生成する System V IPC オブジェクトに設定される許可には 影響を与えない。 .SH 関連項目 .\" FIXME . eventually: .BR acl (5) \fBchmod\fP(2), \fBmkdir\fP(2), \fBopen\fP(2), \fBstat\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。