mirror of
https://github.com/openbsd/src.git
synced 2025-01-04 23:35:36 -08:00
Fix column padding of inode numbers and block counts >2^32, as well as
display of directory block totals >2^32 ok tedu@
This commit is contained in:
parent
b8a635f685
commit
3e12fe88c8
11
bin/ls/ls.c
11
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);
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user