public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] procfs: expose umask in /proc/<PID>/status
@ 2016-04-14 11:08 Richard W.M. Jones
  2016-04-14 11:08 ` Richard W.M. Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Richard W.M. Jones @ 2016-04-14 11:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: corbet, akpm, vbabka, mhocko, hughd, koct9i, chenhanxiao,
	n-horiguchi, ross.zwisler, john.stultz, minchan, jmarchan, hannes,
	nathans, andriy.shevchenko, keescook, gorcunov, joe, linux, mingo,
	cmetcalf, iago, luto, linux-doc, gorcunov, fw, walters

v1 -> v2:

 - Change printf format to %#04o.

 - Retest and update examples accordingly.

----------

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

Example usage:

$ grep Umask /proc/1/status 
Umask:	0022
$ grep Umask /proc/2/status 
Umask:	0022
$ grep Umask /proc/self/status 
Umask:	0022
$ umask 002
$ grep Umask /proc/self/status 
Umask:	0002

Rich.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-15 16:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-14 11:08 [PATCH v2] procfs: expose umask in /proc/<PID>/status Richard W.M. Jones
2016-04-14 11:08 ` Richard W.M. Jones
2016-04-14 12:34   ` Konstantin Khlebnikov
2016-04-14 12:41   ` Jerome Marchand
2016-04-15 13:13   ` Michal Hocko
2016-04-15 13:29     ` Richard W.M. Jones
2016-04-15 15:52       ` Theodore Ts'o
2016-04-15 16:43   ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox