[PATCH 11/13] fs: pstore: read from the file position

Sascha Hauer s.hauer at pengutronix.de
Wed Nov 18 06:52:01 PST 2026


pstore reads at a position of its own, which it keeps in the
pstore_private of the file and resets on open. Reads at another
position, like pread(), get data from the wrong place, and so does
any read when the same file is open more than once.

Read from the file position like other file systems do. That makes the
lseek() operation and the position of its own unnecessary.

Fixes: 160d2ed0ba18 ("fs: Add pstore filesystem")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/pstore/fs.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 49ea5edf74..1a0eba4fa4 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -41,7 +41,6 @@ struct pstore_private {
 	struct list_head list;
 	struct pstore_record *record;
 	ssize_t	size;
-	ssize_t pos;
 };
 
 static void free_pstore_private(struct pstore_private *private)
@@ -118,7 +117,6 @@ static int pstore_open(struct device *dev, struct file *file, const char *filena
 
 	file->f_size = d->size;
 	file->private_data = d;
-	d->pos = 0;
 
 	return 0;
 }
@@ -133,21 +131,11 @@ static int pstore_read(struct file *file, void *buf,
 {
 	struct pstore_private *d = file->private_data;
 
-	memcpy(buf, &d->record->buf[d->pos], insize);
-	d->pos += insize;
+	memcpy(buf, &d->record->buf[file->f_pos], insize);
 
 	return insize;
 }
 
-static int pstore_lseek(struct file *file, loff_t pos)
-{
-	struct pstore_private *d = file->private_data;
-
-	d->pos = pos;
-
-	return 0;
-}
-
 static int pstore_unlink(struct device *dev, const char *filename)
 {
 	struct list_head *head = dev->priv;
@@ -249,7 +237,6 @@ static const struct fs_legacy_ops pstore_ops = {
 	.closedir  = pstore_closedir,
 	.stat      = pstore_stat,
 	.read      = pstore_read,
-	.lseek     = pstore_lseek,
 };
 
 static struct fs_driver pstore_driver = {

-- 
2.47.3




More information about the barebox mailing list