From 394f27b845bb8f3ea95f4f172b46575d7240f824 Mon Sep 17 00:00:00 2001 From: mdf Date: Thu, 27 Sep 2012 23:30:49 +0000 Subject: Fix up kernel sources to be ready for a 64-bit ino_t. Original code by: Gleb Kurtsou --- sys/ufs/ffs/ffs_alloc.c | 26 ++++++++++++++------------ sys/ufs/ffs/ffs_snapshot.c | 31 +++++++++++++++++-------------- sys/ufs/ffs/ffs_softdep.c | 27 +++++++++++++++------------ sys/ufs/ufs/inode.h | 2 +- sys/ufs/ufs/ufs_acl.c | 12 ++++++------ sys/ufs/ufs/ufs_lookup.c | 14 ++++++++------ sys/ufs/ufs/ufs_vnops.c | 4 ++-- 7 files changed, 63 insertions(+), 53 deletions(-) (limited to 'sys/ufs') diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 2b3740d..a7378b6 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -598,7 +598,8 @@ ffs_reallocblks_ufs1(ap) */ #ifdef DEBUG if (prtrealloc) - printf("realloc: ino %d, lbns %jd-%jd\n\told:", ip->i_number, + printf("realloc: ino %ju, lbns %jd-%jd\n\told:", + (uintmax_t)ip->i_number, (intmax_t)start_lbn, (intmax_t)end_lbn); #endif blkno = newblk; @@ -2176,8 +2177,8 @@ ffs_freefile(ump, fs, devvp, ino, mode, wkhd) cgbno = fsbtodb(fs, cgtod(fs, cg)); } if (ino >= fs->fs_ipg * fs->fs_ncg) - panic("ffs_freefile: range: dev = %s, ino = %lu, fs = %s", - devtoname(dev), (u_long)ino, fs->fs_fsmnt); + panic("ffs_freefile: range: dev = %s, ino = %ju, fs = %s", + devtoname(dev), (uintmax_t)ino, fs->fs_fsmnt); if ((error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp))) { brelse(bp); return (error); @@ -2192,8 +2193,8 @@ ffs_freefile(ump, fs, devvp, ino, mode, wkhd) inosused = cg_inosused(cgp); ino %= fs->fs_ipg; if (isclr(inosused, ino)) { - printf("dev = %s, ino = %u, fs = %s\n", devtoname(dev), - ino + cg * fs->fs_ipg, fs->fs_fsmnt); + printf("dev = %s, ino = %ju, fs = %s\n", devtoname(dev), + (uintmax_t)(ino + cg * fs->fs_ipg), fs->fs_fsmnt); if (fs->fs_ronly == 0) panic("ffs_freefile: freeing free inode"); } @@ -2343,8 +2344,9 @@ ffs_fserr(fs, inum, cp) struct thread *td = curthread; /* XXX */ struct proc *p = td->td_proc; - log(LOG_ERR, "pid %d (%s), uid %d inumber %d on %s: %s\n", - p->p_pid, p->p_comm, td->td_ucred->cr_uid, inum, fs->fs_fsmnt, cp); + log(LOG_ERR, "pid %d (%s), uid %d inumber %ju on %s: %s\n", + p->p_pid, p->p_comm, td->td_ucred->cr_uid, (uintmax_t)inum, + fs->fs_fsmnt, cp); } /* @@ -2556,16 +2558,16 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) #ifdef DEBUG if (fsckcmds) { if (cmd.size == 1) - printf("%s: free %s inode %d\n", + printf("%s: free %s inode %ju\n", mp->mnt_stat.f_mntonname, filetype == IFDIR ? "directory" : "file", - (ino_t)cmd.value); + (uintmax_t)cmd.value); else - printf("%s: free %s inodes %d-%d\n", + printf("%s: free %s inodes %ju-%ju\n", mp->mnt_stat.f_mntonname, filetype == IFDIR ? "directory" : "file", - (ino_t)cmd.value, - (ino_t)(cmd.value + cmd.size - 1)); + (uintmax_t)cmd.value, + (uintmax_t)(cmd.value + cmd.size - 1)); } #endif /* DEBUG */ while (cmd.size > 0) { diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 56648af..e528509 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -674,7 +674,8 @@ loop: VI_LOCK(devvp); fs->fs_snapinum[snaploc] = ip->i_number; if (ip->i_nextsnap.tqe_prev != 0) - panic("ffs_snapshot: %d already on list", ip->i_number); + panic("ffs_snapshot: %ju already on list", + (uintmax_t)ip->i_number); TAILQ_INSERT_TAIL(&sn->sn_head, ip, i_nextsnap); devvp->v_vflag |= VV_COPYONWRITE; VI_UNLOCK(devvp); @@ -1571,8 +1572,8 @@ ffs_snapgone(ip) if (xp != NULL) vrele(ITOV(ip)); else if (snapdebug) - printf("ffs_snapgone: lost snapshot vnode %d\n", - ip->i_number); + printf("ffs_snapgone: lost snapshot vnode %ju\n", + (uintmax_t)ip->i_number); /* * Delete snapshot inode from superblock. Keep list dense. */ @@ -1834,9 +1835,10 @@ retry: if (size == fs->fs_bsize) { #ifdef DEBUG if (snapdebug) - printf("%s %d lbn %jd from inum %d\n", - "Grabonremove: snapino", ip->i_number, - (intmax_t)lbn, inum); + printf("%s %ju lbn %jd from inum %ju\n", + "Grabonremove: snapino", + (uintmax_t)ip->i_number, + (intmax_t)lbn, (uintmax_t)inum); #endif /* * If journaling is tracking this write we must add @@ -1878,9 +1880,9 @@ retry: break; #ifdef DEBUG if (snapdebug) - printf("%s%d lbn %jd %s %d size %ld to blkno %jd\n", - "Copyonremove: snapino ", ip->i_number, - (intmax_t)lbn, "for inum", inum, size, + printf("%s%ju lbn %jd %s %ju size %ld to blkno %jd\n", + "Copyonremove: snapino ", (uintmax_t)ip->i_number, + (intmax_t)lbn, "for inum", (uintmax_t)inum, size, (intmax_t)cbp->b_blkno); #endif /* @@ -2021,8 +2023,8 @@ ffs_snapshot_mount(mp) */ VI_LOCK(devvp); if (ip->i_nextsnap.tqe_prev != 0) - panic("ffs_snapshot_mount: %d already on list", - ip->i_number); + panic("ffs_snapshot_mount: %ju already on list", + (uintmax_t)ip->i_number); else TAILQ_INSERT_TAIL(&sn->sn_head, ip, i_nextsnap); vp->v_vflag |= VV_SYSTEM; @@ -2366,12 +2368,13 @@ ffs_copyonwrite(devvp, bp) break; #ifdef DEBUG if (snapdebug) { - printf("Copyonwrite: snapino %d lbn %jd for ", - ip->i_number, (intmax_t)lbn); + printf("Copyonwrite: snapino %ju lbn %jd for ", + (uintmax_t)ip->i_number, (intmax_t)lbn); if (bp->b_vp == devvp) printf("fs metadata"); else - printf("inum %d", VTOI(bp->b_vp)->i_number); + printf("inum %ju", + (uintmax_t)VTOI(bp->b_vp)->i_number); printf(" lblkno %jd to blkno %jd\n", (intmax_t)bp->b_lblkno, (intmax_t)cbp->b_blkno); } diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 3533b07..97b3273 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -4456,8 +4456,8 @@ softdep_setup_mkdir(dp, ip) KASSERT(jaddref != NULL, ("softdep_setup_mkdir: No addref structure present.")); KASSERT(jaddref->ja_parent == dp->i_number, - ("softdep_setup_mkdir: bad parent %d", - jaddref->ja_parent)); + ("softdep_setup_mkdir: bad parent %ju", + (uintmax_t)jaddref->ja_parent)); TAILQ_INSERT_BEFORE(&jaddref->ja_ref, &dotaddref->ja_ref, if_deps); } @@ -8761,8 +8761,8 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) if ((dap->da_state & ATTACHED) == 0) panic("newdirrem: not ATTACHED"); if (dap->da_newinum != ip->i_number) - panic("newdirrem: inum %d should be %d", - ip->i_number, dap->da_newinum); + panic("newdirrem: inum %ju should be %ju", + (uintmax_t)ip->i_number, (uintmax_t)dap->da_newinum); /* * If we are deleting a changed name that never made it to disk, * then return the dirrem describing the previous inode (which @@ -9635,9 +9635,10 @@ initiate_write_filepage(pagedep, bp) ep = (struct direct *) ((char *)bp->b_data + dap->da_offset); if (ep->d_ino != dap->da_newinum) - panic("%s: dir inum %d != new %d", + panic("%s: dir inum %ju != new %ju", "initiate_write_filepage", - ep->d_ino, dap->da_newinum); + (uintmax_t)ep->d_ino, + (uintmax_t)dap->da_newinum); if (dap->da_state & DIRCHG) ep->d_ino = dap->da_previous->dm_oldinum; else @@ -10194,10 +10195,11 @@ softdep_setup_inofree(mp, bp, ino, wkhd) cgp = (struct cg *)bp->b_data; inosused = cg_inosused(cgp); if (isset(inosused, ino % fs->fs_ipg)) - panic("softdep_setup_inofree: inode %d not freed.", ino); + panic("softdep_setup_inofree: inode %ju not freed.", + (uintmax_t)ino); if (inodedep_lookup(mp, ino, 0, &inodedep)) - panic("softdep_setup_inofree: ino %d has existing inodedep %p", - ino, inodedep); + panic("softdep_setup_inofree: ino %ju has existing inodedep %p", + (uintmax_t)ino, inodedep); if (wkhd) { LIST_FOREACH_SAFE(wk, wkhd, wk_list, wkn) { if (wk->wk_type != D_JADDREF) @@ -10423,8 +10425,8 @@ initiate_write_bmsafemap(bmsafemap, bp) jaddref->ja_state |= UNDONE; stat_jaddref++; } else if ((bp->b_xflags & BX_BKGRDMARKER) == 0) - panic("initiate_write_bmsafemap: inode %d " - "marked free", jaddref->ja_ino); + panic("initiate_write_bmsafemap: inode %ju " + "marked free", (uintmax_t)jaddref->ja_ino); } } /* @@ -12498,7 +12500,8 @@ retry: if (dap == LIST_FIRST(diraddhdp)) { inodedep_lookup(UFSTOVFS(ump), inum, 0, &inodedep); panic("flush_pagedep_deps: failed to flush " - "inodedep %p ino %d dap %p", inodedep, inum, dap); + "inodedep %p ino %ju dap %p", + inodedep, (uintmax_t)inum, dap); } } if (error) diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 51f0197..59b170c 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -183,7 +183,7 @@ struct indir { struct ufid { u_int16_t ufid_len; /* Length of structure. */ u_int16_t ufid_pad; /* Force 32-bit alignment. */ - ino_t ufid_ino; /* File number (ino). */ + uint32_t ufid_ino; /* File number (ino). */ int32_t ufid_gen; /* Generation number. */ }; #endif /* _KERNEL */ diff --git a/sys/ufs/ufs/ufs_acl.c b/sys/ufs/ufs/ufs_acl.c index 76a4186..4021b0a 100644 --- a/sys/ufs/ufs/ufs_acl.c +++ b/sys/ufs/ufs/ufs_acl.c @@ -182,8 +182,8 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct thread *td) * are unsafe. */ printf("ufs_getacl_nfs4(): Loaded invalid ACL (" - "%d bytes), inumber %d on %s\n", len, - ip->i_number, ip->i_fs->fs_fsmnt); + "%d bytes), inumber %ju on %s\n", len, + (uintmax_t)ip->i_number, ip->i_fs->fs_fsmnt); return (EPERM); } @@ -191,8 +191,8 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct thread *td) error = acl_nfs4_check(aclp, vp->v_type == VDIR); if (error) { printf("ufs_getacl_nfs4(): Loaded invalid ACL " - "(failed acl_nfs4_check), inumber %d on %s\n", - ip->i_number, ip->i_fs->fs_fsmnt); + "(failed acl_nfs4_check), inumber %ju on %s\n", + (uintmax_t)ip->i_number, ip->i_fs->fs_fsmnt); return (EPERM); } @@ -259,8 +259,8 @@ ufs_get_oldacl(acl_type_t type, struct oldacl *old, struct vnode *vp, * DAC protections are unsafe. */ printf("ufs_get_oldacl(): Loaded invalid ACL " - "(len = %d), inumber %d on %s\n", len, - ip->i_number, ip->i_fs->fs_fsmnt); + "(len = %d), inumber %ju on %s\n", len, + (uintmax_t)ip->i_number, ip->i_fs->fs_fsmnt); return (EPERM); } diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index bcbda6e..d72278d 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -770,11 +770,13 @@ ufs_dirbad(ip, offset, how) mp = ITOV(ip)->v_mount; if ((mp->mnt_flag & MNT_RDONLY) == 0) - panic("ufs_dirbad: %s: bad dir ino %lu at offset %ld: %s", - mp->mnt_stat.f_mntonname, (u_long)ip->i_number, (long)offset, how); + panic("ufs_dirbad: %s: bad dir ino %ju at offset %ld: %s", + mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, + (long)offset, how); else - (void)printf("%s: bad dir ino %lu at offset %ld: %s\n", - mp->mnt_stat.f_mntonname, (u_long)ip->i_number, (long)offset, how); + (void)printf("%s: bad dir ino %ju at offset %ld: %s\n", + mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, + (long)offset, how); } /* @@ -1209,8 +1211,8 @@ ufs_dirremove(dvp, ip, flags, isrmdir) ufsdirhash_remove(dp, rep, dp->i_offset); #endif if (ip && rep->d_ino != ip->i_number) - panic("ufs_dirremove: ip %d does not match dirent ino %d\n", - ip->i_number, rep->d_ino); + panic("ufs_dirremove: ip %ju does not match dirent ino %ju\n", + (uintmax_t)ip->i_number, (uintmax_t)rep->d_ino); if (dp->i_count == 0) { /* * First entry in block: set d_ino to zero. diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index a271cdf..f69b1f9 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1504,8 +1504,8 @@ relock: if (error) panic("ufs_rename: from entry went away!"); if (ino != fip->i_number) - panic("ufs_rename: ino mismatch %d != %d\n", ino, - fip->i_number); + panic("ufs_rename: ino mismatch %ju != %ju\n", + (uintmax_t)ino, (uintmax_t)fip->i_number); } /* * If the source is a directory with a -- cgit v1.1