From 35088c5ed7b4fbf28d6f1c5ef31794fcde94b946 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 29 Jul 2003 23:36:10 +0000 Subject: [PATCH] STABLE12-butm-restore-from-large-files-20030729 make restore also work from large files (cherry picked from commit f7c4f16110497457263851fed22a0c2ed50521c0) --- src/butm/file_tm.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/butm/file_tm.c b/src/butm/file_tm.c index 07246eea5..4eb6d0426 100644 --- a/src/butm/file_tm.c +++ b/src/butm/file_tm.c @@ -30,6 +30,15 @@ RCSID("$Header$"); #include #include "error_macros.h" +#ifdef O_LARGEFILE +typedef off64_t osi_lloff_t; +#else /* O_LARGEFILE */ +#ifdef AFS_HAVE_LLSEEK +typedef offset_t osi_lloff_t; +#else /* AFS_HAVE_LLSEEK */ +typedef off_t osi_lloff_t; +#endif /* AFS_HAVE_LLSEEK */ +#endif /* O_LARGEFILE */ extern int isafile; @@ -75,7 +84,6 @@ extern int isafile; * in succession (2 or 4 of them ). */ - struct fileMark { /* in network byte order */ afs_int32 magic; afs_uint32 nBytes; @@ -670,7 +678,7 @@ incPosition(info, fid, dataSize) if ( info->posCount >= 2147467264 ) /* 2GB - 16K */ { info->posCount = 0; -#if (defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV)) +#if (defined(AFS_SUN_ENV) || defined(AFS_DEC_ENV) || defined(AFS_LINUX24_ENV)) if (!isafile) { hset64(off, 0, 0); @@ -1574,7 +1582,9 @@ static afs_int32 file_Seek (info, position) afs_int32 position; { afs_int32 code = 0; - afs_int32 posit, w; + afs_int32 w; + osi_lloff_t posit; + afs_uint32 c, d; struct progress *p; afs_hyper_t startOff, stopOff; /* for normal file(non-tape) seeks */ @@ -1588,9 +1598,17 @@ static afs_int32 file_Seek (info, position) if (isafile) { p = (struct progress *)info->tmRock; - posit = (position * BUTM_BLOCKSIZE); - - hset64(startOff, 0, posit); + posit = (osi_lloff_t)position * (osi_lloff_t)BUTM_BLOCKSIZE; + /* Not really necessary to do it this way, should be fixed. */ +#ifdef O_LARGEFILE + c = (posit >> 32); + d = (posit & 0xffffffff); +#else + c = 0; + d = posit; +#endif + hset64(startOff, c, d); + w = USD_SEEK(p->fid, startOff, SEEK_SET, &stopOff); if (w) info->error == w; if (hcmp(startOff, stopOff) != 0) ERROR_EXIT(BUTM_POSITION); -- 2.39.5