From cf6f6bf2501f076160f231de3b5efea804bb72e0 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 12 Apr 2022 09:17:44 -0400 Subject: use two columns for link counts --- ls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ls.c b/ls.c index d792ebc..0a9453d 100644 --- a/ls.c +++ b/ls.c @@ -50,6 +50,7 @@ #endif #define SIZEWIDTH (8) +#define LINKWIDTH (2) static enum { ALPHA, @@ -64,7 +65,7 @@ static enum { HIDE_ALL, HIDE_SOME, HIDE_NONE } ls_hidden = HIDE_ALL; static enum { GROUP_NAME, GROUP_ID, GROUP_NONE } ls_group = GROUP_NAME; static enum { OWNER_NAME, OWNER_ID, OWNER_NONE } ls_owner = OWNER_NAME; static enum { MARK_NONE, MARK_DIRS, MARK_ALL } ls_mark = MARK_NONE; -static enum { BLOCKS_NONE, BLOCKS_POSIX, BLOCKS_KIBI } ls_blocks = BLOCKS_NONE; +static enum { BLOCKS_NONE = 0, BLOCKS_POSIX = 512, BLOCKS_KIBI = 1024 } ls_blocks = BLOCKS_NONE; static int ls_print_inodes = 0; static int ls_questionable = 0; @@ -216,8 +217,7 @@ static int ls_dir(const char *dir, int showdirname) } if (ls_blocks != BLOCKS_NONE) { - /* TODO: adjust for BLOCK_KIBI */ - printf("total %ju\n", blocks); + printf("total %ju\n", ls_blocks == BLOCKS_KIBI ? blocks / 2 : blocks); } qsort(files, nfiles, sizeof(*files), ls_compare_files); @@ -352,7 +352,7 @@ static void ls_print_long(size_t n, struct file_info files[static n]) printf("%s ", ls_file_mode(st)); - printf("%ju ", (uintmax_t)st.st_nlink); + printf("%*ju ", LINKWIDTH, (uintmax_t)st.st_nlink); if (ls_owner != OWNER_NONE) { printf("%*s ", - _POSIX_LOGIN_NAME_MAX, -- cgit v1.2.1