mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] libfile: allow fixup_path_case() to resolve directories
Date: Wed, 26 Aug 2026 11:55:38 +0200	[thread overview]
Message-ID: <20260826095604.2652204-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260826095604.2652204-1-a.fatoum@pengutronix.de>

fixup_path_case() opens the final path component without O_DIRECTORY
and thus fails with -EISDIR if that component is a directory.

The only user so far resolved a file and called fstat() on the fd,
but in future we may extend it to handle directories as well,
so prepare for that.

Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 lib/libfile.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index bd0118a7e5be..35ec631de82f 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -869,7 +869,12 @@ int fixup_path_case(int fd, const char **path)
 		free(imatch);
 
 next_component:
-		fd = openat(fd, curr, next ? O_DIRECTORY : 0);
+		/*
+		 * The final component may be a directory as well, which
+		 * can't be opened without O_DIRECTORY, but O_PATH suffices
+		 * for the fstat() callers usually follow up with.
+		 */
+		fd = openat(fd, curr, next ? O_DIRECTORY : O_PATH);
 		closedir(dir);
 
 		if (fd < 0)
-- 
2.47.3




  reply	other threads:[~2026-08-26  9:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26  9:55 [PATCH 1/2] libfile: advance offset in pread_full() on short reads Ahmad Fatoum
2026-08-26  9:55 ` Ahmad Fatoum [this message]
2026-08-28 12:18 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260826095604.2652204-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox