Track backup and restore progress
Track backup and restore progress based on the sizes of the files as they are being added to the tar backup file. Update the progress bar based on the sizes of the files. Change-Id: Idf649efa1db3e91830b4b2add86203a3f30042ff
This commit is contained in:
+8
-3
@@ -94,7 +94,7 @@ tar_set_file_perms(TAR *t, char *realname)
|
||||
|
||||
/* switchboard */
|
||||
int
|
||||
tar_extract_file(TAR *t, char *realname, char *prefix)
|
||||
tar_extract_file(TAR *t, char *realname, char *prefix, const int *progress_fd)
|
||||
{
|
||||
int i;
|
||||
char *lnp;
|
||||
@@ -141,7 +141,7 @@ tar_extract_file(TAR *t, char *realname, char *prefix)
|
||||
}
|
||||
else /* if (TH_ISREG(t)) */ {
|
||||
printf("reg\n");
|
||||
i = tar_extract_regfile(t, realname);
|
||||
i = tar_extract_regfile(t, realname, progress_fd);
|
||||
}
|
||||
|
||||
if (i != 0) {
|
||||
@@ -189,7 +189,7 @@ tar_extract_file(TAR *t, char *realname, char *prefix)
|
||||
|
||||
/* extract regular file */
|
||||
int
|
||||
tar_extract_regfile(TAR *t, char *realname)
|
||||
tar_extract_regfile(TAR *t, char *realname, const int *progress_fd)
|
||||
{
|
||||
//mode_t mode;
|
||||
size_t size;
|
||||
@@ -285,6 +285,11 @@ tar_extract_regfile(TAR *t, char *realname)
|
||||
printf("### done extracting %s\n", filename);
|
||||
#endif
|
||||
|
||||
if (*progress_fd != 0) {
|
||||
unsigned long long file_size = (unsigned long long)(size);
|
||||
write(*progress_fd, &file_size, sizeof(file_size));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -226,7 +226,7 @@ void th_finish(TAR *t);
|
||||
/***** extract.c ***********************************************************/
|
||||
|
||||
/* sequentially extract next file from t */
|
||||
int tar_extract_file(TAR *t, char *realname, char *prefix);
|
||||
int tar_extract_file(TAR *t, char *realname, char *prefix, const int *progress_fd);
|
||||
|
||||
/* extract different file types */
|
||||
int tar_extract_dir(TAR *t, char *realname);
|
||||
@@ -237,7 +237,7 @@ int tar_extract_blockdev(TAR *t, char *realname);
|
||||
int tar_extract_fifo(TAR *t, char *realname);
|
||||
|
||||
/* for regfiles, we need to extract the content blocks as well */
|
||||
int tar_extract_regfile(TAR *t, char *realname);
|
||||
int tar_extract_regfile(TAR *t, char *realname, const int *progress_fd);
|
||||
int tar_skip_regfile(TAR *t);
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ void int_to_oct_nonull(int num, char *oct, size_t octlen);
|
||||
|
||||
/* extract groups of files */
|
||||
int tar_extract_glob(TAR *t, char *globname, char *prefix);
|
||||
int tar_extract_all(TAR *t, char *prefix);
|
||||
int tar_extract_all(TAR *t, char *prefix, const int *progress_fd);
|
||||
|
||||
/* add a whole tree of files */
|
||||
int tar_append_tree(TAR *t, char *realdir, char *savedir, char *exclude);
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@ tar_extract_glob(TAR *t, char *globname, char *prefix)
|
||||
{
|
||||
char *filename;
|
||||
char buf[MAXPATHLEN];
|
||||
int i;
|
||||
int i, fd = 0;
|
||||
|
||||
while ((i = th_read(t)) == 0)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ tar_extract_glob(TAR *t, char *globname, char *prefix)
|
||||
snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
|
||||
else
|
||||
strlcpy(buf, filename, sizeof(buf));
|
||||
if (tar_extract_file(t, filename, prefix) != 0)
|
||||
if (tar_extract_file(t, filename, prefix, &fd) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ tar_extract_glob(TAR *t, char *globname, char *prefix)
|
||||
|
||||
|
||||
int
|
||||
tar_extract_all(TAR *t, char *prefix)
|
||||
tar_extract_all(TAR *t, char *prefix, const int *progress_fd)
|
||||
{
|
||||
char *filename;
|
||||
char buf[MAXPATHLEN];
|
||||
@@ -80,7 +80,7 @@ tar_extract_all(TAR *t, char *prefix)
|
||||
"\"%s\")\n", buf);
|
||||
#endif
|
||||
printf("item name: '%s'\n", filename);
|
||||
if (tar_extract_file(t, buf, prefix) != 0)
|
||||
if (tar_extract_file(t, buf, prefix, progress_fd) != 0)
|
||||
return -1;
|
||||
}
|
||||
return (i == 1 ? 0 : -1);
|
||||
|
||||
Reference in New Issue
Block a user