summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-01-13 13:37:09 +0000
committerkib <kib@FreeBSD.org>2017-01-13 13:37:09 +0000
commita0454e7cff5b13632ab8c24479efd1074f2f8767 (patch)
treea513a4560fc50c02cb44f7a79c5b3aa4d0570725
parent2eaa0f81174966046fba99f19c1f0563fe8ccd78 (diff)
downloadFreeBSD-src-a0454e7cff5b13632ab8c24479efd1074f2f8767.zip
FreeBSD-src-a0454e7cff5b13632ab8c24479efd1074f2f8767.tar.gz
MFC r311522:
Use type-independent formats for printing nlink_t and ino_t.
-rw-r--r--bin/pax/gen_subs.c3
-rw-r--r--contrib/mtree/create.c3
-rw-r--r--contrib/mtree/spec.c3
-rw-r--r--contrib/mtree/specspec.c2
-rw-r--r--sbin/fsck_ffs/suj.c54
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c4
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c4
-rw-r--r--sys/ufs/ffs/ffs_softdep.c8
-rw-r--r--sys/ufs/ufs/ufs_vnops.c4
-rw-r--r--tests/sys/kern/pipe/pipe_ino_test.c6
-rw-r--r--usr.bin/find/ls.c3
-rw-r--r--usr.bin/gzip/gzip.c8
-rw-r--r--usr.sbin/fmtree/compare.c5
-rw-r--r--usr.sbin/fmtree/create.c3
-rw-r--r--usr.sbin/fmtree/specspec.c2
15 files changed, 66 insertions, 46 deletions
diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c
index 232ee77..0e2a1e8 100644
--- a/bin/pax/gen_subs.c
+++ b/bin/pax/gen_subs.c
@@ -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));
/*
diff --git a/contrib/mtree/create.c b/contrib/mtree/create.c
index 8601cfa..eb7bce1 100644
--- a/contrib/mtree/create.c
+++ b/contrib/mtree/create.c
@@ -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",
diff --git a/contrib/mtree/spec.c b/contrib/mtree/spec.c
index 0fb921d..6fbe6f5 100644
--- a/contrib/mtree/spec.c
+++ b/contrib/mtree/spec.c
@@ -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));
diff --git a/contrib/mtree/specspec.c b/contrib/mtree/specspec.c
index 2821fd1..466cb60 100644
--- a/contrib/mtree/specspec.c
+++ b/contrib/mtree/specspec.c
@@ -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)
diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index b265dfc..3ab14d1 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -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;
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 11de5c2..663c4f4 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -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");
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index a6bfbae..2e2fe9f 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -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);
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 812cc56..94ac101 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -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)
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index f7b6ea2..2e8bded 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -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);
}
diff --git a/tests/sys/kern/pipe/pipe_ino_test.c b/tests/sys/kern/pipe/pipe_ino_test.c
index 94692aa..c31e4d5 100644
--- a/tests/sys/kern/pipe/pipe_ino_test.c
+++ b/tests/sys/kern/pipe/pipe_ino_test.c
@@ -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]);
diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c
index 082fd64..953c456 100644
--- a/usr.bin/find/ls.c
+++ b/usr.bin/find/ls.c
@@ -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));
diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c
index 6561c9c..63bde3a 100644
--- a/usr.bin/gzip/gzip.c
+++ b/usr.bin/gzip/gzip.c
@@ -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)
diff --git a/usr.sbin/fmtree/compare.c b/usr.sbin/fmtree/compare.c
index fdd3767..36d3f79 100644
--- a/usr.sbin/fmtree/compare.c
+++ b/usr.sbin/fmtree/compare.c
@@ -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 &&
diff --git a/usr.sbin/fmtree/create.c b/usr.sbin/fmtree/create.c
index 8be9b02..204f40a 100644
--- a/usr.sbin/fmtree/create.c
+++ b/usr.sbin/fmtree/create.c
@@ -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);
diff --git a/usr.sbin/fmtree/specspec.c b/usr.sbin/fmtree/specspec.c
index f85882e..ac70c28 100644
--- a/usr.sbin/fmtree/specspec.c
+++ b/usr.sbin/fmtree/specspec.c
@@ -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)
OpenPOWER on IntegriCloud