From 54fa9d5420eeb3809f01976780885b9e4cb6cdc0 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 1 Nov 2005 16:45:44 +0000 Subject: [PATCH] STABLE14-hpux-vol-package-cleanup-20051101 make inode salvager large partition compliant make namei compile cleanly again (cherry picked from commit 93cd1ed38932e8ddcedc8d082ab739ba949b90c7) --- src/vol/Makefile.in | 3 +++ src/vol/listinodes.c | 44 +++++++++++++++++++++++++++++++++----------- src/vol/namei_ops.c | 16 ++++++++-------- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/vol/Makefile.in b/src/vol/Makefile.in index 27c2691152..c774d758ef 100644 --- a/src/vol/Makefile.in +++ b/src/vol/Makefile.in @@ -147,6 +147,9 @@ listinodes.o: listinodes.c AFS_component_version_number.c hp?00_ux101 | hp_ux10? ) \ ${CC} ${CFLAGS} -D_FILE64 -c ${srcdir}/listinodes.c \ ;; \ + hp_ux11* ) \ + ${CC} ${CFLAGS} -D_FILE_OFFSET_BITS=64 -c ${srcdir}/listinodes.c \ + ;; \ * ) ${CC} ${CFLAGS} -c ${srcdir}/listinodes.c \ ;; \ esac diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index c973ab73df..979cbea97f 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -109,6 +109,28 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, #endif #include "partition.h" +/*@+fcnmacros +macrofcndecl@*/ +#ifdef O_LARGEFILE +#ifdef S_SPLINT_S +extern off64_t afs_lseek(int FD, off64_t O, int F); +#endif /*S_SPLINT_S */ +#define afs_lseek(FD, O, F) lseek64(FD, (off64_t) (O), F) +#define afs_stat stat64 +#define afs_fstat fstat64 +#define afs_open open64 +#define afs_fopen fopen64 +#else /* !O_LARGEFILE */ +#ifdef S_SPLINT_S +extern off_t afs_lseek(int FD, off_t O, int F); +#endif /*S_SPLINT_S */ +#define afs_lseek(FD, O, F) lseek(FD, (off_t) (O), F) +#define afs_stat stat +#define afs_fstat fstat +#define afs_open open +#define afs_fopen fopen +#endif /* !O_LARGEFILE */ +/*@=fcnmacros =macrofcndecl@*/ + /* Notice: parts of this module have been cribbed from vfsck.c */ #define ROOTINODE 2 @@ -248,7 +270,7 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, fmax = fs.s_fsize / (FSBSIZE / 512); /* first invalid blk num */ - pfd = open(rdev, O_RDONLY); + pfd = afs_open(rdev, O_RDONLY); if (pfd < 0) { Log("Unable to open `%s' inode for reading\n", rdev); return -1; @@ -359,7 +381,7 @@ ReadSuper(struct superblock *fs, char *devName) { int pfd; - pfd = open(devName, O_RDONLY); + pfd = afs_open(devName, O_RDONLY); if (pfd < 0) { Log("Unable to open inode on %s for reading superblock.\n", devName); return -1; @@ -797,7 +819,7 @@ xfs_RenameFiles(char *dir, xfs_Rename_t * renames, int n_renames) int_to_base64(stmp, renames[i].uniq)); for (tag = 2, j = 0; j < 64; tag++, j++) { (void)sprintf(npath, "%s.%s", nbase, int_to_base64(stmp, tag)); - fd = open(npath, O_CREAT | O_EXCL | O_RDWR, 0); + fd = afs_open(npath, O_CREAT | O_EXCL | O_RDWR, 0); if (fd > 0) { close(fd); break; @@ -1145,7 +1167,7 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, sleep(10); #endif - pfd = open(rdev, O_RDONLY); + pfd = afs_open(rdev, O_RDONLY); if (pfd <= 0) { sprintf(err1, "Could not open device %s to get inode list\n", rdev); perror(err1); @@ -1286,10 +1308,10 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, i = c * sblock.fs_ipg; e = i + sblock.fs_ipg; #if defined(AFS_HPUX102_ENV) - if (lseek(pfd, dbtoo(fsbtodb(&sblock, itod(&sblock, i))), L_SET) == + if (afs_lseek(pfd, dbtoo(fsbtodb(&sblock, itod(&sblock, i))), L_SET) == -1) { #else - if (lseek(pfd, dbtob(fsbtodb(&sblock, itod(&sblock, i))), L_SET) == + if (afs_lseek(pfd, dbtob(fsbtodb(&sblock, itod(&sblock, i))), L_SET) == -1) { #endif #else @@ -1307,14 +1329,14 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, e = i + super.fs.fs_ipg; #ifdef AFS_OSF_ENV dblk1 = fsbtodb(&super.fs, itod(&super.fs, i)); - if (lseek(pfd, (off_t) ((off_t) dblk1 * DEV_BSIZE), L_SET) == -1) { + if (afs_lseek(pfd, (off_t) ((off_t) dblk1 * DEV_BSIZE), L_SET) == -1) { #else #if defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) f1 = fsbtodb(&super.fs, itod(&super.fs, i)); off = (offset_t) f1 << DEV_BSHIFT; if (llseek(pfd, off, L_SET) == -1) { #else - if (lseek(pfd, dbtob(fsbtodb(&super.fs, itod(&super.fs, i))), L_SET) + if (afs_lseek(pfd, dbtob(fsbtodb(&super.fs, itod(&super.fs, i))), L_SET) == -1) { #endif /* AFS_SUN5_ENV */ #endif /* AFS_OSF_ENV */ @@ -1336,7 +1358,7 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, for (bj = bk = 0; bj < bufsize; bj = bj + 512, bk++) { if ((code = read(pfd, dptr, 512)) != 512) { Log("Error reading inode %d? for partition %s (errno = %d); run vfsck\n", bk + i, partition, errno); - if (lseek(pfd, 512, L_SET) == -1) { + if (afs_lseek(pfd, 512, L_SET) == -1) { Log("Lseek failed\n"); goto out; } @@ -1496,12 +1518,12 @@ bread(int fd, char *buf, daddr_t blk, afs_int32 size) return -1; } #else /* AFS_AIX41_ENV */ - if (lseek(fd, blk * Bsize, 0) < 0) { + if (afs_lseek(fd, blk * Bsize, 0) < 0) { Log("Unable to seek to offset %u for block %u\n", blk * Bsize, blk); } #endif /* AFS_AIX41_ENV */ #else - if (lseek(fd, (off_t) dbtob(blk), L_SET) < 0) { + if (afs_lseek(fd, (off_t) dbtob(blk), L_SET) < 0) { Log("Unable to seek to offset %u for block %u\n", dbtob(blk), blk); } #endif diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index c9aa2c521e..910b1d04e2 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -30,7 +30,7 @@ RCSID #ifdef AFS_AIX_ENV #include #endif -#ifdef AFS_SUN5_ENV +#if defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) #include #endif #include @@ -860,7 +860,7 @@ namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index); if (lockit) { -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) if (lockf(h->fd_fd, F_LOCK, 0) < 0) #else if (flock(h->fd_fd, LOCK_EX) < 0) @@ -879,7 +879,7 @@ namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) bad_getLinkByte: if (lockit) -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) lockf(h->fd_fd, F_ULOCK, 0); #else flock(h->fd_fd, LOCK_UN); @@ -904,7 +904,7 @@ GetFreeTag(IHandle_t * ih, int vno) return -1; /* Only one manipulates at a time. */ -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) { #else if (flock(fdP->fd_fd, LOCK_EX) < 0) { @@ -944,7 +944,7 @@ GetFreeTag(IHandle_t * ih, int vno) goto badGetFreeTag; } FDH_SYNC(fdP); -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) lockf(fdP->fd_fd, F_ULOCK, 0); #else flock(fdP->fd_fd, LOCK_UN); @@ -953,7 +953,7 @@ GetFreeTag(IHandle_t * ih, int vno) return col;; badGetFreeTag: -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) lockf(fdP->fd_fd, F_ULOCK, 0); #else flock(fdP->fd_fd, LOCK_UN); @@ -980,7 +980,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked) namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index); if (!locked) { -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) { #else if (flock(fdP->fd_fd, LOCK_EX) < 0) { @@ -1023,7 +1023,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked) bad_SetLinkCount: -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) +#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) lockf(fdP->fd_fd, F_ULOCK, 0); #else flock(fdP->fd_fd, LOCK_UN);