[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87tvxda2l3.fsf@concordia.ellerman.id.au>
Date:   Wed, 29 Nov 2017 19:52:56 +1100
From:   Michael Ellerman <mpe@...erman.id.au>
To:     Ingo Molnar <mingo@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        LKML <linux-kernel@...r.kernel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Borislav Petkov <bp@...en8.de>,
        Brian Gerst <brgerst@...il.com>,
        Denys Vlasenko <dvlasenk@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Rik van Riel <riel@...hat.com>,
        Daniel Gruss <daniel.gruss@...k.tugraz.at>,
        Hugh Dickins <hughd@...gle.com>,
        Kees Cook <keescook@...gle.com>, linux-mm <linux-mm@...ck.org>,
        michael.schwarz@...k.tugraz.at, moritz.lipp@...k.tugraz.at,
        richard.fellner@...dent.tugraz.at
Subject: Re: [PATCH] vfs: Add PERM_* symbolic helpers for common file mode/permissions
Ingo Molnar <mingo@...nel.org> writes:
...
> Index: tip/include/linux/stat.h
> ===================================================================
> --- tip.orig/include/linux/stat.h
> +++ tip/include/linux/stat.h
> @@ -6,6 +6,34 @@
>  #include <asm/stat.h>
>  #include <uapi/linux/stat.h>
>  
> +/*
> + * Human readable symbolic definitions for common
> + * file permissions:
> + */
> +#define PERM_r________	0400
> +#define PERM_r__r_____	0440
> +#define PERM_r__r__r__	0444
> +
> +#define PERM_rw_______	0600
> +#define PERM_rw_r_____	0640
> +#define PERM_rw_r__r__	0644
> +#define PERM_rw_rw_r__	0664
> +#define PERM_rw_rw_rw_	0666
> +
> +#define PERM__w_______	0200
> +#define PERM__w__w____	0220
> +#define PERM__w__w__w_	0222
> +
> +#define PERM_r_x______	0500
> +#define PERM_r_xr_x___	0550
> +#define PERM_r_xr_xr_x	0555
> +
> +#define PERM_rwx______	0700
> +#define PERM_rwxr_x___	0750
> +#define PERM_rwxr_xr_x	0755
> +#define PERM_rwxrwxr_x	0775
> +#define PERM_rwxrwxrwx	0777
I see what you're trying to do with all the explicit underscores, but it
does make them look kinda ugly.
What if you just used underscores to separate the user/group/other, and
the unset permission bits are just omitted.
Then the two most common cases would be:
  PERM_rw_r_r
  PERM_r_r_r
Both of those read nicely I think. ie. the first is "perm read write,
read, read".
Full set would be:
#define PERM_r			0400
#define PERM_r_r		0440
#define PERM_r_r_r		0444
#define PERM_rw			0600
#define PERM_rw_r		0640
#define PERM_rw_r_r		0644
#define PERM_rw_rw_r		0664
#define PERM_rw_rw_rw		0666
#define PERM_w			0200
#define PERM_w_w		0220
#define PERM_w_w_w		0222
#define PERM_rx			0500
#define PERM_rx_rx		0550
#define PERM_rx_rx_rx		0555
#define PERM_rwx		0700
#define PERM_rwx_rx		0750
#define PERM_rwx_rx_rx		0755
#define PERM_rwx_rwx_rx		0775
#define PERM_rwx_rwx_rwx	0777
cheers
Powered by blists - more mailing lists
 
