Use type-independent formats for printing nlink_t and ino_t.
Extracted from: ino64 work by gleb, mckusick Discussed with: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
6e89d383c7
commit
1c32456953
@ -109,7 +109,8 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp)
|
||||
*/
|
||||
if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
|
||||
f_date[0] = '\0';
|
||||
(void)fprintf(fp, "%s%2u %-12s %-12s ", f_mode, sbp->st_nlink,
|
||||
(void)fprintf(fp, "%s%2ju %-12s %-12s ", f_mode,
|
||||
(uintmax_t)sbp->st_nlink,
|
||||
name_uid(sbp->st_uid, 1), name_gid(sbp->st_gid, 1));
|
||||
|
||||
/*
|
||||
|
@ -224,7 +224,8 @@ statf(FILE *fp, int indent, FTSENT *p)
|
||||
output(fp, indent, &offset, "device=%#jx",
|
||||
(uintmax_t)p->fts_statp->st_rdev);
|
||||
if (keys & F_NLINK && p->fts_statp->st_nlink != 1)
|
||||
output(fp, indent, &offset, "nlink=%u", p->fts_statp->st_nlink);
|
||||
output(fp, indent, &offset, "nlink=%ju",
|
||||
(uintmax_t)p->fts_statp->st_nlink);
|
||||
if (keys & F_SIZE &&
|
||||
(flavor == F_FREEBSD9 || S_ISREG(p->fts_statp->st_mode)))
|
||||
output(fp, indent, &offset, "size=%ju",
|
||||
|
@ -363,7 +363,8 @@ dump_nodes(FILE *fp, const char *dir, NODE *root, int pathlast)
|
||||
appendfield(fp, pathlast, "device=%#jx",
|
||||
(uintmax_t)cur->st_rdev);
|
||||
if (MATCHFLAG(F_NLINK))
|
||||
appendfield(fp, pathlast, "nlink=%d", cur->st_nlink);
|
||||
appendfield(fp, pathlast, "nlink=%ju",
|
||||
(uintmax_t)cur->st_nlink);
|
||||
if (MATCHFLAG(F_SLINK))
|
||||
appendfield(fp, pathlast, "link=%s",
|
||||
vispath(cur->slink));
|
||||
|
@ -73,7 +73,7 @@ shownode(NODE *n, int f, char const *path)
|
||||
if (f & F_MODE)
|
||||
printf(" mode=%o", n->st_mode);
|
||||
if (f & F_NLINK)
|
||||
printf(" nlink=%d", n->st_nlink);
|
||||
printf(" nlink=%ju", (uintmax_t)n->st_nlink);
|
||||
if (f & F_SIZE)
|
||||
printf(" size=%jd", (intmax_t)n->st_size);
|
||||
if (f & F_UID)
|
||||
|
@ -1396,11 +1396,12 @@ ino_adjust(struct suj_ino *sino)
|
||||
ip = ino_read(ino);
|
||||
mode = DIP(ip, di_mode) & IFMT;
|
||||
if (nlink > LINK_MAX)
|
||||
err_suj("ino %ju nlink manipulation error, new %d, old %d\n",
|
||||
(uintmax_t)ino, nlink, DIP(ip, di_nlink));
|
||||
err_suj("ino %ju nlink manipulation error, new %ju, old %d\n",
|
||||
(uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink));
|
||||
if (debug)
|
||||
printf("Adjusting ino %ju, nlink %d, old link %d lastmode %o\n",
|
||||
(uintmax_t)ino, nlink, DIP(ip, di_nlink), sino->si_mode);
|
||||
printf("Adjusting ino %ju, nlink %ju, old link %d lastmode %o\n",
|
||||
(uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink),
|
||||
sino->si_mode);
|
||||
if (mode == 0) {
|
||||
if (debug)
|
||||
printf("ino %ju, zero inode freeing bitmap\n",
|
||||
@ -1419,8 +1420,9 @@ ino_adjust(struct suj_ino *sino)
|
||||
/* If the inode doesn't have enough links to live, free it. */
|
||||
if (nlink < reqlink) {
|
||||
if (debug)
|
||||
printf("ino %ju not enough links to live %d < %d\n",
|
||||
(uintmax_t)ino, nlink, reqlink);
|
||||
printf("ino %ju not enough links to live %ju < %ju\n",
|
||||
(uintmax_t)ino, (uintmax_t)nlink,
|
||||
(uintmax_t)reqlink);
|
||||
ino_reclaim(ip, ino, mode);
|
||||
return;
|
||||
}
|
||||
@ -1657,10 +1659,12 @@ ino_check(struct suj_ino *sino)
|
||||
err_suj("Inode mode/directory type mismatch %o != %o\n",
|
||||
mode, rrec->jr_mode);
|
||||
if (debug)
|
||||
printf("jrefrec: op %d ino %ju, nlink %d, parent %d, "
|
||||
printf("jrefrec: op %d ino %ju, nlink %ju, parent %ju, "
|
||||
"diroff %jd, mode %o, isat %d, isdot %d\n",
|
||||
rrec->jr_op, (uintmax_t)rrec->jr_ino,
|
||||
rrec->jr_nlink, rrec->jr_parent, rrec->jr_diroff,
|
||||
(uintmax_t)rrec->jr_nlink,
|
||||
(uintmax_t)rrec->jr_parent,
|
||||
(uintmax_t)rrec->jr_diroff,
|
||||
rrec->jr_mode, isat, isdot);
|
||||
mode = rrec->jr_mode & IFMT;
|
||||
if (rrec->jr_op == JOP_REMREF)
|
||||
@ -1677,8 +1681,10 @@ ino_check(struct suj_ino *sino)
|
||||
* by one.
|
||||
*/
|
||||
if (debug)
|
||||
printf("ino %ju nlink %d newlinks %d removes %d dotlinks %d\n",
|
||||
(uintmax_t)ino, nlink, newlinks, removes, dotlinks);
|
||||
printf(
|
||||
"ino %ju nlink %ju newlinks %ju removes %ju dotlinks %ju\n",
|
||||
(uintmax_t)ino, (uintmax_t)nlink, (uintmax_t)newlinks,
|
||||
(uintmax_t)removes, (uintmax_t)dotlinks);
|
||||
nlink += newlinks;
|
||||
nlink -= removes;
|
||||
sino->si_linkadj = 1;
|
||||
@ -1962,15 +1968,17 @@ ino_append(union jrec *rec)
|
||||
mvrec = &rec->rec_jmvrec;
|
||||
refrec = &rec->rec_jrefrec;
|
||||
if (debug && mvrec->jm_op == JOP_MVREF)
|
||||
printf("ino move: ino %d, parent %d, diroff %jd, oldoff %jd\n",
|
||||
mvrec->jm_ino, mvrec->jm_parent, mvrec->jm_newoff,
|
||||
mvrec->jm_oldoff);
|
||||
printf("ino move: ino %ju, parent %ju, "
|
||||
"diroff %jd, oldoff %jd\n",
|
||||
(uintmax_t)mvrec->jm_ino, (uintmax_t)mvrec->jm_parent,
|
||||
(uintmax_t)mvrec->jm_newoff, (uintmax_t)mvrec->jm_oldoff);
|
||||
else if (debug &&
|
||||
(refrec->jr_op == JOP_ADDREF || refrec->jr_op == JOP_REMREF))
|
||||
printf("ino ref: op %d, ino %d, nlink %d, "
|
||||
"parent %d, diroff %jd\n",
|
||||
refrec->jr_op, refrec->jr_ino, refrec->jr_nlink,
|
||||
refrec->jr_parent, refrec->jr_diroff);
|
||||
printf("ino ref: op %d, ino %ju, nlink %ju, "
|
||||
"parent %ju, diroff %jd\n",
|
||||
refrec->jr_op, (uintmax_t)refrec->jr_ino,
|
||||
(uintmax_t)refrec->jr_nlink,
|
||||
(uintmax_t)refrec->jr_parent, (uintmax_t)refrec->jr_diroff);
|
||||
sino = ino_lookup(((struct jrefrec *)rec)->jr_ino, 1);
|
||||
sino->si_hasrecs = 1;
|
||||
srec = errmalloc(sizeof(*srec));
|
||||
@ -2182,9 +2190,10 @@ blk_build(struct jblkrec *blkrec)
|
||||
|
||||
if (debug)
|
||||
printf("blk_build: op %d blkno %jd frags %d oldfrags %d "
|
||||
"ino %d lbn %jd\n",
|
||||
blkrec->jb_op, blkrec->jb_blkno, blkrec->jb_frags,
|
||||
blkrec->jb_oldfrags, blkrec->jb_ino, blkrec->jb_lbn);
|
||||
"ino %ju lbn %jd\n",
|
||||
blkrec->jb_op, (uintmax_t)blkrec->jb_blkno,
|
||||
blkrec->jb_frags, blkrec->jb_oldfrags,
|
||||
(uintmax_t)blkrec->jb_ino, (uintmax_t)blkrec->jb_lbn);
|
||||
|
||||
blk = blknum(fs, blkrec->jb_blkno);
|
||||
frag = fragnum(fs, blkrec->jb_blkno);
|
||||
@ -2232,8 +2241,9 @@ ino_build_trunc(struct jtrncrec *rec)
|
||||
struct suj_ino *sino;
|
||||
|
||||
if (debug)
|
||||
printf("ino_build_trunc: op %d ino %d, size %jd\n",
|
||||
rec->jt_op, rec->jt_ino, rec->jt_size);
|
||||
printf("ino_build_trunc: op %d ino %ju, size %jd\n",
|
||||
rec->jt_op, (uintmax_t)rec->jt_ino,
|
||||
(uintmax_t)rec->jt_size);
|
||||
sino = ino_lookup(rec->jt_ino, 1);
|
||||
if (rec->jt_op == JOP_SYNC) {
|
||||
sino->si_trunc = NULL;
|
||||
|
@ -3135,8 +3135,8 @@ nfs_print(struct vop_print_args *ap)
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct nfsnode *np = VTONFS(vp);
|
||||
|
||||
printf("\tfileid %ld fsid 0x%x", np->n_vattr.na_fileid,
|
||||
np->n_vattr.na_fsid);
|
||||
printf("\tfileid %jd fsid 0x%jx", (uintmax_t)np->n_vattr.na_fileid,
|
||||
(uintmax_t)np->n_vattr.na_fsid);
|
||||
if (vp->v_type == VFIFO)
|
||||
fifo_printinfo(vp);
|
||||
printf("\n");
|
||||
|
@ -1286,8 +1286,8 @@ tmpfs_print(struct vop_print_args *v)
|
||||
|
||||
node = VP_TO_TMPFS_NODE(vp);
|
||||
|
||||
printf("tag VT_TMPFS, tmpfs_node %p, flags 0x%lx, links %d\n",
|
||||
node, node->tn_flags, node->tn_links);
|
||||
printf("tag VT_TMPFS, tmpfs_node %p, flags 0x%lx, links %jd\n",
|
||||
node, node->tn_flags, (uintmax_t)node->tn_links);
|
||||
printf("\tmode 0%o, owner %d, group %d, size %jd, status 0x%x\n",
|
||||
node->tn_mode, node->tn_uid, node->tn_gid,
|
||||
(intmax_t)node->tn_size, node->tn_status);
|
||||
|
@ -11525,7 +11525,8 @@ handle_written_inodeblock(inodedep, bp, flags)
|
||||
panic("handle_written_inodeblock: bad size");
|
||||
if (inodedep->id_savednlink > LINK_MAX)
|
||||
panic("handle_written_inodeblock: Invalid link count "
|
||||
"%d for inodedep %p", inodedep->id_savednlink, inodedep);
|
||||
"%jd for inodedep %p", (uintmax_t)inodedep->id_savednlink,
|
||||
inodedep);
|
||||
if (fstype == UFS1) {
|
||||
if (dp1->di_nlink != inodedep->id_savednlink) {
|
||||
dp1->di_nlink = inodedep->id_savednlink;
|
||||
@ -14271,13 +14272,14 @@ softdep_error(func, error)
|
||||
static void
|
||||
inodedep_print(struct inodedep *inodedep, int verbose)
|
||||
{
|
||||
db_printf("%p fs %p st %x ino %jd inoblk %jd delta %d nlink %d"
|
||||
db_printf("%p fs %p st %x ino %jd inoblk %jd delta %jd nlink %jd"
|
||||
" saveino %p\n",
|
||||
inodedep, inodedep->id_fs, inodedep->id_state,
|
||||
(intmax_t)inodedep->id_ino,
|
||||
(intmax_t)fsbtodb(inodedep->id_fs,
|
||||
ino_to_fsba(inodedep->id_fs, inodedep->id_ino)),
|
||||
inodedep->id_nlinkdelta, inodedep->id_savednlink,
|
||||
(intmax_t)inodedep->id_nlinkdelta,
|
||||
(intmax_t)inodedep->id_savednlink,
|
||||
inodedep->id_savedino1);
|
||||
|
||||
if (verbose == 0)
|
||||
|
@ -948,8 +948,8 @@ print_bad_link_count(const char *funcname, struct vnode *dvp)
|
||||
struct inode *dip;
|
||||
|
||||
dip = VTOI(dvp);
|
||||
uprintf("%s: Bad link count %d on parent inode %d in file system %s\n",
|
||||
funcname, dip->i_effnlink, dip->i_number,
|
||||
uprintf("%s: Bad link count %d on parent inode %jd in file system %s\n",
|
||||
funcname, dip->i_effnlink, (intmax_t)dip->i_number,
|
||||
dvp->v_mount->mnt_stat.f_mntonname);
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,11 @@ main(void)
|
||||
if (fstat(pipefd[1], &st2) == -1)
|
||||
err(1, "FAIL: fstat st2");
|
||||
if (st1.st_dev != st2.st_dev || st1.st_dev == 0 || st2.st_dev == 0)
|
||||
errx(1, "FAIL: wrong dev number %d %d", st1.st_dev, st2.st_dev);
|
||||
errx(1, "FAIL: wrong dev number %ju %ju",
|
||||
(uintmax_t)st1.st_dev, (uintmax_t)st2.st_dev);
|
||||
if (st1.st_ino == st2.st_ino)
|
||||
errx(1, "FAIL: inode numbers are equal: %d", st1.st_ino);
|
||||
errx(1, "FAIL: inode numbers are equal: %ju",
|
||||
(uintmax_t)st1.st_ino);
|
||||
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
|
@ -65,7 +65,8 @@ printlong(char *name, char *accpath, struct stat *sb)
|
||||
|
||||
(void)printf("%6ju %8"PRId64" ", (uintmax_t)sb->st_ino, sb->st_blocks);
|
||||
(void)strmode(sb->st_mode, modep);
|
||||
(void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, MAXLOGNAME - 1,
|
||||
(void)printf("%s %3ju %-*s %-*s ", modep, (uintmax_t)sb->st_nlink,
|
||||
MAXLOGNAME - 1,
|
||||
user_from_uid(sb->st_uid, 0), MAXLOGNAME - 1,
|
||||
group_from_gid(sb->st_gid, 0));
|
||||
|
||||
|
@ -1252,8 +1252,8 @@ file_compress(char *file, char *outfile, size_t outsize)
|
||||
if (cflag == 0) {
|
||||
#ifndef SMALL
|
||||
if (isb.st_nlink > 1 && fflag == 0) {
|
||||
maybe_warnx("%s has %d other link%s -- skipping",
|
||||
file, isb.st_nlink - 1,
|
||||
maybe_warnx("%s has %ju other link%s -- skipping",
|
||||
file, (uintmax_t)isb.st_nlink - 1,
|
||||
(isb.st_nlink - 1) == 1 ? "" : "s");
|
||||
close(in);
|
||||
return (-1);
|
||||
@ -1448,8 +1448,8 @@ file_uncompress(char *file, char *outfile, size_t outsize)
|
||||
goto lose;
|
||||
#ifndef SMALL
|
||||
if (isb.st_nlink > 1 && lflag == 0 && fflag == 0) {
|
||||
maybe_warnx("%s has %d other links -- skipping",
|
||||
file, isb.st_nlink - 1);
|
||||
maybe_warnx("%s has %ju other links -- skipping",
|
||||
file, (uintmax_t)isb.st_nlink - 1);
|
||||
goto lose;
|
||||
}
|
||||
if (nflag == 0 && timestamp)
|
||||
|
@ -165,8 +165,9 @@ typeerr: LABEL;
|
||||
if (s->flags & F_NLINK && s->type != F_DIR &&
|
||||
s->st_nlink != p->fts_statp->st_nlink) {
|
||||
LABEL;
|
||||
(void)printf("%slink_count expected %u found %u\n",
|
||||
tab, s->st_nlink, p->fts_statp->st_nlink);
|
||||
(void)printf("%slink_count expected %ju found %ju\n",
|
||||
tab, (uintmax_t)s->st_nlink,
|
||||
(uintmax_t)p->fts_statp->st_nlink);
|
||||
tab = "\t";
|
||||
}
|
||||
if (s->flags & F_SIZE && s->st_size != p->fts_statp->st_size &&
|
||||
|
@ -207,7 +207,8 @@ statf(int indent, FTSENT *p)
|
||||
if (keys & F_MODE && (p->fts_statp->st_mode & MBITS) != mode)
|
||||
output(indent, &offset, "mode=%#o", p->fts_statp->st_mode & MBITS);
|
||||
if (keys & F_NLINK && p->fts_statp->st_nlink != 1)
|
||||
output(indent, &offset, "nlink=%u", p->fts_statp->st_nlink);
|
||||
output(indent, &offset, "nlink=%ju",
|
||||
(uintmax_t)p->fts_statp->st_nlink);
|
||||
if (keys & F_SIZE && S_ISREG(p->fts_statp->st_mode))
|
||||
output(indent, &offset, "size=%jd",
|
||||
(intmax_t)p->fts_statp->st_size);
|
||||
|
@ -64,7 +64,7 @@ shownode(NODE *n, int f, char const *path)
|
||||
if (f & F_MODE)
|
||||
printf(" mode=%o", n->st_mode);
|
||||
if (f & F_NLINK)
|
||||
printf(" nlink=%d", n->st_nlink);
|
||||
printf(" nlink=%ju", (uintmax_t)n->st_nlink);
|
||||
if (f & F_SIZE)
|
||||
printf(" size=%jd", (intmax_t)n->st_size);
|
||||
if (f & F_UID)
|
||||
|
Loading…
Reference in New Issue
Block a user