Download | Plain Text | Line Numbers
diff -Naur tar-1.18.orig/src/common.h tar-1.18/src/common.h
--- tar-1.18.orig/src/common.h 2007-06-27 15:30:31.000000000 +0200
+++ tar-1.18/src/common.h 2011-01-13 14:08:14.000000000 +0100
@@ -261,6 +261,12 @@
GLOBAL bool show_omitted_dirs_option;
+GLOBAL unsigned sleep_time;
+GLOBAL unsigned sleep_filenum;
+GLOBAL unsigned sleep_curfilenum;
+GLOBAL unsigned sleep_filesize;
+GLOBAL unsigned sleep_curfilesize;
+
GLOBAL bool sparse_option;
GLOBAL unsigned tar_sparse_major;
GLOBAL unsigned tar_sparse_minor;
diff -Naur tar-1.18.orig/src/extract.c tar-1.18/src/extract.c
--- tar-1.18.orig/src/extract.c 2007-06-27 15:30:31.000000000 +0200
+++ tar-1.18/src/extract.c 2011-01-13 15:17:00.000000000 +0100
@@ -832,6 +832,24 @@
UNKNOWN_PERMSTATUS : ARCHIVED_PERMSTATUS),
typeflag);
+ if (sleep_filenum > 0)
+ ++sleep_curfilenum;
+ if (sleep_filesize > 0)
+ sleep_curfilesize += current_stat_info.stat.st_size;
+ if (sleep_time > 0)
+ {
+ if (sleep_filenum > 0 && sleep_curfilenum >= sleep_filenum)
+ {
+ sleep_curfilenum -= sleep_filenum;
+ usleep(sleep_time * 1000);
+ }
+ else if (sleep_filesize > 0 && sleep_curfilesize >= sleep_filesize)
+ {
+ sleep_curfilesize -= sleep_filesize;
+ usleep(sleep_time * 1000);
+ }
+ }
+
return status;
}
@@ -1246,7 +1264,6 @@
}
else
skip_member ();
-
}
/* Extract the symbolic links whose final extraction were delayed. */
diff -Naur tar-1.18.orig/src/tar.c tar-1.18/src/tar.c
--- tar-1.18.orig/src/tar.c 2007-06-27 15:30:32.000000000 +0200
+++ tar-1.18/src/tar.c 2011-01-13 14:18:53.000000000 +0100
@@ -307,6 +307,7 @@
SHOW_DEFAULTS_OPTION,
SHOW_OMITTED_DIRS_OPTION,
SHOW_TRANSFORMED_NAMES_OPTION,
+ SLEEP_OPTION,
SPARSE_VERSION_OPTION,
STRIP_COMPONENTS_OPTION,
SUFFIX_OPTION,
@@ -543,6 +544,8 @@
N_("ignore zeroed blocks in archive (means EOF)"), GRID+1 },
{"read-full-records", 'B', 0, 0,
N_("reblock as we read (for 4.2BSD pipes)"), GRID+1 },
+ {"sleep", SLEEP_OPTION, N_("SLEEP:FILENUM[:FILESIZE]"), 0,
+ N_("while extracting sleep SLEEP milliseconds every FILENUM files [or FILESIZE bytes]"), GRID+1 },
#undef GRID
#define GRID 80
@@ -1755,6 +1758,29 @@
show_transformed_names_option = true;
break;
+ case SLEEP_OPTION:
+ {
+ char *token, *p;
+ if ((token = strtok (arg, ":")) == NULL)
+ FATAL_ERROR ((0, 0, _("--sleep: Invalid syntax 1")));
+ sleep_time = strtoul (token, &p, 10);
+ if (*p)
+ FATAL_ERROR ((0, 0, _("--sleep: SLEEP is not an integer")));
+
+ if ((token = strtok (NULL, ":")) == NULL)
+ FATAL_ERROR ((0, 0, _("--sleep: Invalid syntax 2")));
+ sleep_filenum = strtoul (token, &p, 10);
+ if (*p)
+ FATAL_ERROR ((0, 0, _("--sleep: FILENUM is not an integer")));
+
+ if ((token = strtok (NULL, ":")) == NULL)
+ break;
+ sleep_filesize = strtoul (token, &p, 10);
+ if (*p)
+ FATAL_ERROR ((0, 0, _("--sleep: FILESIZE is not an integer")));
+ }
+ break;
+
case SUFFIX_OPTION:
backup_option = true;
args->backup_suffix_string = arg;
@@ -1975,6 +2001,7 @@
unquote_option = true;
tar_sparse_major = 1;
tar_sparse_minor = 0;
+ sleep_time = sleep_filenum = sleep_curfilenum = sleep_filesize = sleep_curfilesize = 0;
owner_option = -1;
group_option = -1;