VFS: add common error checks to lookup_one_qstr_excl()
authorNeilBrown <neilb@suse.de>
Mon, 17 Feb 2025 00:27:21 +0000 (11:27 +1100)
committerChristian Brauner <brauner@kernel.org>
Wed, 19 Feb 2025 13:09:15 +0000 (14:09 +0100)
commit204a575e91f3dace7589db5d1ff00067094c1e29
treeaf3811c151979d69bfb3999c069ef91167051f4d
parent1c3cb50b58c30e37d88d0b46aa093ce331f4678d
VFS: add common error checks to lookup_one_qstr_excl()

Callers of lookup_one_qstr_excl() often check if the result is negative or
positive.
These changes can easily be moved into lookup_one_qstr_excl() by checking the
lookup flags:
LOOKUP_CREATE means it is NOT an error if the name doesn't exist.
LOOKUP_EXCL means it IS an error if the name DOES exist.

This patch adds these checks, then removes error checks from callers,
and ensures that appropriate flags are passed.

This subtly changes the meaning of LOOKUP_EXCL.  Previously it could
only accompany LOOKUP_CREATE.  Now it can accompany LOOKUP_RENAME_TARGET
as well.  A couple of small changes are needed to accommodate this.  The
NFS change is functionally a no-op but ensures nfs_is_exclusive_create() does
exactly what the name says.

Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250217003020.3170652-3-neilb@suse.de
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Documentation/filesystems/porting.rst
fs/namei.c
fs/nfs/dir.c
fs/smb/server/vfs.c