From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 11/13] fs: pstore: read from the file position
Date: Wed, 18 Nov 2026 15:52:01 +0100 [thread overview]
Message-ID: <20261118-fs-conformance-fixes-v1-11-59b59ec15d47@pengutronix.de> (raw)
In-Reply-To: <20261118-fs-conformance-fixes-v1-0-59b59ec15d47@pengutronix.de>
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@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
next prev parent reply other threads:[~2026-11-18 15:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 14:51 [PATCH 00/13] fs: fixes found by file system conformance tests Sascha Hauer
2026-11-18 14:51 ` [PATCH 01/13] fs: ramfs: zero the rest of a chunk when truncating Sascha Hauer
2026-11-18 14:51 ` [PATCH 02/13] fs: fat: zero-fill files grown by truncate Sascha Hauer
2026-11-18 14:51 ` [PATCH 03/13] fs: keep the file size when O_TRUNC fails Sascha Hauer
2026-11-18 14:51 ` [PATCH 04/13] fs: legacy: return -EPERM when a driver can't create symlinks Sascha Hauer
2026-11-18 14:51 ` [PATCH 05/13] fs: uimagefs: allow opening a file more than once Sascha Hauer
2026-11-18 14:51 ` [PATCH 06/13] fs: nfs: drop the write and truncate stubs Sascha Hauer
2026-11-18 14:51 ` [PATCH 07/13] fs: fat: fix building without CONFIG_FS_FAT_LFN Sascha Hauer
2026-11-18 14:51 ` [PATCH 08/13] fs: bpkfs: skip the data of ignored duplicates Sascha Hauer
2026-11-18 14:51 ` [PATCH 09/13] fs: bpkfs: allow opening a file more than once Sascha Hauer
2026-11-18 14:52 ` [PATCH 10/13] fs: bpkfs: make room for the NUL after the checksum string Sascha Hauer
2026-11-18 14:52 ` Sascha Hauer [this message]
2026-11-18 14:52 ` [PATCH 12/13] fs: pstore: don't free the records when unmounting Sascha Hauer
2026-11-18 14:52 ` [PATCH 13/13] fs: efivarfs: zero-fill variables grown by truncate 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=20261118-fs-conformance-fixes-v1-11-59b59ec15d47@pengutronix.de \
--to=s.hauer@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