From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] stddev: make reads from /dev/null return 0 bytes
Date: Tue, 22 Apr 2025 09:54:44 +0200 [thread overview]
Message-ID: <20250422075444.218493-1-a.fatoum@pengutronix.de> (raw)
Currently, /dev/null discards all writes, but returns -ENOSYS on read.
Implement read to return 0 always, so it returns EOF immediately.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/stddev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/commands/stddev.c b/commands/stddev.c
index e9b7dcc0d2f3..16cf4e30802d 100644
--- a/commands/stddev.c
+++ b/commands/stddev.c
@@ -64,8 +64,14 @@ static ssize_t null_write(struct cdev *cdev, const void *buf, size_t count, loff
return count;
}
+static ssize_t null_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
+{
+ return 0;
+}
+
static struct cdev_operations nullops = {
.write = null_write,
+ .read = null_read,
};
static int null_init(void)
--
2.39.5
next reply other threads:[~2025-04-22 8:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 7:54 Ahmad Fatoum [this message]
2025-04-22 9:23 ` 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=20250422075444.218493-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