/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
/* For the single dump case, it's ok to just return the "bytes written"
* that rx_Write returns, since all the callers of iod_Write abort when
* the returned value is less than they expect. For the multi dump case,
- * I don't think we want half the replicas to go bad just because one
- * connection timed out, but if they all time out, then we should give up.
+ * I don't think we want half the replicas to go bad just because one
+ * connection timed out, but if they all time out, then we should give up.
*/
static int
iod_Write(struct iod *iodp, char *buf, int nbytes)
return VOLSERDUMPERROR;
}
code = iod_Write(iodp, &tag, 1);
+ if (code != 1)
+ return VOLSERDUMPERROR;
return 0;
}
afs_sfsize_t nbytes, howBig;
ssize_t n;
size_t howMany;
- afs_foff_t lcode = 0;
+ afs_foff_t howFar = 0;
byte *p;
afs_uint32 hi, lo;
+ afs_ino_str_t stmp;
#ifndef AFS_NT40_ENV
struct afs_stat status;
#endif
howBig = status.st_size;
#ifdef AFS_AIX_ENV
- /* Unfortunately in AIX valuable fields such as st_blksize are
+ /* Unfortunately in AIX valuable fields such as st_blksize are
* gone from the stat structure.
*/
#if defined(AFS_AIX52_ENV)
if (nbytes < howMany)
howMany = nbytes;
- /* Read the data - unless we know we can't */
- n = (lcode ? 0 : FDH_READ(handleP, p, howMany));
+ /* Read the data */
+ n = FDH_PREAD(handleP, p, howMany, howFar);
+ howFar += n;
/* If read any good data and we null padded previously, log the
* amount that we had null padded.
/* Record the read error */
if (n < 0) {
n = 0;
- Log("1 Volser: DumpFile: Error reading inode %s for vnode %d: %s\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode, afs_error_message(errno));
+ Log("1 Volser: DumpFile: Error reading inode %s for vnode %d: %s\n", PrintInode(stmp, handleP->fd_ih->ih_ino), vnode, afs_error_message(errno));
} else if (!pad) {
- Log("1 Volser: DumpFile: Error reading inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
+ Log("1 Volser: DumpFile: Error reading inode %s for vnode %d\n", PrintInode(stmp, handleP->fd_ih->ih_ino), vnode);
}
- /* Pad the rest of the buffer with zeros. Remember offset we started
+ /* Pad the rest of the buffer with zeros. Remember offset we started
* padding. Keep total tally of padding.
*/
memset(p + n, 0, howMany - n);
/* Now seek over the data we could not get. An error here means we
* can't do the next read.
*/
- lcode = FDH_SEEK(handleP, (size_t)((size - nbytes) + howMany), SEEK_SET);
- if (lcode != ((size - nbytes) + howMany)) {
- if (lcode < 0) {
- Log("1 Volser: DumpFile: Error seeking in inode %s for vnode %d: %s\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode, afs_error_message(errno));
- } else {
- Log("1 Volser: DumpFile: Error seeking in inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode);
- lcode = -1;
- }
- } else {
- lcode = 0;
- }
+ howFar = (size_t)((size - nbytes) + howMany);
}
/* Now write the data out */
nVnodes = (size / vcp->diskSize) - 1;
if (nVnodes > 0) {
assert((nVnodes + 1) * vcp->diskSize == size);
- assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
+ assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else
nVnodes = 0;
for (vnodeIndex = 0;
for (i = 0; i < *sizep; i++) {
if (Buf[i]) {
cnt++;
- STREAM_SEEK(afile, Buf[i], 0);
+ STREAM_ASEEK(afile, Buf[i]);
code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
if (code == 1) {
if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
cnt1++;
if (DoLogging) {
- Log("RestoreVolume %u Cleanup: Removing old vnode=%u inode=%llu size=unknown\n",
- V_id(vp), bitNumberToVnodeNumber(i, class),
+ Log("RestoreVolume %u Cleanup: Removing old vnode=%u inode=%llu size=unknown\n",
+ V_id(vp), bitNumberToVnodeNumber(i, class),
(afs_uintmax_t) VNDISK_GET_INO(vnode));
}
IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(vnode),
V_parentId(vp));
DOPOLL;
}
- STREAM_SEEK(afile, Buf[i], 0);
+ STREAM_ASEEK(afile, Buf[i]);
(void)STREAM_WRITE(zero, vcp->diskSize, 1, afile); /* Zero it out */
}
Buf[i] = 0;
return -1;
}
memset(Buf, 0, nVnodes * sizeof(afs_int32));
- STREAM_SEEK(afile, offset = vcp->diskSize, 0);
+ STREAM_ASEEK(afile, offset = vcp->diskSize);
while (1) {
code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
if (code != 1) {
afs_error_message(errno));
return VOLSERREAD_DUMPERROR;
}
- if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) <
- 0) {
- Log("1 Volser: ReadVnodes: Error seeking into vnode index: %s; restore aborted\n",
- afs_error_message(errno));
- FDH_REALLYCLOSE(fdP);
- return VOLSERREAD_DUMPERROR;
- }
- if (FDH_READ(fdP, &oldvnode, sizeof(oldvnode)) ==
+ if (FDH_PREAD(fdP, &oldvnode, sizeof(oldvnode), vnodeIndexOffset(vcp, vnodeNumber)) ==
sizeof(oldvnode)) {
if (oldvnode.type != vNull && VNDISK_GET_INO(&oldvnode)) {
IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(&oldvnode),
}
}
vnode->vnodeMagic = vcp->magic;
- if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) <
- 0) {
- Log("1 Volser: ReadVnodes: Error seeking into vnode index: %s; restore aborted\n",
- afs_error_message(errno));
- FDH_REALLYCLOSE(fdP);
- return VOLSERREAD_DUMPERROR;
- }
- if (FDH_WRITE(fdP, vnode, vcp->diskSize) != vcp->diskSize) {
+ if (FDH_PWRITE(fdP, vnode, vcp->diskSize, vnodeIndexOffset(vcp, vnodeNumber)) != vcp->diskSize) {
Log("1 Volser: ReadVnodes: Error writing vnode index: %s; restore aborted\n",
afs_error_message(errno));
FDH_REALLYCLOSE(fdP);
break;
}
if (handleP) {
- nBytes = FDH_WRITE(handleP, p, size);
+ nBytes = FDH_PWRITE(handleP, p, size, written);
if (nBytes > 0)
written += nBytes;
if (nBytes != size) {
nVnodes = (size / vcp->diskSize) - 1;
if (nVnodes > 0) {
assert((nVnodes + 1) * vcp->diskSize == size);
- assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0);
+ assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else
nVnodes = 0;
for (vnodeIndex = 0;