int rc;
int oflag;
int skip, first;
- afs_hyper_t size;
+ afs_int64 size;
/* If we were asked to skip this volume, then skip it */
if (nskip) {
return 0;
}
if (headerPtr->contd != TC_VOLCONTD) {
- hzero(size);
+ size = 0;
rc = USD_IOCTL(ofd, USD_IOCTL_SETSIZE, &size);
if (rc != 0) {
fprintf(stderr, "Unable to open file %s. Skipping. Code = %d\n",
Rewind(usd_handle_t fid)
{
if (isafile) {
- afs_hyper_t startOff, stopOff;
- hzero(startOff);
+ afs_int64 stopOff;
- return (USD_SEEK(fid, startOff, SEEK_SET, &stopOff));
+ return (USD_SEEK(fid, 0, SEEK_SET, &stopOff));
} else {
return (ForkIoctl(fid, USDTAPE_REW, 0));
}
info->posCount = 0;
#if (defined(AFS_SUN_ENV) || defined(AFS_LINUX24_ENV))
if (!isafile) {
- afs_hyper_t off;
- hset64(off, 0, 0);
+ afs_int64 off;
+
+ off = 0;
USD_IOCTL(fid, USD_IOCTL_SETSIZE, &off);
}
#endif
afs_int32 fcode;
struct tapeLabel *tlabel;
struct progress *p;
- afs_hyper_t off; /* offset */
+ afs_int64 off; /* offset */
if (info->debug)
printf("butm: Write tape label\n");
if (isafile) {
p = (struct progress *)info->tmRock;
- hset64(off, 0, 0);
+ off = 0;
code = USD_IOCTL(p->fid, USD_IOCTL_SETSIZE, &off);
if (code)
ERROR_EXIT(BUTM_POSITION);
afs_int32 code = 0;
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 */
+ afs_int64 stopOff; /* for normal file(non-tape) seeks */
if (info->debug)
printf("butm: Seek to the tape position %d\n", position);
p = (struct progress *)info->tmRock;
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);
+ w = USD_SEEK(p->fid, posit, SEEK_SET, &stopOff);
if (w)
info->error = w;
- if (hcmp(startOff, stopOff) != 0)
+ if (posit != stopOff)
ERROR_EXIT(BUTM_POSITION);
p->reading = p->writing = 0;
afs_int32 blockType;
afs_int32 w;
struct progress *p;
- afs_hyper_t startOff, stopOff; /* file seek offsets */
+ afs_int64 stopOff; /* file seek offsets */
if (info->debug)
printf("butm: Seek to end-of-dump\n");
if (isafile) {
p = (struct progress *)info->tmRock;
- hset64(startOff, 0, 0);
- w = USD_SEEK(p->fid, startOff, SEEK_END, &stopOff);
+ w = USD_SEEK(p->fid, 0, SEEK_END, &stopOff);
if (w) {
info->error = w;
ERROR_EXIT(BUTM_POSITION);
}
- if (hgetlo(stopOff) % BUTM_BLOCKSIZE)
+ if (stopOff % BUTM_BLOCKSIZE)
ERROR_EXIT(BUTM_POSITION);
- info->position = (hgetlo(stopOff) / BUTM_BLOCKSIZE);
+ info->position = (stopOff / BUTM_BLOCKSIZE);
} else {
/* Seek to the desired position */
code = SeekFile(info, (position - info->position) + 1);
static int BackSpace(usd_handle_t hTape, int cnt);
static int PrepTape(usd_handle_t hTape);
static int ShutdownTape(usd_handle_t hTape);
-static int PrintTapePos(usd_handle_t hTape);
+static afs_int64 PrintTapePos(usd_handle_t hTape);
int
main(int argc, char **argv)
}
#ifdef AFS_NT40_ENV
-static int
+static afs_int64
PrintTapePos(usd_handle_t hTape)
{
DWORD rcode;
return (offLow);
}
#else
-static int
+static afs_int64
PrintTapePos(usd_handle_t hTape)
{
- afs_hyper_t startOff, stopOff;
+ afs_int64 startOff, stopOff;
int rcode;
- hset64(startOff, 0, 0);
- hset64(stopOff, 0, 0);
+ startOff = 0;
+ stopOff = 0;
rcode = USD_SEEK(hTape, startOff, SEEK_CUR, &stopOff);
err_exit("Seek", "Tape Seek Test Failed", rcode);
if (USDTEST_DEBUG)
- printf("%s: Cur Tape Pos : %d bytes\n", whoami, stopOff.low);
+ printf("%s: Cur Tape Pos : %"AFS_INT64_FMT" bytes\n", whoami, stopOff);
- return (stopOff.low);
+ return stopOff;
}
#endif
*
* As a consequence of this method of reporting errors, output values are
* returned in reference parameters instead of being encoded in the return
- * value. Also, offsets and lengths use the afs_hyper_t type. */
+ * value. Also, offsets and lengths use the afs_int64 type. */
/* NOTE -- this module is preempt safe. It assume it is being called from a
* preemptive environment. Treat all calls as if they had an "_r"
afs_uint32 * xferdP);
int (*write) (usd_handle_t usd, char *buf, afs_uint32 nbyte,
afs_uint32 * xferdP);
- int (*seek) (usd_handle_t usd, afs_hyper_t inOff, int whence,
- afs_hyper_t * outOffP);
+ int (*seek) (usd_handle_t usd, afs_int64 inOff, int whence,
+ afs_int64 * outOffP);
int (*ioctl) (usd_handle_t usd, int req, void *arg);
int (*close) (usd_handle_t usd);
#define USD_IOCTL_GETDEV 3
-/* GetSize(afs_hyper_t *sizeP) -- returns the size of the file. Doesn't work
+/* GetSize(afs_int64 *sizeP) -- returns the size of the file. Doesn't work
* on BLK or CHR devices. */
#define USD_IOCTL_GETSIZE 6
-/* SetSize(afs_hyper_t *sizeP) -- sets the size of the file. Doesn't work
+/* SetSize(afs_int64 *sizeP) -- sets the size of the file. Doesn't work
* on BLK or CHR devices. */
#define USD_IOCTL_SETSIZE 7
* conversion occur. A good compiler in a 64 bit environment will
* elide the entire statement if the offset type is 64 bits wide.
*/
-#define osi_hFitsInOff(ahyper, noff) \
- ((sizeof(noff) == 4) ? hfitsin32(ahyper) : 1)
-
-#define osi_h2off(ahyper, noff) \
- ((sizeof(noff) == 4) \
- ? ((noff) = (osi_lloff_t)hgetlo(ahyper))\
- : ((noff) = ((osi_lloff_t)hgethi(ahyper)<<32) | (osi_lloff_t)hgetlo(ahyper)))
-
-#define osi_off2h(noff, ahyper) \
- ((sizeof(noff) == 4) \
- ? (hset32(ahyper, (int)noff)) \
- : (hset64(ahyper, (int)((noff>>32)&0xffffffff), ((int)noff&0xffffffff))))
-
+#define osi_hFitsInOff(val) \
+ ((sizeof(osi_lloff_t) == 4) ? (((val) & 0xffffffff00000000LL) == 0) : 1)
/************ End of osi wrappers ***********************************/
extern osi_lloff_t osi_llseek(int, osi_lloff_t, int);
static int
-usd_FileSeek(usd_handle_t usd, afs_hyper_t reqOff, int whence,
- afs_hyper_t * curOffP)
+usd_FileSeek(usd_handle_t usd, afs_int64 reqOff, int whence,
+ afs_int64 * curOffP)
{
int fd = (intptr_t)(usd->handle);
osi_lloff_t lloff;
- if (!osi_hFitsInOff(reqOff, lloff))
+ if (!osi_hFitsInOff(reqOff))
return EINVAL;
- osi_h2off(reqOff, lloff);
- lloff = osi_llseek(fd, lloff, whence);
+ lloff = osi_llseek(fd, reqOff, whence);
if (lloff == (((osi_lloff_t) 0) - 1))
return errno;
if (curOffP)
- osi_off2h(lloff, *curOffP);
+ *curOffP = lloff;
return 0;
}
#ifdef AFS_AIX_ENV
struct statfs fsinfo; /* AIX stat structure doesn't have st_blksize */
#endif /* AFS_AIX_ENV */
- afs_hyper_t size;
- osi_lloff_t off;
+ afs_int64 size;
int code = 0;
switch (req) {
case USD_IOCTL_GETSIZE:
if (S_ISCHR(info.st_mode) || S_ISBLK(info.st_mode))
return ENOTTY; /* shouldn't be a device */
- osi_off2h(info.st_size, *(afs_hyper_t *) arg);
+ *(afs_int64 *)arg = info.st_size;
break;
case USD_IOCTL_GETFULLNAME:
*(char **)arg = usd->fullPathName;
/* However, I'm pretty sure this doesn't work on Ultrix so I am
* unsure about OSF/1 and HP/UX. 931118 */
- size = *(afs_hyper_t *) arg;
- if (!osi_hFitsInOff(size, off))
+ size = *(afs_int64 *) arg;
+ if (!osi_hFitsInOff(size))
return EFBIG;
- osi_h2off(size, off);
#ifdef O_LARGEFILE
- code = ftruncate64(fd, off);
+ code = ftruncate64(fd, size);
#else /* O_LARGEFILE */
- code = ftruncate(fd, off);
+ code = ftruncate(fd, size);
#endif /* O_LARGEFILE */
if (code == -1)
code = errno;
* Add a check of the offset against the disk size to fix this problem. */
static int
-usd_DeviceSeek(usd_handle_t usd, afs_hyper_t reqOff, int whence,
- afs_hyper_t * curOffP)
+usd_DeviceSeek(usd_handle_t usd, afs_int64 reqOff, int whence,
+ afs_int64 * curOffP)
{
HANDLE fd = usd->handle;
DWORD method, result;
DWORD error;
- long loOffset, hiOffset;
+ LARGE_INTEGER offset, retOffset;
/* determine move method based on value of whence */
/* attempt seek */
- loOffset = hgetlo(reqOff);
- hiOffset = hgethi(reqOff);
-
if (usd->privateData) {
/* For disk devices that know their size, check the offset against the
* limit provided by DeviceIoControl(). */
- DWORDLONG offset =
- ((DWORDLONG) hgethi(reqOff) << 32 | (DWORDLONG) hgetlo(reqOff));
-
- DWORDLONG k = (DWORDLONG) ((afs_uint32) usd->privateData);
+ afs_int64 k = ((afs_uint32) usd->privateData);
- if (offset >= (k << 10))
+ if (reqOff >= (k << 10))
return EINVAL;
}
- result = SetFilePointer(fd, loOffset, &hiOffset, method);
- if (result == 0xffffffff && (error = GetLastError()) != NO_ERROR)
+ offset.QuadPart = reqOff;
+
+ result = SetFilePointerEx(fd, offset, &retOffset, method);
+ if (result == 0 && (error = GetLastError()) != NO_ERROR)
return nterr_nt2unix(error, EIO);
+
if (curOffP)
- hset64(*curOffP, hiOffset, result);
+ *curOffP = retOffset.QuadPart;
return 0;
}
usd_DeviceIoctl(usd_handle_t usd, int req, void *arg)
{
HANDLE fd = usd->handle;
+ LARGE_INTEGER size;
DWORD result;
DWORD hiPart;
int code = 0;
break;
case USD_IOCTL_GETSIZE:
- result = GetFileSize(fd, &hiPart);
- if (result == 0xffffffff && (code = GetLastError()) != NO_ERROR)
+ if (!GetFileSizeEx(fd, &size) && (code = GetLastError()) != NO_ERROR)
return nterr_nt2unix(code, EIO);
- hset64(*(afs_hyper_t *) arg, hiPart, result);
+
+ *(afs_int64 *) arg = size.QuadPart;
+
return 0;
case USD_IOCTL_SETSIZE:
- code = usd_DeviceSeek(usd, *(afs_hyper_t *) arg, SEEK_SET, NULL);
+ code = usd_DeviceSeek(usd, *(afs_int64 *) arg, SEEK_SET, NULL);
if (!code) {
if (!SetEndOfFile(fd))
code = nterr_nt2unix(GetLastError(), EIO);
{
usd_handle_t ufd;
int code;
- afs_hyper_t size;
+ afs_int64 size;
code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
if (code) {
long blksize;
afs_int32 error, code;
int ufdIsOpen = 0;
- afs_hyper_t filesize, currOffset;
+ afs_int64 currOffset;
afs_uint32 buffer;
afs_uint32 got;
goto wfail;
}
/* test if we have a valid dump */
- hset64(filesize, 0, 0);
- USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
- hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
- USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
+ USD_SEEK(ufd, 0, SEEK_END, &currOffset);
+ USD_SEEK(ufd, currOffset - sizeof(afs_uint32), SEEK_SET, &currOffset);
USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
error = VOLSERBADOP;
goto wfail;
}
- /* rewind, we are done */
- hset64(filesize, 0, 0);
- USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
+ USD_SEEK(ufd, 0, SEEK_SET, &currOffset);
}
code = SendFile(ufd, call, blksize);
if (code) {
char *filename = (char *)rock;
usd_handle_t ufd; /* default is to stdout */
afs_int32 error = 0, code;
- afs_hyper_t size;
+ afs_int64 size;
long blksize;
int ufdIsOpen = 0;
usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
if (code == 0) {
ufdIsOpen = 1;
- hzero(size);
+ size = 0;
code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
}
if (code == 0) {