From 1920a56ddf7c966353f2dc03fc95dcd7b07dc486 Mon Sep 17 00:00:00 2001 From: Jan Cybulski Date: Mon, 3 Nov 2014 12:13:18 +0100 Subject: [PATCH] ls: Fix displaying total block size of dir Change-Id: I213cfcf5bd4fce5bb33e4034cad3149c40dbf5e8 Signed-off-by: Jan Cybulski --- toys/posix/ls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/posix/ls.c b/toys/posix/ls.c index a651d6e..3699c31 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -324,6 +324,7 @@ static void listfiles(int dirfd, struct dirtree *indir) unsigned long dtlen = 0, ul = 0; unsigned width, flags = toys.optflags, totals[LEN_MAX], len[LEN_MAX], *colsizes = (unsigned *)(toybuf+260), columns = (sizeof(toybuf)-260)/4; + unsigned long blocks = 0; #ifdef USE_SMACK char ctx_buf[SMACK_LABEL_LEN +1]; #else @@ -378,6 +379,7 @@ static void listfiles(int dirfd, struct dirtree *indir) entrylen(sort[ul], len, NULL); for (width=0; width totals[width]) totals[width] = len[width]; + blocks += sort[ul]->st.st_blocks; } // Find largest entry in each field for display alignment @@ -407,8 +409,6 @@ static void listfiles(int dirfd, struct dirtree *indir) if (ul == dtlen) break; } } else if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g|FLAG_s)) { - unsigned long blocks = 0; - if (indir->parent) xprintf("total %lu\n", blocks); } -- 2.7.4