From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 5/6] commands: stat: fix size display for FILE_SIZE_STREAM
Date: Mon, 6 Jan 2025 10:18:34 +0100 [thread overview]
Message-ID: <20250106091835.3434836-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250106091835.3434836-1-a.fatoum@pengutronix.de>
FILE_SIZE_STREAM is a special value that indicates that the size field
should be ignored as the cdev in question is a stream device.
Teach the stat command about this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/fs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 6d047f197640..8cdd0c55202b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -188,9 +188,13 @@ void stat_print(int dirfd, const char *filename, const struct stat *st)
typeprefix = "cdev link to ";
}
- printf("\n");
+ printf("\nSize: ");
+
+ if (st->st_size == FILE_SIZE_STREAM)
+ printf("%-20s", "stream");
+ else
+ printf("%-20llu", st->st_size);
- printf(" Size: %-20llu", st->st_size);
if (bdev)
printf("Blocks: %llu\tIO Block: %u\t",
(u64)bdev->num_blocks, 1 << bdev->blockbits);
--
2.39.5
next prev parent reply other threads:[~2025-01-06 9:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 9:18 [PATCH 1/6] fs: ramfs: drop unneeded indirection during unlink Ahmad Fatoum
2025-01-06 9:18 ` [PATCH 2/6] fs: squashfs: delete unreferenced source file Ahmad Fatoum
2025-01-06 9:18 ` [PATCH 3/6] fs: collect legacy file system operation in new struct fs_legacy_ops Ahmad Fatoum
2025-01-06 9:18 ` [PATCH 4/6] fs: return error pointer not NULL from cdev_mount_default Ahmad Fatoum
2025-01-06 9:18 ` Ahmad Fatoum [this message]
2025-01-06 9:18 ` [PATCH 6/6] commands: stat: print mode in octal if type unknown Ahmad Fatoum
2025-01-06 10:40 ` [PATCH 1/6] fs: ramfs: drop unneeded indirection during unlink 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=20250106091835.3434836-5-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