From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] pstore: move slash handling into common function
Date: Wed, 8 May 2024 13:18:35 +0200 [thread overview]
Message-ID: <20240508111836.307806-1-a.fatoum@pengutronix.de> (raw)
Both open and stat receive a file path and manually skip over the slash
before calling pstore_get_by_name. Follow-up commit adds one more user
of pstore_get_by_name, so instead of duplicating the flash skip a third
time, move it into pstore_get_by_name.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/pstore/fs.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 238a316e9157..f2ffc0ac6251 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -130,6 +130,9 @@ static struct pstore_private *pstore_get_by_name(struct list_head *head,
if (!name)
return NULL;
+ if (name[0] == '/')
+ name++;
+
list_for_each_entry(d, head, list) {
if (strcmp(d->name, name) == 0)
return d;
@@ -143,9 +146,6 @@ static int pstore_open(struct device *dev, FILE *file, const char *filename)
struct list_head *head = dev->priv;
struct pstore_private *d;
- if (filename[0] == '/')
- filename++;
-
d = pstore_get_by_name(head, filename);
if (!d)
return -ENOENT;
@@ -221,9 +221,6 @@ static int pstore_stat(struct device *dev, const char *filename,
{
struct pstore_private *d;
- if (filename[0] == '/')
- filename++;
-
d = pstore_get_by_name(&allpstore, filename);
if (!d)
return -ENOENT;
--
2.39.2
next reply other threads:[~2024-05-08 11:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 11:18 Ahmad Fatoum [this message]
2024-05-08 11:18 ` [PATCH 2/2] pstore: add unlink implementation for deleting pstore files Ahmad Fatoum
2024-05-08 12:42 ` [PATCH 1/2] pstore: move slash handling into common function Sascha Hauer
2024-05-08 12:43 ` 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=20240508111836.307806-1-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