vol-dump-incr-largefile-support-20081222

LICENSE IPL10
FIXES 123984

add large file support for >2gb dumps; add incremental support
This commit is contained in:
Tom Kula 2008-12-22 19:01:46 +00:00 committed by Derrick Brashear
parent 0c52c9b3d9
commit d2ae1c9952

View File

@ -90,11 +90,11 @@ int VolumeChanged; /* needed by physio - leave alone */
int verbose = 0; int verbose = 0;
/* Forward Declarations */ /* Forward Declarations */
void HandleVolume(struct DiskPartition64 *partP, char *name, char *filename); void HandleVolume(struct DiskPartition64 *partP, char *name, char *filename, int fromtime);
Volume *AttachVolume(struct DiskPartition64 *dp, char *volname, Volume *AttachVolume(struct DiskPartition64 *dp, char *volname,
register struct VolumeHeader *header); register struct VolumeHeader *header);
static void DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, static void DoMyVolDump(Volume * vp, struct DiskPartition64 *dp,
char *dumpfile); char *dumpfile, int fromtime);
#ifndef AFS_NT40_ENV #ifndef AFS_NT40_ENV
#include "AFS_component_version_number.c" #include "AFS_component_version_number.c"
@ -176,6 +176,8 @@ handleit(struct cmd_syndesc *as, void *arock)
struct DiskPartition64 *partP = NULL; struct DiskPartition64 *partP = NULL;
char name1[128]; char name1[128];
char tmpPartName[20]; char tmpPartName[20];
int fromtime = 0;
afs_int32 code;
#ifndef AFS_NT40_ENV #ifndef AFS_NT40_ENV
@ -195,6 +197,14 @@ handleit(struct cmd_syndesc *as, void *arock)
fileName = ti->data; fileName = ti->data;
if ((ti = as->parms[3].items)) if ((ti = as->parms[3].items))
verbose = 1; verbose = 1;
if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
code = ktime_DateToInt32(as->parms[4].items->data, &fromtime);
if (code) {
fprintf(STDERR, "failed to parse date '%s' (error=%d))\n",
as->parms[4].items->data, code);
return code;
}
}
DInit(10); DInit(10);
@ -232,12 +242,12 @@ handleit(struct cmd_syndesc *as, void *arock)
} }
(void)afs_snprintf(name1, sizeof name1, VFORMAT, (unsigned long)volumeId); (void)afs_snprintf(name1, sizeof name1, VFORMAT, (unsigned long)volumeId);
HandleVolume(partP, name1, fileName); HandleVolume(partP, name1, fileName, fromtime);
return 0; return 0;
} }
void void
HandleVolume(struct DiskPartition64 *dp, char *name, char *filename) HandleVolume(struct DiskPartition64 *dp, char *name, char *filename, int fromtime)
{ {
struct VolumeHeader header; struct VolumeHeader header;
struct VolumeDiskHeader diskHeader; struct VolumeDiskHeader diskHeader;
@ -279,7 +289,7 @@ HandleVolume(struct DiskPartition64 *dp, char *name, char *filename)
exit(1); exit(1);
} }
DoMyVolDump(vp, dp, filename); DoMyVolDump(vp, dp, filename, fromtime);
} }
@ -298,6 +308,7 @@ main(int argc, char **argv)
cmd_AddParm(ts, "-file", CMD_LIST, CMD_OPTIONAL, "Dump filename"); cmd_AddParm(ts, "-file", CMD_LIST, CMD_OPTIONAL, "Dump filename");
cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL,
"Trace dump progress (very verbose)"); "Trace dump progress (very verbose)");
cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
code = cmd_Dispatch(argc, argv); code = cmd_Dispatch(argc, argv);
return code; return code;
} }
@ -834,17 +845,16 @@ DumpPartial(int dumpfd, register Volume * vp, afs_int32 fromtime,
static void static void
DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, char *dumpfile) DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, char *dumpfile, int fromtime)
{ {
int code = 0; int code = 0;
int fromtime = 0;
int dumpAllDirs = 0; int dumpAllDirs = 0;
int dumpfd = 0; int dumpfd = 0;
if (dumpfile) { if (dumpfile) {
unlink(dumpfile); unlink(dumpfile);
dumpfd = dumpfd =
open(dumpfile, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR); afs_open(dumpfile, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
if (dumpfd < 0) { if (dumpfd < 0) {
fprintf(stderr, "Failed to open dump file! Exiting.\n"); fprintf(stderr, "Failed to open dump file! Exiting.\n");
exit(1); exit(1);