* [PATCH 1/2] pstore: move slash handling into common function
@ 2024-05-08 11:18 Ahmad Fatoum
2024-05-08 11:18 ` [PATCH 2/2] pstore: add unlink implementation for deleting pstore files Ahmad Fatoum
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-05-08 11:18 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] pstore: add unlink implementation for deleting pstore files
2024-05-08 11:18 [PATCH 1/2] pstore: move slash handling into common function Ahmad Fatoum
@ 2024-05-08 11:18 ` 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
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-05-08 11:18 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
During debugging, it can be useful to delete a pstore file to start
fresh. There's already support for this in the code base using the erase
callback, but it was so far never called. Call it from the newly
introduced unlink operation.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/pstore/fs.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index f2ffc0ac6251..f11db91582aa 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -182,6 +182,29 @@ static int pstore_lseek(struct device *dev, FILE *file, loff_t pos)
return 0;
}
+static int pstore_unlink(struct device *dev, const char *filename)
+{
+ struct list_head *head = dev->priv;
+ struct pstore_private *d;
+ int ret;
+
+ d = pstore_get_by_name(head, filename);
+ if (!d)
+ return -ENOENT;
+
+ if (!d->psi->erase)
+ return -EPERM;
+
+ ret = d->psi->erase(d->type, d->id, d->count, d->psi);
+ if (ret)
+ return ret;
+
+ list_del(&d->list);
+ free(d);
+
+ return 0;
+}
+
static DIR *pstore_opendir(struct device *dev, const char *pathname)
{
DIR *dir;
@@ -256,6 +279,7 @@ static struct fs_driver pstore_driver = {
.close = pstore_close,
.read = pstore_read,
.lseek = pstore_lseek,
+ .unlink = pstore_unlink,
.opendir = pstore_opendir,
.readdir = pstore_readdir,
.closedir = pstore_closedir,
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] pstore: move slash handling into common function
2024-05-08 11:18 [PATCH 1/2] pstore: move slash handling into common function Ahmad Fatoum
2024-05-08 11:18 ` [PATCH 2/2] pstore: add unlink implementation for deleting pstore files Ahmad Fatoum
@ 2024-05-08 12:42 ` Sascha Hauer
2024-05-08 12:43 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-05-08 12:42 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Wed, 08 May 2024 13:18:35 +0200, Ahmad Fatoum wrote:
> 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.
>
>
Applied, thanks!
[1/2] pstore: move slash handling into common function
https://git.pengutronix.de/cgit/barebox/commit/?id=8cca127ca0ab (link may not be stable)
[2/2] pstore: add unlink implementation for deleting pstore files
https://git.pengutronix.de/cgit/barebox/commit/?id=a7ed187e0f88 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] pstore: move slash handling into common function
2024-05-08 11:18 [PATCH 1/2] pstore: move slash handling into common function Ahmad Fatoum
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
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-05-08 12:43 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, May 08, 2024 at 01:18:35PM +0200, Ahmad Fatoum wrote:
> 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.
s/flash/slash while applying.
Sascha
>
> 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
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-08 12:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 11:18 [PATCH 1/2] pstore: move slash handling into common function Ahmad Fatoum
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox