From 1fc5b6e67477c6e52c311b4117ff067a60487cdc Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Tue, 19 Jul 2011 16:44:21 -0500 Subject: [PATCH] Revert "afs: Use 64-bit inode numbers" This reverts commit e1e008338639d6cc0d836ff8079e6fb42021ab9e. Using 64-bit inode numbers can make AFS largely inaccessible to 32-bit programs that are not compiled with large file support, since the inode number we provide is not representable in a 32-bit struct stat. Using 64-bit inode numbers thus can break quite a few programs, and has little benefit, so don't do it. Change-Id: Ia482ac2864601b5c56a4259432529d14981f4a1a Reviewed-on: http://gerrit.openafs.org/5048 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/IRIX/osi_idbg.c | 2 +- src/afs/VNOPS/afs_vnop_attrs.c | 1 + src/afs/afs_prototypes.h | 3 ++- src/afs/afs_util.c | 21 +++++++-------------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/afs/IRIX/osi_idbg.c b/src/afs/IRIX/osi_idbg.c index 173be4bb6..369405327 100644 --- a/src/afs/IRIX/osi_idbg.c +++ b/src/afs/IRIX/osi_idbg.c @@ -106,7 +106,7 @@ idbg_afsvfslist() struct vcache *tvc; struct afs_q *tq; struct afs_q *uq; - ino_t nodeid; /* what ls prints as 'inode' */ + afs_int32 nodeid; /* what ls prints as 'inode' */ AFS_GLOCK(); for (tq = VLRU.prev; tq != &VLRU; tq = uq) { diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index 4278cd84e..ef3f774c1 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -117,6 +117,7 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) afs_calc_inum(avc->f.fid.Cell, avc->f.fid.Fid.Volume, avc->f.fid.Fid.Vnode); + attrs->va_nodeid &= 0x7fffffff; /* Saber C hates negative inode #s! */ attrs->va_nlink = fakedir ? 100 : avc->f.m.LinkCount; attrs->va_size = fakedir ? 4096 : avc->f.m.Length; #if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 2483eacbe..535ffc227 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1010,7 +1010,8 @@ extern void afs_MarkUserExpired(afs_int32 pag); /* afs_util.c */ extern afs_int32 afs_strtoi_r(const char *str, char **endptr, afs_uint32 *ret); -extern ino_t afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode); +extern afs_int32 afs_calc_inum(afs_int32 cell, afs_int32 volume, + afs_int32 vnode); #ifndef afs_cv2string extern char *afs_cv2string(char *ttp, afs_uint32 aval); #endif diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c index c9c627fc0..6b4cf1904 100644 --- a/src/afs/afs_util.c +++ b/src/afs/afs_util.c @@ -368,11 +368,10 @@ afs_data_pointer_to_int32(const void *p) } #ifdef AFS_LINUX20_ENV -static_inline ino_t +static_inline afs_int32 afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode) { - ino_t ino = 0; - afs_int32 vno = vnode; + afs_int32 ino = 0, vno = vnode; char digest[16]; struct md5 ct; @@ -395,9 +394,7 @@ afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode) memcpy(&ino, &digest[offset], sizeof(ino)); ino ^= (ino ^ vno) & 1; - - /* Clear MSB to ensure a positive inode number */ - ino &= ~(1ULL << (sizeof(ino) * 8 - 1)); + ino &= 0x7fffffff; /* Assumes 32 bit ino_t ..... */ } } return ino; @@ -406,20 +403,16 @@ afs_calc_inum_md5(afs_int32 cell, afs_int32 volume, afs_int32 vnode) # define afs_calc_inum_md5(cell, volume, vnode) 0 #endif -ino_t +afs_int32 afs_calc_inum(afs_int32 cell, afs_int32 volume, afs_int32 vnode) { - ino_t ino; + afs_int32 ino; ino = afs_calc_inum_md5(cell, volume, vnode); if (ino == 0 || ino == 1) { - /* If we have 32-bit inodes, just shift the volume id 16 bits; but - * if we have 64-bit inodes, we can dedicate 32 bits for the volid, - * and 32 bits for the vnode. */ - ino = ((ino_t)volume << (sizeof(ino)*4)) + vnode; + ino = (volume << 16) + vnode; } - /* Clear MSB to ensure a positive inode number */ - ino &= ~(1ULL << (sizeof(ino) * 8 - 1)); + ino &= 0x7fffffff; /* Assumes 32 bit ino_t ..... */ return ino; } -- 2.39.5