Man page - umask(2)

Packages contains this manual

Available languages:

en fr it pl nl ja ru ro de

Manual

UMASK

名 前
書 式
説 明
返 り 値
準 拠
注 意
関 連 項 目
こ の 文 書 に つ い て

名 前

umask - フ ァ イ ル モ ー ド 作 成 マ ス ク を 設 定 す る

書 式

#include <sys/types.h>
#include <sys/stat.h>

mode_t umask(mode_t mask );

説 明

umask () は 、 呼 び 出 し 元 プ ロ セ ス の フ ァ イ ル モ ー ド 作 成 マ ス ク (umask) を mask & 0777 に 設 定 し ( umask の フ ァ イ ル 許 可 に 対 応 す る ビ ッ ト の み を 使 用 す る )、 変 更 前 の マ ス ク 値 を 返 す 。

umask は 、 open (2), mkdir (2) や フ ァ イ ル 作 成 を 行 う そ の 他 の シ ス テ ム コ ー ル で 、 新 し く 作 成 さ れ る フ ァ イ ル や デ ィ レ ク ト リ の 許 可 (permission) を 修 正 す る た め に 使 用 さ れ る 。 具 体 的 に は umask に 設 定 さ れ て い る 許 可 が open (2) や mkdir (2) の mode 引 数 か ら 取 り 消 さ れ る 。

Alternatively, if the parent directory has a default ACL (see acl (5)), the umask is ignored, the default ACL is inherited, the permission bits are set based on the inherited ACL, and permission bits absent in the mode argument are turned off. For example, the following default ACL is equivalent to a umask of 022:

u::rwx,g::r-x,o::r-x

Combining the effect of this default ACL with a mode argument of 0666 (rw-rw-rw-), the resulting file permissions would be 0644 (rw-r--r--).

mask に 指 定 す る の に 使 用 す べ き 定 数 に つ い て は inode (7) で 説 明 さ れ て い る 。

プ ロ セ ス の umask の よ く あ る デ フ ォ ル ト 値 は S_IWGRP | S_IWOTH (8進 で 022) で あ る 。 新 し い フ ァ イ ル を 作 成 す る 際 に open (2) の mode 引 数 に

S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH

を 指 定 す る と い う よ く あ る ケ ー ス で は 、 作 成 さ れ た フ ァ イ ル は

S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH

(because 0666 & ~022 = 0644; i.e., rw-r--r--).

返 り 値

こ の シ ス テ ム コ ー ル は 必 ず 成 功 し 、 以 前 の umask 値 を 返 す 。

準 拠

POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.

注 意

fork (2) で 作 成 さ れ た 子 プ ロ セ ス は 、 親 プ ロ セ ス の umask を 継 承 す る 。 execve (2) に よ っ て umask は 変 更 さ れ な い 。

It is impossible to use umask () to fetch a process’s umask without at the same time changing it. A second call to umask () would then be needed to restore the umask. The nonatomicity of these two steps provides the potential for races in multithreaded programs.

Since Linux 4.7, the umask of any process can be viewed via the Umask field of /proc/[pid]/status . Inspecting this field in /proc/self/status allows a process to retrieve its umask without at the same time changing it.

umask の 設 定 は 、 そ の プ ロ セ ス が 生 成 す る POSIX IPC オ ブ ジ ェ ク ト ( mq_open (3), sem_open (3), shm_open (3)) や FIFO ( mkfifo (3))、 UNIX ド メ イ ン ソ ケ ッ ト ( unix (7)) に 設 定 さ れ る 許 可 に も 影 響 を 与 え る 。 一 方 、 umask は 、 そ の プ ロ セ ス が ( msgget (2), semget (2), shmget (2) を 使 っ て ) 生 成 す る System V IPC オ ブ ジ ェ ク ト に 設 定 さ れ る 許 可 に は 影 響 を 与 え な い 。

関 連 項 目

chmod (2), mkdir (2), open (2), stat (2), acl (5)

こ の 文 書 に つ い て

こ の man ペ ー ジ は Linux man-pages プ ロ ジ ェ ク ト の リ リ ー ス 5.10 の 一 部 で あ る 。 プ ロ ジ ェ ク ト の 説 明 と バ グ 報 告 に 関 す る 情 報 は https://www.kernel.org/doc/man-pages/ に 書 か れ て い る 。