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
diff --git a/libtar/extract.c b/libtar/extract.c
index 4526c98..e605aca 100644
--- a/libtar/extract.c
+++ b/libtar/extract.c
@@ -94,7 +94,7 @@
 
 /* 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 @@
 	}
 	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 @@
 
 /* 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 @@
 	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;
 }