All of lore.kernel.org
 help / color / mirror / Atom feed
* Using bit shifts for VXFS file modes
@ 2021-02-01 23:49 Amy Parker
  2021-02-01 23:57 ` Chaitanya Kulkarni
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Amy Parker @ 2021-02-01 23:49 UTC (permalink / raw)
  To: linux-fsdevel, Christoph Hellwig

Hello filesystem developers!

I was scouting through the FreeVXFS code, when I came across this in
fs/freevxfs/vxfs.h:

enum vxfs_mode {
        VXFS_ISUID = 0x00000800, /* setuid */
        VXFS_ISGID = 0x00000400, /* setgid */
        VXFS_ISVTX = 0x00000200, /* sticky bit */
        VXFS_IREAD = 0x00000100, /* read */
        VXFS_IWRITE = 0x00000080, /* write */
        VXFS_IEXEC = 0x00000040, /* exec */

Especially in an expanded form like this, these are ugly to read, and
a pain to work with.

An example of potentially a better method, from fs/dax.c:

#define DAX_SHIFT (4)
#define DAX_LOCKED (1UL << 0)
#define DAX_PMD (1UL << 1)
#define DAX_ZERO_PAGE (1UL << 2)
#define DAX_EMPTY (1UL << 3)

Pardon the space condensation - my email client is not functioning properly.

Anyways, I believe using bit shifts to represent different file modes
would be a much better idea - no runtime penalty as they get
calculated into constants at compile time, and significantly easier
for the average user to read.

Any thoughts on this?

Best regards,
Amy Parker
(she/her/hers)

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

end of thread, other threads:[~2021-02-02  2:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-01 23:49 Using bit shifts for VXFS file modes Amy Parker
2021-02-01 23:57 ` Chaitanya Kulkarni
2021-02-02  0:40   ` Amy Parker
2021-02-02  0:21 ` Randy Dunlap
2021-02-02  0:46   ` Amy Parker
2021-02-02  1:31 ` Theodore Ts'o
2021-02-02  1:48 ` Darrick J. Wong
2021-02-02  2:36   ` Amy Parker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.