fs: sort out the fallocate mode vs flag mess
authorChristoph Hellwig <hch@lst.de>
Tue, 27 Aug 2024 06:50:47 +0000 (08:50 +0200)
committerChristian Brauner <brauner@kernel.org>
Wed, 28 Aug 2024 14:53:57 +0000 (16:53 +0200)
commit57413d8e172c10c90fbd91f98d0f7d8eb27e824c
tree85ee8b00d68a0adf810bd4cdc04009c6f8042684
parentf951171044762a0d179caf9f1addcdbc7cb533bf
fs: sort out the fallocate mode vs flag mess

The fallocate system call takes a mode argument, but that argument
contains a wild mix of exclusive modes and an optional flags.

Replace FALLOC_FL_SUPPORTED_MASK with FALLOC_FL_MODE_MASK, which excludes
the optional flag bit, so that we can use switch statement on the value
to easily enumerate the cases while getting the check for duplicate modes
for free.

To make this (and in the future the file system implementations) more
readable also add a symbolic name for the 0 mode used to allocate blocks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240827065123.1762168-4-hch@lst.de
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/open.c
include/linux/falloc.h
include/uapi/linux/falloc.h