[PATCH] procfs: expose umask in /proc/<PID>/status (formerly umask2, formerly getumask)

From: Richard W.M. Jones
Date: Thu Apr 14 2016 - 05:35:16 EST


It's not possible to read the process umask without also modifying it,
which is what umask(2) does. A library cannot read umask safely,
especially if the main program might be multithreaded.

Add a new status line ("Umask") in /proc/<PID>/status. It contains
the file mode creation mask (umask) in octal. It is only shown for
tasks which have task->fs.

For the library this allows me to read the umask from
/proc/self/status.

This patch is adapted from one originally written by Pierre Carrier:
https://lkml.org/lkml/2012/5/4/451

Rich.