From ba9feb14c5f5780758b6d62ebb44cd90b99eccc4 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 2 Sep 2023 16:47:13 +0200 Subject: S_dir_lookup: Handle O_DIRECTORY When e.g. looking up a socket with O_DIRECTORY, we should return ENOTDIR rather than EACCESS. --- libdiskfs/dir-lookup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libdiskfs') diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c index 8df81cfa..76b9cb54 100644 --- a/libdiskfs/dir-lookup.c +++ b/libdiskfs/dir-lookup.c @@ -56,6 +56,7 @@ diskfs_S_dir_lookup (struct protid *dircred, int type; struct protid *newpi = 0; struct peropen *newpo = 0; + int orig_flags = flags; if (!dircred) return EOPNOTSUPP; @@ -447,7 +448,7 @@ diskfs_S_dir_lookup (struct protid *dircred, gotit: type = np->dn_stat.st_mode & S_IFMT; - if (mustbedir && type != S_IFDIR) + if ((mustbedir || orig_flags & O_DIRECTORY) && type != S_IFDIR) { err = ENOTDIR; goto out; -- cgit v1.2.3