summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-05-30 16:34:33 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-05-30 16:34:33 +0000
commitaf3070bdd7597a04785c2e13047f208c8cdac9af (patch)
treef51c8345288b85ff2800c4c8060c32b3db453860
parent66de9e9a78cffd1b9bd1cd1e2c73f1876dc2b0dc (diff)
Fix column padding of inode numbers and block counts >2^32, as well as
display of directory block totals >2^32 ok tedu@
-rw-r--r--bin/ls/ls.c11
-rw-r--r--bin/ls/ls.h4
-rw-r--r--bin/ls/print.c8
3 files changed, 13 insertions, 10 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index bbdae89ac19..b82d4952bcb 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ls.c,v 1.37 2011/03/04 21:03:19 okan Exp $ */
+/* $OpenBSD: ls.c,v 1.38 2013/05/30 16:34:32 guenther Exp $ */
/* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */
/*
@@ -412,7 +412,9 @@ display(FTSENT *p, FTSENT *list)
FTSENT *cur;
NAMES *np;
off_t maxsize;
- u_long btotal, maxblock, maxinode, maxlen, maxnlink;
+ u_long maxlen, maxnlink;
+ unsigned long long btotal, maxblock;
+ ino_t maxinode;
int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser;
int entries, needstats;
char *user, *group, buf[21]; /* 64 bits == 20 digits */
@@ -532,11 +534,12 @@ display(FTSENT *p, FTSENT *list)
if (needstats) {
d.bcfile = bcfile;
d.btotal = btotal;
- (void)snprintf(buf, sizeof(buf), "%lu", maxblock);
+ (void)snprintf(buf, sizeof(buf), "%llu", maxblock);
d.s_block = strlen(buf);
d.s_flags = maxflags;
d.s_group = maxgroup;
- (void)snprintf(buf, sizeof(buf), "%lu", maxinode);
+ (void)snprintf(buf, sizeof(buf), "%llu",
+ (unsigned long long)maxinode);
d.s_inode = strlen(buf);
(void)snprintf(buf, sizeof(buf), "%lu", maxnlink);
d.s_nlink = strlen(buf);
diff --git a/bin/ls/ls.h b/bin/ls/ls.h
index fc4f140aeb4..1feebd9324a 100644
--- a/bin/ls/ls.h
+++ b/bin/ls/ls.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ls.h,v 1.8 2007/05/07 18:39:28 millert Exp $ */
+/* $OpenBSD: ls.h,v 1.9 2013/05/30 16:34:32 guenther Exp $ */
/* $NetBSD: ls.h,v 1.7 1995/03/21 09:06:33 cgd Exp $ */
/*
@@ -54,7 +54,7 @@ extern int f_typedir; /* add type character for directories */
typedef struct {
FTSENT *list;
- u_long btotal;
+ unsigned long long btotal;
int bcfile;
int entries;
int maxlen;
diff --git a/bin/ls/print.c b/bin/ls/print.c
index 031ea80c60d..57a0c111a22 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.29 2013/04/23 18:08:40 deraadt Exp $ */
+/* $OpenBSD: print.c,v 1.30 2013/05/30 16:34:32 guenther Exp $ */
/* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */
/*
@@ -83,7 +83,7 @@ printlong(DISPLAY *dp)
char buf[20];
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
- (void)printf("total %lu\n", howmany(dp->btotal, blocksize));
+ (void)printf("total %llu\n", howmany(dp->btotal, blocksize));
for (p = dp->list; p; p = p->fts_link) {
if (IS_NOPRINT(p))
@@ -193,7 +193,7 @@ printcol(DISPLAY *dp)
++numrows;
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
- (void)printf("total %lu\n", howmany(dp->btotal, blocksize));
+ (void)printf("total %llu\n", howmany(dp->btotal, blocksize));
for (row = 0; row < numrows; ++row) {
for (base = row, col = 0;;) {
chcnt = printaname(array[base], dp->s_inode, dp->s_block);
@@ -274,7 +274,7 @@ printacol(DISPLAY *dp)
return;
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
- (void)printf("total %lu\n", howmany(dp->btotal, blocksize));
+ (void)printf("total %llu\n", howmany(dp->btotal, blocksize));
col = 0;
for (p = dp->list; p; p = p->fts_link) {
if (IS_NOPRINT(p))