Fix bin/ build with a 64-bit ino_t.

Original code by:	Gleb Kurtsou
This commit is contained in:
Matthew D Fleming 2012-09-27 23:31:12 +00:00
parent e25a029eb2
commit 6db1a7f11e
3 changed files with 14 additions and 9 deletions

View File

@ -561,7 +561,8 @@ display(const FTSENT *p, FTSENT *list, int options)
NAMES *np;
off_t maxsize;
long maxblock;
u_long btotal, labelstrlen, maxinode, maxlen, maxnlink;
uintmax_t maxinode;
u_long btotal, labelstrlen, maxlen, maxnlink;
u_long maxlabelstr;
u_int sizelen;
int maxflags;
@ -580,8 +581,9 @@ display(const FTSENT *p, FTSENT *list, int options)
btotal = 0;
initmax = getenv("LS_COLWIDTHS");
/* Fields match -lios order. New ones should be added at the end. */
maxlabelstr = maxblock = maxinode = maxlen = maxnlink =
maxuser = maxgroup = maxflags = maxsize = 0;
maxlabelstr = maxblock = maxlen = maxnlink = 0;
maxuser = maxgroup = maxflags = maxsize = 0;
maxinode = 0;
if (initmax != NULL && *initmax != '\0') {
char *initmax2, *jinitmax;
int ninitmax;
@ -609,7 +611,7 @@ display(const FTSENT *p, FTSENT *list, int options)
strcpy(initmax2, "0");
ninitmax = sscanf(jinitmax,
" %lu : %ld : %lu : %u : %u : %i : %jd : %lu : %lu ",
" %ju : %ld : %lu : %u : %u : %i : %jd : %lu : %lu ",
&maxinode, &maxblock, &maxnlink, &maxuser,
&maxgroup, &maxflags, &maxsize, &maxlen, &maxlabelstr);
f_notabs = 1;
@ -839,7 +841,7 @@ display(const FTSENT *p, FTSENT *list, int options)
d.s_flags = maxflags;
d.s_label = maxlabelstr;
d.s_group = maxgroup;
d.s_inode = snprintf(NULL, 0, "%lu", maxinode);
d.s_inode = snprintf(NULL, 0, "%ju", maxinode);
d.s_nlink = snprintf(NULL, 0, "%lu", maxnlink);
sizelen = f_humanval ? HUMANVALSTR_LEN :
snprintf(NULL, 0, "%ju", maxsize);

View File

@ -152,7 +152,8 @@ printlong(const DISPLAY *dp)
continue;
sp = p->fts_statp;
if (f_inode)
(void)printf("%*lu ", dp->s_inode, (u_long)sp->st_ino);
(void)printf("%*ju ",
dp->s_inode, (uintmax_t)sp->st_ino);
if (f_size)
(void)printf("%*jd ",
dp->s_block, howmany(sp->st_blocks, blocksize));
@ -328,7 +329,8 @@ printaname(const FTSENT *p, u_long inodefield, u_long sizefield)
sp = p->fts_statp;
chcnt = 0;
if (f_inode)
chcnt += printf("%*lu ", (int)inodefield, (u_long)sp->st_ino);
chcnt += printf("%*ju ",
(int)inodefield, (uintmax_t)sp->st_ino);
if (f_size)
chcnt += printf("%*jd ",
(int)sizefield, howmany(sp->st_blocks, blocksize));

View File

@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <fts.h>
#include <grp.h>
#include <pwd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -429,8 +430,8 @@ rm_overwrite(char *file, struct stat *sbp)
if (!S_ISREG(sbp->st_mode))
return (1);
if (sbp->st_nlink > 1 && !fflag) {
warnx("%s (inode %u): not overwritten due to multiple links",
file, sbp->st_ino);
warnx("%s (inode %ju): not overwritten due to multiple links",
file, (uintmax_t)sbp->st_ino);
return (0);
}
if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1)