Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754815AbcDNJgy (ORCPT ); Thu, 14 Apr 2016 05:36:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57320 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754469AbcDNJgu (ORCPT ); Thu, 14 Apr 2016 05:36:50 -0400 Date: Thu, 14 Apr 2016 10:36:37 +0100 From: "Richard W.M. Jones" To: corbet@lwn.net Cc: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, hughd@google.com, koct9i@gmail.com, chenhanxiao@cn.fujitsu.com, n-horiguchi@ah.jp.nec.com, ross.zwisler@linux.intel.com, john.stultz@linaro.org, minchan@kernel.org, jmarchan@redhat.com, hannes@cmpxchg.org, nathans@redhat.com, andriy.shevchenko@linux.intel.com, keescook@chromium.org, gorcunov@openvz.org, joe@perches.com, linux@rasmusvillemoes.dk, mingo@kernel.org, cmetcalf@ezchip.com, iago@endocode.com, luto@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, gorcunov@gmail.com, fw@deneb.enyo.de, walters@verbum.org Subject: Re: [PATCH] procfs: expose umask in /proc//status (formerly umask2, formerly getumask) Message-ID: <20160414093637.GC28599@redhat.com> References: <1460626489-31932-1-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460626489-31932-1-git-send-email-rjones@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1208 Lines: 35 On Thu, Apr 14, 2016 at 10:34:48AM +0100, Richard W.M. Jones wrote: > 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//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 Sorry, I meant to add an example of what this looks like: $ grep Umask /proc/1/status Umask: 022 $ grep Umask /proc/2/status Umask: 022 $ grep Umask /proc/self/status Umask: 022 $ umask 002 $ grep Umask /proc/self/status Umask: 02 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top