#include <ctype.h>
-#include <rx/xdr.h>
+#include <afs/opr.h>
#include <rx/rx.h>
+#include <rx/rx_queue.h>
#include <afs/afsint.h>
#include <afs/nfs.h>
#include <afs/errors.h>
struct volintSize *size);
#define MAX_SECTIONS 3
-#define MIN_TLV_TAG 5
+
+/* The TLV range must start above D_MAX */
+#define MIN_TLV_TAG 21
#define MAX_TLV_TAG 0x60
#define MAX_STANDARD_TAG 0x7a
static afs_uint32 oldtags[MAX_SECTIONS][16];
int code, i;
int one_success = 0;
- osi_Assert((iodp->call && iodp->ncalls == 1 && !iodp->calls)
+ opr_Assert((iodp->call && iodp->ncalls == 1 && !iodp->calls)
|| (!iodp->call && iodp->ncalls >= 1 && iodp->calls));
if (iodp->call) {
afs_int32 code, i;
afs_uint32 off = tag >> 5;
afs_uint32 mask = 1 << (tag & 0x1f);
- unsigned char len, buf[8], *p;
+ int len;
+ unsigned char buf[8], *p;
if (!oldtagsInited)
initNonStandardTags();
}
if (tag <= MAX_TLV_TAG) {
len = iod_getc(iodp);
- if (len < 128)
+ if (len == EOF)
+ return VOLSERDUMPERROR;
+ else if (len < 128)
*length = len;
else {
len &= 0x7f;
int vnodeIndex;
fdP = IH_OPEN(vp->vnodeIndex[class].handle);
- osi_Assert(fdP != NULL);
+ opr_Assert(fdP != NULL);
file = FDH_FDOPEN(fdP, "r+");
- osi_Assert(file != NULL);
+ opr_Assert(file != NULL);
size = OS_SIZE(fdP->fd_fd);
- osi_Assert(size != -1);
+ opr_Assert(size != -1);
nVnodes = (size / vcp->diskSize) - 1;
if (nVnodes > 0) {
- osi_Assert((nVnodes + 1) * vcp->diskSize == size);
- osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
+ opr_Assert((nVnodes + 1) * vcp->diskSize == size);
+ opr_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else
nVnodes = 0;
for (vnodeIndex = 0;
if (!code)
code = DumpString(iodp, 'n', V_name(vp));
dumpTimes[0] = fromtime;
- dumpTimes[1] = V_backupDate(vp); /* Until the time the clone was made */
+ switch (V_type(vp)) {
+ case readwriteVolume:
+ dumpTimes[1] = V_updateDate(vp); /* until last update */
+ break;
+ case readonlyVolume:
+ dumpTimes[1] = V_creationDate(vp); /* until clone was updated */
+ break;
+ case backupVolume:
+ /* until backup was made */
+ dumpTimes[1] = V_backupDate(vp) != 0 ? V_backupDate(vp) :
+ V_creationDate(vp);
+ break;
+ default:
+ code = EINVAL;
+ }
if (!code)
code = DumpArrayInt32(iodp, 't', (afs_uint32 *) dumpTimes, 2);
return code;
VAclDiskSize(v));
}
if (VNDISK_GET_INO(v)) {
+ afs_sfsize_t indexlen, disklen;
IH_INIT(ihP, iodp->device, iodp->parentId, VNDISK_GET_INO(v));
fdP = IH_OPEN(ihP);
if (fdP == NULL) {
IH_RELEASE(ihP);
return VOLSERREAD_DUMPERROR;
}
+ VNDISK_GET_LEN(indexlen, v);
+ disklen = FDH_SIZE(fdP);
+ if (indexlen != disklen) {
+ FDH_REALLYCLOSE(fdP);
+ IH_RELEASE(ihP);
+ Log("DumpVnode: volume %lu vnode %lu has inconsistent length "
+ "(index %lu disk %lu); aborting dump\n",
+ (unsigned long)volid, (unsigned long)vnodeNumber,
+ (unsigned long)indexlen, (unsigned long)disklen);
+ return VOLSERREAD_DUMPERROR;
+ }
code = DumpFile(iodp, vnodeNumber, fdP);
FDH_CLOSE(fdP);
IH_RELEASE(ihP);
OS_SYNC(afile->str_fd);
} else {
size = OS_SIZE(fdP->fd_fd);
- osi_Assert(size != -1);
+ opr_Assert(size != -1);
nVnodes =
(size <=
vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize;
if (nVnodes > 0) {
- Buf = malloc(nVnodes * sizeof(afs_foff_t));
+ Buf = calloc(nVnodes, sizeof(afs_foff_t));
if (Buf == NULL) {
STREAM_CLOSE(afile);
FDH_CLOSE(fdP);
return -1;
}
- memset(Buf, 0, nVnodes * sizeof(afs_foff_t));
STREAM_ASEEK(afile, offset = vcp->diskSize);
while (1) {
code = STREAM_READ(vnode, vcp->diskSize, 1, afile);
}
saw_f = 1;
- ino =
- IH_CREATE(V_linkHandle(vp), V_device(vp),
+ tmpH =
+ IH_CREATE_INIT(V_linkHandle(vp), V_device(vp),
VPartitionPath(V_partition(vp)), nearInode,
V_parentId(vp), vnodeNumber,
vnode->uniquifier, vnode->dataVersion);
- if (!VALID_INO(ino)) {
+ if (!tmpH) {
Log("1 Volser: ReadVnodes: IH_CREATE: %s - restore aborted\n",
afs_error_message(errno));
V_needsSalvaged(vp) = 1;
return VOLSERREAD_DUMPERROR;
}
+ ino = tmpH->ih_ino;
nearInode = ino;
VNDISK_SET_INO(vnode, ino);
- IH_INIT(tmpH, vp->device, V_parentId(vp), ino);
fdP = IH_OPEN(tmpH);
if (fdP == NULL) {
Log("1 Volser: ReadVnodes: IH_OPEN: %s - restore aborted\n",
}
FillInt64(filesize, filesize_high, filesize_low);
}
- p = (unsigned char *)malloc(size);
+ p = malloc(size);
if (p == NULL) {
*status = 2;
return (0);
}
if (VNDISK_GET_INO(v)) {
- FillInt64(addvar,0, (v->length + 5));
+ VNDISK_GET_LEN(addvar, v);
+ if (v->vn_length_hi)
+ addvar += 9;
+ else
+ addvar += 5;
AddUInt64(v_size->dump_size, addvar, &v_size->dump_size);
}
return code;
int vnodeIndex;
fdP = IH_OPEN(vp->vnodeIndex[class].handle);
- osi_Assert(fdP != NULL);
+ opr_Assert(fdP != NULL);
file = FDH_FDOPEN(fdP, "r+");
- osi_Assert(file != NULL);
+ opr_Assert(file != NULL);
size = OS_SIZE(fdP->fd_fd);
- osi_Assert(size != -1);
+ opr_Assert(size != -1);
nVnodes = (size / vcp->diskSize) - 1;
if (nVnodes > 0) {
- osi_Assert((nVnodes + 1) * vcp->diskSize == size);
- osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
+ opr_Assert((nVnodes + 1) * vcp->diskSize == size);
+ opr_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else
nVnodes = 0;
for (vnodeIndex = 0;