Download | Plain Text | No Line Numbers


  1. diff -Naur tar-1.18.orig/src/common.h tar-1.18/src/common.h
  2. --- tar-1.18.orig/src/common.h 2007-06-27 15:30:31.000000000 +0200
  3. +++ tar-1.18/src/common.h 2011-01-13 14:08:14.000000000 +0100
  4. @@ -261,6 +261,12 @@
  5.  
  6. GLOBAL bool show_omitted_dirs_option;
  7.  
  8. +GLOBAL unsigned sleep_time;
  9. +GLOBAL unsigned sleep_filenum;
  10. +GLOBAL unsigned sleep_curfilenum;
  11. +GLOBAL unsigned sleep_filesize;
  12. +GLOBAL unsigned sleep_curfilesize;
  13. +
  14. GLOBAL bool sparse_option;
  15. GLOBAL unsigned tar_sparse_major;
  16. GLOBAL unsigned tar_sparse_minor;
  17. diff -Naur tar-1.18.orig/src/extract.c tar-1.18/src/extract.c
  18. --- tar-1.18.orig/src/extract.c 2007-06-27 15:30:31.000000000 +0200
  19. +++ tar-1.18/src/extract.c 2011-01-13 15:17:00.000000000 +0100
  20. @@ -832,6 +832,24 @@
  21. UNKNOWN_PERMSTATUS : ARCHIVED_PERMSTATUS),
  22. typeflag);
  23.  
  24. + if (sleep_filenum > 0)
  25. + ++sleep_curfilenum;
  26. + if (sleep_filesize > 0)
  27. + sleep_curfilesize += current_stat_info.stat.st_size;
  28. + if (sleep_time > 0)
  29. + {
  30. + if (sleep_filenum > 0 && sleep_curfilenum >= sleep_filenum)
  31. + {
  32. + sleep_curfilenum -= sleep_filenum;
  33. + usleep(sleep_time * 1000);
  34. + }
  35. + else if (sleep_filesize > 0 && sleep_curfilesize >= sleep_filesize)
  36. + {
  37. + sleep_curfilesize -= sleep_filesize;
  38. + usleep(sleep_time * 1000);
  39. + }
  40. + }
  41. +
  42. return status;
  43. }
  44.  
  45. @@ -1246,7 +1264,6 @@
  46. }
  47. else
  48. skip_member ();
  49. -
  50. }
  51.  
  52. /* Extract the symbolic links whose final extraction were delayed. */
  53. diff -Naur tar-1.18.orig/src/tar.c tar-1.18/src/tar.c
  54. --- tar-1.18.orig/src/tar.c 2007-06-27 15:30:32.000000000 +0200
  55. +++ tar-1.18/src/tar.c 2011-01-13 14:18:53.000000000 +0100
  56. @@ -307,6 +307,7 @@
  57. SHOW_DEFAULTS_OPTION,
  58. SHOW_OMITTED_DIRS_OPTION,
  59. SHOW_TRANSFORMED_NAMES_OPTION,
  60. + SLEEP_OPTION,
  61. SPARSE_VERSION_OPTION,
  62. STRIP_COMPONENTS_OPTION,
  63. SUFFIX_OPTION,
  64. @@ -543,6 +544,8 @@
  65. N_("ignore zeroed blocks in archive (means EOF)"), GRID+1 },
  66. {"read-full-records", 'B', 0, 0,
  67. N_("reblock as we read (for 4.2BSD pipes)"), GRID+1 },
  68. + {"sleep", SLEEP_OPTION, N_("SLEEP:FILENUM[:FILESIZE]"), 0,
  69. + N_("while extracting sleep SLEEP milliseconds every FILENUM files [or FILESIZE bytes]"), GRID+1 },
  70. #undef GRID
  71.  
  72. #define GRID 80
  73. @@ -1755,6 +1758,29 @@
  74. show_transformed_names_option = true;
  75. break;
  76.  
  77. + case SLEEP_OPTION:
  78. + {
  79. + char *token, *p;
  80. + if ((token = strtok (arg, ":")) == NULL)
  81. + FATAL_ERROR ((0, 0, _("--sleep: Invalid syntax 1")));
  82. + sleep_time = strtoul (token, &p, 10);
  83. + if (*p)
  84. + FATAL_ERROR ((0, 0, _("--sleep: SLEEP is not an integer")));
  85. +
  86. + if ((token = strtok (NULL, ":")) == NULL)
  87. + FATAL_ERROR ((0, 0, _("--sleep: Invalid syntax 2")));
  88. + sleep_filenum = strtoul (token, &p, 10);
  89. + if (*p)
  90. + FATAL_ERROR ((0, 0, _("--sleep: FILENUM is not an integer")));
  91. +
  92. + if ((token = strtok (NULL, ":")) == NULL)
  93. + break;
  94. + sleep_filesize = strtoul (token, &p, 10);
  95. + if (*p)
  96. + FATAL_ERROR ((0, 0, _("--sleep: FILESIZE is not an integer")));
  97. + }
  98. + break;
  99. +
  100. case SUFFIX_OPTION:
  101. backup_option = true;
  102. args->backup_suffix_string = arg;
  103. @@ -1975,6 +2001,7 @@
  104. unquote_option = true;
  105. tar_sparse_major = 1;
  106. tar_sparse_minor = 0;
  107. + sleep_time = sleep_filenum = sleep_curfilenum = sleep_filesize = sleep_curfilesize = 0;
  108.  
  109. owner_option = -1;
  110. group_option = -1;
  111.