[PATCH 10/10] ls: use ~0 for FILE_SIZE_STREAM

Sascha Hauer s.hauer at pengutronix.de
Thu Nov 27 01:19:32 PST 2025


For stream size files we used to show ((loff_t) -1) as file size which
is quite unreadable. Use ~0 in this case.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/ls.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/commands/ls.c b/commands/ls.c
index 1ccd44f7bbc00a03b773b56020a7117ce94b24cd..5c9e0f738b03ae36655b04ec1037811a4abc0423 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -33,8 +33,12 @@ static void ls_one(const char *path, const char* fullname)
 		return;
 
 	mkmodestr(s.st_mode, modestr);
-	printf("%s %*llu %*.*s", modestr, SIZELEN, s.st_size, namelen,
-	       namelen, path);
+	if (s.st_size == FILE_SIZE_STREAM)
+		printf("%s %*s %*.*s", modestr, SIZELEN, "~0", namelen,
+		       namelen, path);
+	else
+		printf("%s %*llu %*.*s", modestr, SIZELEN, s.st_size, namelen,
+			namelen, path);
 
 	if (S_ISLNK(s.st_mode)) {
 		char realname[PATH_MAX];

-- 
2.47.3




More information about the barebox mailing list