register struct cmd_syndesc *as;
{
- afs_int32 avolid, aserver, apart, code, vcode, err;
+ afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
afs_int32 aoverwrite = ASK;
afs_int32 acreation = 0, alastupdate = 0;
int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
prompt = 'n';
+ aparentid = 0;
if (as->parms[4].items) {
avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
if (avolid == 0) {
&& entry.volumeId[voltype] != avolid) {
avolid = entry.volumeId[voltype];
}
+ aparentid = entry.volumeId[RWVOL];
}
else { /* volume exists - do we do a full incremental or abort */
&& entry.volumeId[voltype] != avolid) {
avolid = entry.volumeId[voltype];
}
+ aparentid = entry.volumeId[RWVOL];
/* A file name was specified - check if volume is on another partition */
vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
}
code =
- UV_RestoreVolume(aserver, apart, avolid, avolname, restoreflags,
- WriteData, afilename);
+ UV_RestoreVolume2(aserver, apart, avolid, aparentid,
+ avolname, restoreflags, WriteData, afilename);
if (code) {
PrintDiagnostics("restore", code);
exit(1);
* after extracting params from the rock
*/
int
-UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
- char tovolname[], int flags, afs_int32(*WriteData) (),
- char *rock)
+UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
+ afs_int32 toparentid, char tovolname[], int flags,
+ afs_int32(*WriteData) (), char *rock)
{
struct rx_connection *toconn, *tempconn;
struct rx_call *tocall;
struct volser_status tstatus;
struct volintInfo vinfo;
char partName[10];
- afs_int32 pvolid;
+ afs_int32 pvolid, pparentid;
afs_int32 temptid;
int success;
struct nvldbentry entry, storeEntry;
}
pvolid = tovolid;
+ pparentid = toparentid;
toconn = UV_Bind(toserver, AFSCONF_VOLUMEPORT);
if (pvolid == 0) { /*alot a new id if needed */
vcode = VLDB_GetEntryByName(tovolname, &entry);
goto refail;
}
pvolid = entry.volumeId[ROVOL];
+ pparentid = entry.volumeId[RWVOL];
} else {
pvolid = entry.volumeId[RWVOL];
+ pparentid = entry.volumeId[RWVOL];
}
}
+ if (!pparentid) pparentid = pvolid;
/* at this point we have a volume id to use/reuse for the volume to be restored */
if (strlen(tovolname) > (VOLSER_OLDMAXVOLNAME - 1)) {
EGOTO1(refail, VOLSERBADOP,
hostutil_GetNameByINet(toserver), partName);
fflush(STDOUT);
code =
- AFSVolCreateVolume(toconn, topart, tovolname, volsertype, 0, &pvolid,
+ AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid, &pvolid,
&totid);
if (code) {
if (flags & RV_FULLRST) { /* full restore: delete then create anew */
VDONE;
code =
- AFSVolCreateVolume(toconn, topart, tovolname, volsertype, 0,
+ AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid,
&pvolid, &totid);
EGOTO1(refail, code, "Could not create new volume %u\n", pvolid);
} else {
oldUpdateDate = 0;
}
- cookie.parent = pvolid;
+ cookie.parent = pparentid;
cookie.type = voltype;
cookie.clone = 0;
strncpy(cookie.name, tovolname, VOLSER_OLDMAXVOLNAME);
error = code;
goto refail;
}
- code = AFSVolSetIdsTypes(toconn, totid, tovolname, voltype, pvolid, 0, 0);
+ code = AFSVolSetIdsTypes(toconn, totid, tovolname, voltype, pparentid, 0, 0);
if (code) {
fprintf(STDERR, "Could not set the right type and ID on %lu\n",
(unsigned long)pvolid);
entry.volumeId[ROVOL] = tstatus.cloneID; /*this should come from status info on the volume if non zero */
} else
entry.volumeId[ROVOL] = INVALID_BID;
- entry.volumeId[RWVOL] = pvolid;
+ entry.volumeId[RWVOL] = pparentid;
entry.cloneId = 0;
if (tstatus.backupID != 0) {
entry.volumeId[BACKVOL] = tstatus.backupID;
return error;
}
+int
+UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
+ char tovolname[], int flags, afs_int32(*WriteData) (),
+ char *rock)
+{
+ return UV_RestoreVolume2(toserver, topart, tovolid, 0, tovolname, flags,
+ WriteData, rock);
+}
+
/*unlocks the vldb entry associated with <volid> */
int