/* Values for the UV_RestoreVolume flags parameter */
/* Also used for UV_CopyVolume and UV_CloneVolume */
-#define RV_FULLRST 0x1
-#define RV_OFFLINE 0x2
-#define RV_RDONLY 0x10000
-#define RV_CPINCR 0x20000
-#define RV_NOVLDB 0x40000
-#define RV_NOCLONE 0x80000
+#define RV_FULLRST 0x00001
+#define RV_OFFLINE 0x00002
+#define RV_CRDUMP 0x00010
+#define RV_CRKEEP 0x00020
+#define RV_CRNEW 0x00040
+#define RV_LUDUMP 0x00100
+#define RV_LUKEEP 0x00200
+#define RV_LUNEW 0x00400
+#define RV_RDONLY 0x10000
+#define RV_CPINCR 0x20000
+#define RV_NOVLDB 0x40000
+#define RV_NOCLONE 0x80000
extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp);
extern int vsu_ExtractName(char rname[], char name[]);
fprintf(STDOUT, " Last Access %s",
ctime((time_t *) & pntr->accessDate));
#endif
- if (pntr->updateDate < pntr->creationDate)
- fprintf(STDOUT, " Last Update %s",
- ctime((time_t *) & pntr->creationDate));
- else
- fprintf(STDOUT, " Last Update %s",
- ctime((time_t *) & pntr->updateDate));
+ fprintf(STDOUT, " Last Update %s",
+ ctime((time_t *) & pntr->updateDate));
fprintf(STDOUT,
" %d accesses in the past day (i.e., vnode references)\n",
pntr->dayUse);
fprintf(STDOUT, " Last Access %s",
ctime((time_t *) & a_xInfoP->accessDate));
#endif
- if (a_xInfoP->updateDate < a_xInfoP->creationDate)
- fprintf(STDOUT, " Last Update %s",
- ctime((time_t *) & a_xInfoP->creationDate));
- else
- fprintf(STDOUT, " Last Update %s",
- ctime((time_t *) & a_xInfoP->updateDate));
+ fprintf(STDOUT, " Last Update %s",
+ ctime((time_t *) & a_xInfoP->updateDate));
fprintf(STDOUT,
" %d accesses in the past day (i.e., vnode references)\n",
a_xInfoP->dayUse);
#define FULL 2
#define INC 3
+#define TS_DUMP 1
+#define TS_KEEP 2
+#define TS_NEW 3
+
static
RestoreVolume(as)
register struct cmd_syndesc *as;
{
afs_int32 avolid, aserver, apart, code, vcode, err;
afs_int32 aoverwrite = ASK;
+ afs_int32 acreation = 0, alastupdate = 0;
int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
char prompt;
char afilename[NameLen], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
voltype = ROVOL;
}
+ if (as->parms[8].items) {
+ if ((strcmp(as->parms[8].items->data, "d") == 0)
+ || (strcmp(as->parms[8].items->data, "dump") == 0)) {
+ acreation = TS_DUMP;
+ } else if ((strcmp(as->parms[8].items->data, "k") == 0)
+ || (strcmp(as->parms[8].items->data, "keep") == 0)) {
+ acreation = TS_KEEP;
+ } else if ((strcmp(as->parms[8].items->data, "n") == 0)
+ || (strcmp(as->parms[8].items->data, "new") == 0)) {
+ acreation = TS_NEW;
+ } else {
+ fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
+ as->parms[8].items->data);
+ exit(1);
+ }
+ }
+
+ if (as->parms[9].items) {
+ if ((strcmp(as->parms[9].items->data, "d") == 0)
+ || (strcmp(as->parms[9].items->data, "dump") == 0)) {
+ alastupdate = TS_DUMP;
+ } else if ((strcmp(as->parms[9].items->data, "k") == 0)
+ || (strcmp(as->parms[9].items->data, "keep") == 0)) {
+ alastupdate = TS_KEEP;
+ } else if ((strcmp(as->parms[9].items->data, "n") == 0)
+ || (strcmp(as->parms[9].items->data, "new") == 0)) {
+ alastupdate = TS_NEW;
+ } else {
+ fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
+ as->parms[9].items->data);
+ exit(1);
+ }
+ }
+
aserver = GetServer(as->parms[0].items->data);
if (aserver == 0) {
fprintf(STDERR, "vos: server '%s' not found in host table\n",
restoreflags |= RV_OFFLINE;
if (readonly)
restoreflags |= RV_RDONLY;
+
+ switch (acreation) {
+ case TS_DUMP:
+ restoreflags |= RV_CRDUMP;
+ break;
+ case TS_KEEP:
+ restoreflags |= RV_CRKEEP;
+ break;
+ case TS_NEW:
+ restoreflags |= RV_CRNEW;
+ break;
+ default:
+ if (aoverwrite == FULL)
+ restoreflags |= RV_CRNEW;
+ else
+ restoreflags |= RV_CRKEEP;
+ }
+
+ switch (alastupdate) {
+ case TS_DUMP:
+ restoreflags |= RV_LUDUMP;
+ break;
+ case TS_KEEP:
+ restoreflags |= RV_LUKEEP;
+ break;
+ case TS_NEW:
+ restoreflags |= RV_LUNEW;
+ break;
+ default:
+ restoreflags |= RV_LUKEEP;
+ }
+
code =
UV_RestoreVolume(aserver, apart, avolid, avolname, restoreflags,
WriteData, afilename);
"leave restored volume offline");
cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
"make restored volume read-only");
+ cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
+ "dump | keep | new");
+ cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
+ "dump | keep | new");
COMMONPARMS;
ts = cmd_CreateSyntax("unlock", LockReleaseCmd, 0,
afs_int32 totid, code, rcode, vcode, terror = 0;
afs_int32 rxError = 0;
struct volser_status tstatus;
+ struct volintInfo vinfo;
char partName[10];
afs_int32 pvolid;
afs_int32 temptid;
int islocked;
struct restoreCookie cookie;
int reuseID;
- afs_int32 newDate, volflag, voltype, volsertype;
+ afs_int32 volflag, voltype, volsertype;
+ afs_int32 oldCreateDate, oldUpdateDate, newCreateDate, newUpdateDate;
int index, same, errcode;
char apartName[10];
EGOTO1(refail, code, "Failed to start transaction on %u\n",
pvolid);
+ code = AFSVolGetStatus(toconn, totid, &tstatus);
+ EGOTO1(refail, code, "Could not get timestamp from volume %u\n",
+ pvolid);
+
+ oldCreateDate = tstatus.creationDate;
+ oldUpdateDate = tstatus.updateDate;
+
code =
AFSVolSetFlags(toconn, totid,
VTDeleteOnSalvage | VTOutOfService);
AFSVolCreateVolume(toconn, topart, tovolname, volsertype, 0,
&pvolid, &totid);
EGOTO1(refail, code, "Could not create new volume %u\n", pvolid);
-
- newDate = 0;
} else {
code =
AFSVolTransCreate(toconn, pvolid, topart, ITOffline, &totid);
code = AFSVolGetStatus(toconn, totid, &tstatus);
EGOTO1(refail, code, "Could not get timestamp from volume %u\n",
pvolid);
- newDate = tstatus.creationDate;
+
+ oldCreateDate = tstatus.creationDate;
+ oldUpdateDate = tstatus.updateDate;
}
+ } else {
+ oldCreateDate = 0;
+ oldUpdateDate = 0;
}
+
cookie.parent = pvolid;
cookie.type = voltype;
cookie.clone = 0;
error = code;
goto refail;
}
- if (!newDate)
- newDate = time(0);
- code = AFSVolSetDate(toconn, totid, newDate);
+
+ if (flags & RV_CRDUMP)
+ newCreateDate = tstatus.creationDate;
+ else if (flags & RV_CRKEEP && oldCreateDate != 0)
+ newCreateDate = oldCreateDate;
+ else
+ newCreateDate = time(0);
+ if (flags & RV_LUDUMP)
+ newUpdateDate = tstatus.updateDate;
+ else if (flags & RV_LUKEEP)
+ newUpdateDate = oldUpdateDate;
+ else
+ newUpdateDate = time(0);
+ code = AFSVolSetDate(toconn,totid, newCreateDate);
if (code) {
- fprintf(STDERR, "Could not set the date on %lu\n",
- (unsigned long)pvolid);
+ fprintf(STDERR, "Could not set the 'creation' date on %u\n", pvolid);
+ error = code;
+ goto refail;
+ }
+
+ memset(&vinfo, 0, sizeof(struct volintInfo));
+ vinfo.dayUse = -1;
+ vinfo.maxquota = -1;
+ vinfo.creationDate = newCreateDate;
+ vinfo.updateDate = newUpdateDate;
+ code = AFSVolSetInfo(toconn, totid, &vinfo);
+ if (code) {
+ fprintf(STDERR, "Could not set the 'last updated' date on %u\n",
+ pvolid);
error = code;
goto refail;
}