From 3a33ce4a336223ac8aebe2fc24fd69459ab9e9db Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 6 Jul 2011 16:23:23 -0500 Subject: [PATCH] afs: Use afs_calc_inum everywhere The algorithm for calculating inode numbers was copied in several places in libafs. Make them all use afs_calc_inum instead. Change-Id: Ie835a0b92bf940b78090fd7ca4e36aace1df9767 Reviewed-on: http://gerrit.openafs.org/4919 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/IRIX/osi_idbg.c | 10 ++++---- src/afs/VNOPS/afs_vnop_readdir.c | 40 +++++++++++++------------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/afs/IRIX/osi_idbg.c b/src/afs/IRIX/osi_idbg.c index 89d021cba..369405327 100644 --- a/src/afs/IRIX/osi_idbg.c +++ b/src/afs/IRIX/osi_idbg.c @@ -112,13 +112,13 @@ idbg_afsvfslist() for (tq = VLRU.prev; tq != &VLRU; tq = uq) { tvc = QTOV(tq); uq = QPrev(tq); - nodeid = tvc->f.fid.Fid.Vnode + (tvc->f.fid.Fid.Volume << 16); - nodeid &= 0x7fffffff; - qprintf("avp 0x%x type %s cnt %d pg %d map %d nodeid %d(0x%x)\n", tvc, + nodeid = afs_calc_inum(tvc->f.fid.Cell, tvc->f.fid.Fid.Volume, + tvc->f.fid.Fid.Vnode); + qprintf("avp 0x%x type %s cnt %d pg %d map %d nodeid %lu(0x%lx)\n", tvc, tab_vtypes[((vnode_t *) tvc)->v_type], ((vnode_t *) tvc)->v_count, - (int)VN_GET_PGCNT((vnode_t *) tvc), (int)tvc->mapcnt, nodeid, - nodeid); + (int)VN_GET_PGCNT((vnode_t *) tvc), (int)tvc->mapcnt, + (long unsigned)nodeid, (long unsigned)nodeid); } AFS_GUNLOCK(); return 0; diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index 2dcb576d2..5aca35255 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -42,11 +42,6 @@ * AFS readdir vnodeop and bulk stat support. */ -/* Saber C hates negative inode #s. We're not going to talk about software - * that could fail if it sees a negative inode #. - */ -#define FIXUPSTUPIDINODE(a) ((a) &= 0x7fffffff) - /* BlobScan is supposed to ensure that the blob reference refers to a valid directory entry. It consults the allocation map in the page header to determine whether a blob is actually in use or not. @@ -411,8 +406,8 @@ afs_readdir_move(struct DirEntry *de, struct vcache *vc, struct uio *auio, if (use64BitDirent) { struct min_dirent sdirEntry; - sdirEntry.d_fileno = (Volume << 16) + ntohl(Vnode); - FIXUPSTUPIDINODE(sdirEntry.d_fileno); + sdirEntry.d_fileno = afs_calc_inum(vc->f.fid.Cell, + Volume, ntohl(Vnode)); sdirEntry.d_reclen = rlen; sdirEntry.d_off = (off_t) off; AFS_UIOMOVE(&sdirEntry, AFS_DIRENT64BASESIZE, UIO_READ, auio, @@ -434,8 +429,8 @@ afs_readdir_move(struct DirEntry *de, struct vcache *vc, struct uio *auio, } } else { struct irix5_min_dirent sdirEntry; - sdirEntry.d_fileno = (Volume << 16) + ntohl(Vnode); - FIXUPSTUPIDINODE(sdirEntry.d_fileno); + sdirEntry.d_fileno = afs_calc_inum(vc->f.fid.Cell, + Volume, ntohl(Vnode)); sdirEntry.d_reclen = rlen; sdirEntry.d_off = (afs_int32) off; AFS_UIOMOVE(&sdirEntry, AFS_DIRENT32BASESIZE, UIO_READ, auio, @@ -465,8 +460,7 @@ afs_readdir_move(struct DirEntry *de, struct vcache *vc, struct uio *auio, #else direntp = (struct dirent *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); #endif - direntp->d_ino = (Volume << 16) + ntohl(Vnode); - FIXUPSTUPIDINODE(direntp->d_ino); + direntp->d_ino = afs_calc_inum(vc->f.fid.Cell, Volume, ntohl(Vnode)); #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) direntp->d_offset = off; direntp->d_namlen = slen; @@ -479,8 +473,7 @@ afs_readdir_move(struct DirEntry *de, struct vcache *vc, struct uio *auio, osi_FreeLargeSpace((char *)direntp); #else /* AFS_SUN5_ENV */ /* Note the odd mechanism for building the inode number */ - sdirEntry.d_fileno = (Volume << 16) + ntohl(Vnode); - FIXUPSTUPIDINODE(sdirEntry.d_fileno); + sdirEntry.d_fileno = afs_calc_inum(vc->f.fid.Cell, Volume, ntohl(Vnode)); sdirEntry.d_reclen = rlen; #if !defined(AFS_SGI_ENV) sdirEntry.d_namlen = slen; @@ -507,8 +500,7 @@ afs_readdir_move(struct DirEntry *de, struct vcache *vc, struct uio *auio, struct dirent *dp; dp = osi_AllocLargeSpace(sizeof(struct dirent)); memset(dp, 0, sizeof(struct dirent)); - dp->d_ino = (Volume << 16) + ntohl(Vnode); - FIXUPSTUPIDINODE(dp->d_ino); + dp->d_ino = afs_calc_inum(vc->f.fid.Cell, Volume, ntohl(Vnode)); dp->d_namlen = slen; dp->d_type = afs_readdir_type(vc, de); strcpy(dp->d_name, de->name); @@ -752,9 +744,9 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred) if (len) { /* something to hand over. */ #ifdef AFS_HPUX_ENV - sdirEntry->d_fileno = - (avc->f.fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); - FIXUPSTUPIDINODE(sdirEntry->d_fileno); + sdirEntry->d_fileno = afs_calc_inum(avc->f.fid.Cell, + avc->f.fid.Fid.Volume, + ntohl(ode->fid.vnode)); sdirEntry->d_reclen = rlen = AFS_UIO_RESID(auio); sdirEntry->d_namlen = o_slen; #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV) @@ -820,9 +812,9 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred) DRelease(&nextEntry, 0); /* can't use this one. */ if (len) { #ifdef AFS_HPUX_ENV - sdirEntry->d_fileno = - (avc->f.fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); - FIXUPSTUPIDINODE(sdirEntry->d_fileno); + sdirEntry->d_fileno = afs_calc_inum(avc->f.fid.Cell, + avc->f.fid.Fid.Volume, + ntohl(ode->fid.vnode)); sdirEntry->d_reclen = rlen = AFS_UIO_RESID(auio); sdirEntry->d_namlen = o_slen; #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV) @@ -876,9 +868,9 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred) */ if (len) { #ifdef AFS_HPUX_ENV - sdirEntry->d_fileno = - (avc->f.fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); - FIXUPSTUPIDINODE(sdirEntry->d_fileno); + sdirEntry->d_fileno = afs_calc_inum(avc->f.fid.Cell, + avc->f.fid.Fid.Volume, + ntohl(ode->fid.vnode)); sdirEntry->d_reclen = rlen = len; sdirEntry->d_namlen = o_slen; #if defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV) -- 2.39.5