list.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. /* List a tar archive, with support routines for reading a tar archive.
  2. Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
  3. 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
  4. Written by John Gilmore, on 1985-08-26.
  5. This program is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any later
  8. version.
  9. This program is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  12. Public License for more details.
  13. You should have received a copy of the GNU General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  16. /* Define to non-zero for forcing old ctime format instead of ISO format. */
  17. #undef USE_OLD_CTIME
  18. #include <system.h>
  19. #include <quotearg.h>
  20. #include "common.h"
  21. #define max(a, b) ((a) < (b) ? (b) : (a))
  22. union block *current_header; /* points to current archive header */
  23. enum archive_format current_format; /* recognized format */
  24. union block *recent_long_name; /* recent long name header and contents */
  25. union block *recent_long_link; /* likewise, for long link */
  26. size_t recent_long_name_blocks; /* number of blocks in recent_long_name */
  27. size_t recent_long_link_blocks; /* likewise, for long link */
  28. static uintmax_t from_header (const char *, size_t, const char *,
  29. uintmax_t, uintmax_t, bool, bool);
  30. /* Base 64 digits; see Internet RFC 2045 Table 1. */
  31. static char const base_64_digits[64] =
  32. {
  33. 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
  34. 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
  35. 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
  36. 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
  37. '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
  38. };
  39. /* Table of base-64 digit values indexed by unsigned chars.
  40. The value is 64 for unsigned chars that are not base-64 digits. */
  41. static char base64_map[UCHAR_MAX + 1];
  42. static void
  43. base64_init (void)
  44. {
  45. int i;
  46. memset (base64_map, 64, sizeof base64_map);
  47. for (i = 0; i < 64; i++)
  48. base64_map[(int) base_64_digits[i]] = i;
  49. }
  50. /* Main loop for reading an archive. */
  51. void
  52. read_and (void (*do_something) (void))
  53. {
  54. enum read_header status = HEADER_STILL_UNREAD;
  55. enum read_header prev_status;
  56. base64_init ();
  57. name_gather ();
  58. open_archive (ACCESS_READ);
  59. do
  60. {
  61. prev_status = status;
  62. tar_stat_destroy (&current_stat_info);
  63. xheader_destroy (&extended_header);
  64. status = read_header (false);
  65. switch (status)
  66. {
  67. case HEADER_STILL_UNREAD:
  68. case HEADER_SUCCESS_EXTENDED:
  69. abort ();
  70. case HEADER_SUCCESS:
  71. /* Valid header. We should decode next field (mode) first.
  72. Ensure incoming names are null terminated. */
  73. if (! name_match (current_stat_info.file_name)
  74. || (NEWER_OPTION_INITIALIZED (newer_mtime_option)
  75. /* FIXME: We get mtime now, and again later; this causes
  76. duplicate diagnostics if header.mtime is bogus. */
  77. && ((current_stat_info.stat.st_mtime
  78. = TIME_FROM_HEADER (current_header->header.mtime)),
  79. #ifdef ST_MTIM_NSEC
  80. /* FIXME: Grab fractional time stamps from
  81. extended header. */
  82. current_stat_info.stat.st_mtim.ST_MTIM_NSEC = 0,
  83. #endif
  84. OLDER_STAT_TIME (current_stat_info.stat, m)))
  85. || excluded_name (current_stat_info.file_name))
  86. {
  87. switch (current_header->header.typeflag)
  88. {
  89. case GNUTYPE_VOLHDR:
  90. case GNUTYPE_MULTIVOL:
  91. case GNUTYPE_NAMES:
  92. break;
  93. case DIRTYPE:
  94. if (show_omitted_dirs_option)
  95. WARN ((0, 0, _("%s: Omitting"),
  96. quotearg_colon (current_stat_info.file_name)));
  97. /* Fall through. */
  98. default:
  99. decode_header (current_header,
  100. &current_stat_info, &current_format, 0);
  101. skip_member ();
  102. continue;
  103. }
  104. }
  105. (*do_something) ();
  106. continue;
  107. case HEADER_ZERO_BLOCK:
  108. if (block_number_option)
  109. {
  110. char buf[UINTMAX_STRSIZE_BOUND];
  111. fprintf (stdlis, _("block %s: ** Block of NULs **\n"),
  112. STRINGIFY_BIGINT (current_block_ordinal (), buf));
  113. }
  114. set_next_block_after (current_header);
  115. if (!ignore_zeros_option)
  116. {
  117. char buf[UINTMAX_STRSIZE_BOUND];
  118. status = read_header (false);
  119. if (status == HEADER_ZERO_BLOCK)
  120. break;
  121. WARN ((0, 0, _("A lone zero block at %s"),
  122. STRINGIFY_BIGINT (current_block_ordinal (), buf)));
  123. break;
  124. }
  125. status = prev_status;
  126. continue;
  127. case HEADER_END_OF_FILE:
  128. if (block_number_option)
  129. {
  130. char buf[UINTMAX_STRSIZE_BOUND];
  131. fprintf (stdlis, _("block %s: ** End of File **\n"),
  132. STRINGIFY_BIGINT (current_block_ordinal (), buf));
  133. }
  134. break;
  135. case HEADER_FAILURE:
  136. /* If the previous header was good, tell them that we are
  137. skipping bad ones. */
  138. set_next_block_after (current_header);
  139. switch (prev_status)
  140. {
  141. case HEADER_STILL_UNREAD:
  142. ERROR ((0, 0, _("This does not look like a tar archive")));
  143. /* Fall through. */
  144. case HEADER_ZERO_BLOCK:
  145. case HEADER_SUCCESS:
  146. if (block_number_option)
  147. {
  148. char buf[UINTMAX_STRSIZE_BOUND];
  149. off_t block_ordinal = current_block_ordinal ();
  150. block_ordinal -= recent_long_name_blocks;
  151. block_ordinal -= recent_long_link_blocks;
  152. fprintf (stdlis, _("block %s: "),
  153. STRINGIFY_BIGINT (block_ordinal, buf));
  154. }
  155. ERROR ((0, 0, _("Skipping to next header")));
  156. break;
  157. case HEADER_END_OF_FILE:
  158. case HEADER_FAILURE:
  159. /* We are in the middle of a cascade of errors. */
  160. break;
  161. case HEADER_SUCCESS_EXTENDED:
  162. abort ();
  163. }
  164. continue;
  165. }
  166. break;
  167. }
  168. while (!all_names_found (&current_stat_info));
  169. close_archive ();
  170. names_notfound (); /* print names not found */
  171. }
  172. /* Print a header block, based on tar options. */
  173. void
  174. list_archive (void)
  175. {
  176. /* Print the header block. */
  177. decode_header (current_header, &current_stat_info, &current_format, 0);
  178. if (verbose_option)
  179. print_header (&current_stat_info, -1);
  180. if (incremental_option && current_header->header.typeflag == GNUTYPE_DUMPDIR)
  181. {
  182. off_t size;
  183. size_t written, check;
  184. union block *data_block;
  185. set_next_block_after (current_header);
  186. if (multi_volume_option)
  187. {
  188. assign_string (&save_name, current_stat_info.file_name);
  189. save_totsize = current_stat_info.stat.st_size;
  190. }
  191. for (size = current_stat_info.stat.st_size; size > 0; size -= written)
  192. {
  193. if (multi_volume_option)
  194. save_sizeleft = size;
  195. data_block = find_next_block ();
  196. if (!data_block)
  197. {
  198. ERROR ((0, 0, _("Unexpected EOF in archive")));
  199. break; /* FIXME: What happens, then? */
  200. }
  201. written = available_space_after (data_block);
  202. if (written > size)
  203. written = size;
  204. errno = 0;
  205. check = fwrite (data_block->buffer, sizeof (char), written, stdlis);
  206. set_next_block_after ((union block *)
  207. (data_block->buffer + written - 1));
  208. if (check != written)
  209. {
  210. write_error_details (current_stat_info.file_name, check, written);
  211. skip_file (size - written);
  212. break;
  213. }
  214. }
  215. if (multi_volume_option)
  216. assign_string (&save_name, 0);
  217. fputc ('\n', stdlis);
  218. fflush (stdlis);
  219. return;
  220. }
  221. if (multi_volume_option)
  222. assign_string (&save_name, current_stat_info.file_name);
  223. skip_member ();
  224. if (multi_volume_option)
  225. assign_string (&save_name, 0);
  226. }
  227. /* Check header checksum */
  228. /* The standard BSD tar sources create the checksum by adding up the
  229. bytes in the header as type char. I think the type char was unsigned
  230. on the PDP-11, but it's signed on the Next and Sun. It looks like the
  231. sources to BSD tar were never changed to compute the checksum
  232. correctly, so both the Sun and Next add the bytes of the header as
  233. signed chars. This doesn't cause a problem until you get a file with
  234. a name containing characters with the high bit set. So tar_checksum
  235. computes two checksums -- signed and unsigned. */
  236. enum read_header
  237. tar_checksum (union block *header, bool silent)
  238. {
  239. size_t i;
  240. int unsigned_sum = 0; /* the POSIX one :-) */
  241. int signed_sum = 0; /* the Sun one :-( */
  242. int recorded_sum;
  243. uintmax_t parsed_sum;
  244. char *p;
  245. p = header->buffer;
  246. for (i = sizeof *header; i-- != 0;)
  247. {
  248. unsigned_sum += (unsigned char) *p;
  249. signed_sum += (signed char) (*p++);
  250. }
  251. if (unsigned_sum == 0)
  252. return HEADER_ZERO_BLOCK;
  253. /* Adjust checksum to count the "chksum" field as blanks. */
  254. for (i = sizeof header->header.chksum; i-- != 0;)
  255. {
  256. unsigned_sum -= (unsigned char) header->header.chksum[i];
  257. signed_sum -= (signed char) (header->header.chksum[i]);
  258. }
  259. unsigned_sum += ' ' * sizeof header->header.chksum;
  260. signed_sum += ' ' * sizeof header->header.chksum;
  261. parsed_sum = from_header (header->header.chksum,
  262. sizeof header->header.chksum, 0,
  263. (uintmax_t) 0,
  264. (uintmax_t) TYPE_MAXIMUM (int), true, silent);
  265. if (parsed_sum == (uintmax_t) -1)
  266. return HEADER_FAILURE;
  267. recorded_sum = parsed_sum;
  268. if (unsigned_sum != recorded_sum && signed_sum != recorded_sum)
  269. return HEADER_FAILURE;
  270. return HEADER_SUCCESS;
  271. }
  272. /* Read a block that's supposed to be a header block. Return its
  273. address in "current_header", and if it is good, the file's size in
  274. current_stat_info.stat.st_size.
  275. Return 1 for success, 0 if the checksum is bad, EOF on eof, 2 for a
  276. block full of zeros (EOF marker).
  277. If RAW_EXTENDED_HEADERS is nonzero, do not automagically fold the
  278. GNU long name and link headers into later headers.
  279. You must always set_next_block_after(current_header) to skip past
  280. the header which this routine reads. */
  281. enum read_header
  282. read_header (bool raw_extended_headers)
  283. {
  284. union block *header;
  285. union block *header_copy;
  286. char *bp;
  287. union block *data_block;
  288. size_t size, written;
  289. union block *next_long_name = 0;
  290. union block *next_long_link = 0;
  291. size_t next_long_name_blocks;
  292. size_t next_long_link_blocks;
  293. while (1)
  294. {
  295. enum read_header status;
  296. header = find_next_block ();
  297. current_header = header;
  298. if (!header)
  299. return HEADER_END_OF_FILE;
  300. if ((status = tar_checksum (header, false)) != HEADER_SUCCESS)
  301. return status;
  302. /* Good block. Decode file size and return. */
  303. if (header->header.typeflag == LNKTYPE)
  304. current_stat_info.stat.st_size = 0; /* links 0 size on tape */
  305. else
  306. current_stat_info.stat.st_size = OFF_FROM_HEADER (header->header.size);
  307. if (header->header.typeflag == GNUTYPE_LONGNAME
  308. || header->header.typeflag == GNUTYPE_LONGLINK
  309. || header->header.typeflag == XHDTYPE
  310. || header->header.typeflag == XGLTYPE)
  311. {
  312. if (raw_extended_headers)
  313. return HEADER_SUCCESS_EXTENDED;
  314. else if (header->header.typeflag == GNUTYPE_LONGNAME
  315. || header->header.typeflag == GNUTYPE_LONGLINK)
  316. {
  317. size_t name_size = current_stat_info.stat.st_size;
  318. size_t n = name_size % BLOCKSIZE;
  319. size = name_size + BLOCKSIZE;
  320. if (n)
  321. size += BLOCKSIZE - n;
  322. if (name_size != current_stat_info.stat.st_size
  323. || size < name_size)
  324. xalloc_die ();
  325. header_copy = xmalloc (size + 1);
  326. if (header->header.typeflag == GNUTYPE_LONGNAME)
  327. {
  328. if (next_long_name)
  329. free (next_long_name);
  330. next_long_name = header_copy;
  331. next_long_name_blocks = size / BLOCKSIZE;
  332. }
  333. else
  334. {
  335. if (next_long_link)
  336. free (next_long_link);
  337. next_long_link = header_copy;
  338. next_long_link_blocks = size / BLOCKSIZE;
  339. }
  340. set_next_block_after (header);
  341. *header_copy = *header;
  342. bp = header_copy->buffer + BLOCKSIZE;
  343. for (size -= BLOCKSIZE; size > 0; size -= written)
  344. {
  345. data_block = find_next_block ();
  346. if (! data_block)
  347. {
  348. ERROR ((0, 0, _("Unexpected EOF in archive")));
  349. break;
  350. }
  351. written = available_space_after (data_block);
  352. if (written > size)
  353. written = size;
  354. memcpy (bp, data_block->buffer, written);
  355. bp += written;
  356. set_next_block_after ((union block *)
  357. (data_block->buffer + written - 1));
  358. }
  359. *bp = '\0';
  360. }
  361. else if (header->header.typeflag == XHDTYPE)
  362. xheader_read (header, OFF_FROM_HEADER (header->header.size));
  363. else if (header->header.typeflag == XGLTYPE)
  364. {
  365. xheader_read (header, OFF_FROM_HEADER (header->header.size));
  366. xheader_decode_global ();
  367. }
  368. /* Loop! */
  369. }
  370. else
  371. {
  372. char const *name;
  373. struct posix_header const *h = &current_header->header;
  374. char namebuf[sizeof h->prefix + 1 + NAME_FIELD_SIZE + 1];
  375. if (recent_long_name)
  376. free (recent_long_name);
  377. if (next_long_name)
  378. {
  379. name = next_long_name->buffer + BLOCKSIZE;
  380. recent_long_name = next_long_name;
  381. recent_long_name_blocks = next_long_name_blocks;
  382. }
  383. else
  384. {
  385. /* Accept file names as specified by POSIX.1-1996
  386. section 10.1.1. */
  387. char *np = namebuf;
  388. if (h->prefix[0] && strcmp (h->magic, TMAGIC) == 0)
  389. {
  390. memcpy (np, h->prefix, sizeof h->prefix);
  391. np[sizeof h->prefix] = '\0';
  392. np += strlen (np);
  393. *np++ = '/';
  394. }
  395. memcpy (np, h->name, sizeof h->name);
  396. np[sizeof h->name] = '\0';
  397. name = namebuf;
  398. recent_long_name = 0;
  399. recent_long_name_blocks = 0;
  400. }
  401. assign_string (&current_stat_info.orig_file_name, name);
  402. assign_string (&current_stat_info.file_name, name);
  403. current_stat_info.had_trailing_slash = strip_trailing_slashes (current_stat_info.file_name);
  404. if (recent_long_link)
  405. free (recent_long_link);
  406. if (next_long_link)
  407. {
  408. name = next_long_link->buffer + BLOCKSIZE;
  409. recent_long_link = next_long_link;
  410. recent_long_link_blocks = next_long_link_blocks;
  411. }
  412. else
  413. {
  414. memcpy (namebuf, h->linkname, sizeof h->linkname);
  415. namebuf[sizeof h->linkname] = '\0';
  416. name = namebuf;
  417. recent_long_link = 0;
  418. recent_long_link_blocks = 0;
  419. }
  420. assign_string (&current_stat_info.link_name, name);
  421. return HEADER_SUCCESS;
  422. }
  423. }
  424. }
  425. #define ISOCTAL(c) ((c)>='0'&&(c)<='7')
  426. /* Decode things from a file HEADER block into STAT_INFO, also setting
  427. *FORMAT_POINTER depending on the header block format. If
  428. DO_USER_GROUP, decode the user/group information (this is useful
  429. for extraction, but waste time when merely listing).
  430. read_header() has already decoded the checksum and length, so we don't.
  431. This routine should *not* be called twice for the same block, since
  432. the two calls might use different DO_USER_GROUP values and thus
  433. might end up with different uid/gid for the two calls. If anybody
  434. wants the uid/gid they should decode it first, and other callers
  435. should decode it without uid/gid before calling a routine,
  436. e.g. print_header, that assumes decoded data. */
  437. void
  438. decode_header (union block *header, struct tar_stat_info *stat_info,
  439. enum archive_format *format_pointer, int do_user_group)
  440. {
  441. enum archive_format format;
  442. if (strcmp (header->header.magic, TMAGIC) == 0)
  443. {
  444. if (header->star_header.prefix[130] == 0
  445. && ISOCTAL (header->star_header.atime[0])
  446. && header->star_header.atime[11] == ' '
  447. && ISOCTAL (header->star_header.ctime[0])
  448. && header->star_header.ctime[11] == ' ')
  449. format = STAR_FORMAT;
  450. else if (extended_header.size)
  451. format = POSIX_FORMAT;
  452. else
  453. format = USTAR_FORMAT;
  454. }
  455. else if (strcmp (header->header.magic, OLDGNU_MAGIC) == 0)
  456. format = OLDGNU_FORMAT;
  457. else
  458. format = V7_FORMAT;
  459. *format_pointer = format;
  460. stat_info->stat.st_mode = MODE_FROM_HEADER (header->header.mode);
  461. stat_info->stat.st_mtime = TIME_FROM_HEADER (header->header.mtime);
  462. assign_string (&stat_info->uname,
  463. header->header.uname[0] ? header->header.uname : NULL);
  464. assign_string (&stat_info->gname,
  465. header->header.gname[0] ? header->header.gname : NULL);
  466. stat_info->devmajor = MAJOR_FROM_HEADER (header->header.devmajor);
  467. stat_info->devminor = MINOR_FROM_HEADER (header->header.devminor);
  468. stat_info->stat.st_atime = start_time;
  469. stat_info->stat.st_ctime = start_time;
  470. if (format == OLDGNU_FORMAT && incremental_option)
  471. {
  472. stat_info->stat.st_atime = TIME_FROM_HEADER (header->oldgnu_header.atime);
  473. stat_info->stat.st_ctime = TIME_FROM_HEADER (header->oldgnu_header.ctime);
  474. }
  475. if (format == V7_FORMAT)
  476. {
  477. stat_info->stat.st_uid = UID_FROM_HEADER (header->header.uid);
  478. stat_info->stat.st_gid = GID_FROM_HEADER (header->header.gid);
  479. stat_info->stat.st_rdev = 0;
  480. }
  481. else
  482. {
  483. if (format == STAR_FORMAT)
  484. {
  485. stat_info->stat.st_atime = TIME_FROM_HEADER (header->star_header.atime);
  486. stat_info->stat.st_ctime = TIME_FROM_HEADER (header->star_header.ctime);
  487. }
  488. if (do_user_group)
  489. {
  490. /* FIXME: Decide if this should somewhat depend on -p. */
  491. if (numeric_owner_option
  492. || !*header->header.uname
  493. || !uname_to_uid (header->header.uname, &stat_info->stat.st_uid))
  494. stat_info->stat.st_uid = UID_FROM_HEADER (header->header.uid);
  495. if (numeric_owner_option
  496. || !*header->header.gname
  497. || !gname_to_gid (header->header.gname, &stat_info->stat.st_gid))
  498. stat_info->stat.st_gid = GID_FROM_HEADER (header->header.gid);
  499. }
  500. switch (header->header.typeflag)
  501. {
  502. case BLKTYPE:
  503. case CHRTYPE:
  504. stat_info->stat.st_rdev = makedev (stat_info->devmajor,
  505. stat_info->devminor);
  506. break;
  507. default:
  508. stat_info->stat.st_rdev = 0;
  509. }
  510. }
  511. stat_info->archive_file_size = stat_info->stat.st_size;
  512. xheader_decode (stat_info);
  513. if (sparse_member_p (stat_info))
  514. {
  515. sparse_fixup_header (stat_info);
  516. stat_info->is_sparse = true;
  517. }
  518. else
  519. stat_info->is_sparse = false;
  520. }
  521. /* Convert buffer at WHERE0 of size DIGS from external format to
  522. uintmax_t. DIGS must be positive. If TYPE is nonnull, the data
  523. are of type TYPE. The buffer must represent a value in the range
  524. -MINUS_MINVAL through MAXVAL. If OCTAL_ONLY, allow only octal
  525. numbers instead of the other GNU extensions. Return -1 on error,
  526. diagnosing the error if TYPE is nonnull and if !SILENT. */
  527. static uintmax_t
  528. from_header (char const *where0, size_t digs, char const *type,
  529. uintmax_t minus_minval, uintmax_t maxval,
  530. bool octal_only, bool silent)
  531. {
  532. uintmax_t value;
  533. char const *where = where0;
  534. char const *lim = where + digs;
  535. int negative = 0;
  536. /* Accommodate buggy tar of unknown vintage, which outputs leading
  537. NUL if the previous field overflows. */
  538. where += !*where;
  539. /* Accommodate older tars, which output leading spaces. */
  540. for (;;)
  541. {
  542. if (where == lim)
  543. {
  544. if (type && !silent)
  545. ERROR ((0, 0,
  546. /* TRANSLATORS: %s is type of the value (gid_t, uid_t, etc.) */
  547. _("Blanks in header where numeric %s value expected"),
  548. type));
  549. return -1;
  550. }
  551. if (!ISSPACE ((unsigned char) *where))
  552. break;
  553. where++;
  554. }
  555. value = 0;
  556. if (ISODIGIT (*where))
  557. {
  558. char const *where1 = where;
  559. uintmax_t overflow = 0;
  560. for (;;)
  561. {
  562. value += *where++ - '0';
  563. if (where == lim || ! ISODIGIT (*where))
  564. break;
  565. overflow |= value ^ (value << LG_8 >> LG_8);
  566. value <<= LG_8;
  567. }
  568. /* Parse the output of older, unportable tars, which generate
  569. negative values in two's complement octal. If the leading
  570. nonzero digit is 1, we can't recover the original value
  571. reliably; so do this only if the digit is 2 or more. This
  572. catches the common case of 32-bit negative time stamps. */
  573. if ((overflow || maxval < value) && '2' <= *where1 && type)
  574. {
  575. /* Compute the negative of the input value, assuming two's
  576. complement. */
  577. int digit = (*where1 - '0') | 4;
  578. overflow = 0;
  579. value = 0;
  580. where = where1;
  581. for (;;)
  582. {
  583. value += 7 - digit;
  584. where++;
  585. if (where == lim || ! ISODIGIT (*where))
  586. break;
  587. digit = *where - '0';
  588. overflow |= value ^ (value << LG_8 >> LG_8);
  589. value <<= LG_8;
  590. }
  591. value++;
  592. overflow |= !value;
  593. if (!overflow && value <= minus_minval)
  594. {
  595. if (!silent)
  596. WARN ((0, 0,
  597. /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
  598. _("Archive octal value %.*s is out of %s range; assuming two's complement"),
  599. (int) (where - where1), where1, type));
  600. negative = 1;
  601. }
  602. }
  603. if (overflow)
  604. {
  605. if (type && !silent)
  606. ERROR ((0, 0,
  607. /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
  608. _("Archive octal value %.*s is out of %s range"),
  609. (int) (where - where1), where1, type));
  610. return -1;
  611. }
  612. }
  613. else if (octal_only)
  614. {
  615. /* Suppress the following extensions. */
  616. }
  617. else if (*where == '-' || *where == '+')
  618. {
  619. /* Parse base-64 output produced only by tar test versions
  620. 1.13.6 (1999-08-11) through 1.13.11 (1999-08-23).
  621. Support for this will be withdrawn in future releases. */
  622. int dig;
  623. if (!silent)
  624. {
  625. static bool warned_once;
  626. if (! warned_once)
  627. {
  628. warned_once = true;
  629. WARN ((0, 0, _("Archive contains obsolescent base-64 headers")));
  630. }
  631. }
  632. negative = *where++ == '-';
  633. while (where != lim
  634. && (dig = base64_map[(unsigned char) *where]) < 64)
  635. {
  636. if (value << LG_64 >> LG_64 != value)
  637. {
  638. char *string = alloca (digs + 1);
  639. memcpy (string, where0, digs);
  640. string[digs] = '\0';
  641. if (type && !silent)
  642. ERROR ((0, 0,
  643. _("Archive signed base-64 string %s is out of %s range"),
  644. quote (string), type));
  645. return -1;
  646. }
  647. value = (value << LG_64) | dig;
  648. where++;
  649. }
  650. }
  651. else if (*where == '\200' /* positive base-256 */
  652. || *where == '\377' /* negative base-256 */)
  653. {
  654. /* Parse base-256 output. A nonnegative number N is
  655. represented as (256**DIGS)/2 + N; a negative number -N is
  656. represented as (256**DIGS) - N, i.e. as two's complement.
  657. The representation guarantees that the leading bit is
  658. always on, so that we don't confuse this format with the
  659. others (assuming ASCII bytes of 8 bits or more). */
  660. int signbit = *where & (1 << (LG_256 - 2));
  661. uintmax_t topbits = (((uintmax_t) - signbit)
  662. << (CHAR_BIT * sizeof (uintmax_t)
  663. - LG_256 - (LG_256 - 2)));
  664. value = (*where++ & ((1 << (LG_256 - 2)) - 1)) - signbit;
  665. for (;;)
  666. {
  667. value = (value << LG_256) + (unsigned char) *where++;
  668. if (where == lim)
  669. break;
  670. if (((value << LG_256 >> LG_256) | topbits) != value)
  671. {
  672. if (type && !silent)
  673. ERROR ((0, 0,
  674. _("Archive base-256 value is out of %s range"),
  675. type));
  676. return -1;
  677. }
  678. }
  679. negative = signbit;
  680. if (negative)
  681. value = -value;
  682. }
  683. if (where != lim && *where && !ISSPACE ((unsigned char) *where))
  684. {
  685. if (type)
  686. {
  687. char buf[1000]; /* Big enough to represent any header. */
  688. static struct quoting_options *o;
  689. if (!o)
  690. {
  691. o = clone_quoting_options (0);
  692. set_quoting_style (o, locale_quoting_style);
  693. }
  694. while (where0 != lim && ! lim[-1])
  695. lim--;
  696. quotearg_buffer (buf, sizeof buf, where0, lim - where, o);
  697. if (!silent)
  698. ERROR ((0, 0,
  699. /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */
  700. _("Archive contains %.*s where numeric %s value expected"),
  701. (int) sizeof buf, buf, type));
  702. }
  703. return -1;
  704. }
  705. if (value <= (negative ? minus_minval : maxval))
  706. return negative ? -value : value;
  707. if (type && !silent)
  708. {
  709. char minval_buf[UINTMAX_STRSIZE_BOUND + 1];
  710. char maxval_buf[UINTMAX_STRSIZE_BOUND];
  711. char value_buf[UINTMAX_STRSIZE_BOUND + 1];
  712. char *minval_string = STRINGIFY_BIGINT (minus_minval, minval_buf + 1);
  713. char *value_string = STRINGIFY_BIGINT (value, value_buf + 1);
  714. if (negative)
  715. *--value_string = '-';
  716. if (minus_minval)
  717. *--minval_string = '-';
  718. /* TRANSLATORS: Second %s is type name (gid_t,uid_t,etc.) */
  719. ERROR ((0, 0, _("Archive value %s is out of %s range %s..%s"),
  720. value_string, type,
  721. minval_string, STRINGIFY_BIGINT (maxval, maxval_buf)));
  722. }
  723. return -1;
  724. }
  725. gid_t
  726. gid_from_header (const char *p, size_t s)
  727. {
  728. return from_header (p, s, "gid_t",
  729. - (uintmax_t) TYPE_MINIMUM (gid_t),
  730. (uintmax_t) TYPE_MAXIMUM (gid_t),
  731. false, false);
  732. }
  733. major_t
  734. major_from_header (const char *p, size_t s)
  735. {
  736. return from_header (p, s, "major_t",
  737. - (uintmax_t) TYPE_MINIMUM (major_t),
  738. (uintmax_t) TYPE_MAXIMUM (major_t), false, false);
  739. }
  740. minor_t
  741. minor_from_header (const char *p, size_t s)
  742. {
  743. return from_header (p, s, "minor_t",
  744. - (uintmax_t) TYPE_MINIMUM (minor_t),
  745. (uintmax_t) TYPE_MAXIMUM (minor_t), false, false);
  746. }
  747. mode_t
  748. mode_from_header (const char *p, size_t s)
  749. {
  750. /* Do not complain about unrecognized mode bits. */
  751. unsigned u = from_header (p, s, "mode_t",
  752. - (uintmax_t) TYPE_MINIMUM (mode_t),
  753. TYPE_MAXIMUM (uintmax_t), false, false);
  754. return ((u & TSUID ? S_ISUID : 0)
  755. | (u & TSGID ? S_ISGID : 0)
  756. | (u & TSVTX ? S_ISVTX : 0)
  757. | (u & TUREAD ? S_IRUSR : 0)
  758. | (u & TUWRITE ? S_IWUSR : 0)
  759. | (u & TUEXEC ? S_IXUSR : 0)
  760. | (u & TGREAD ? S_IRGRP : 0)
  761. | (u & TGWRITE ? S_IWGRP : 0)
  762. | (u & TGEXEC ? S_IXGRP : 0)
  763. | (u & TOREAD ? S_IROTH : 0)
  764. | (u & TOWRITE ? S_IWOTH : 0)
  765. | (u & TOEXEC ? S_IXOTH : 0));
  766. }
  767. off_t
  768. off_from_header (const char *p, size_t s)
  769. {
  770. /* Negative offsets are not allowed in tar files, so invoke
  771. from_header with minimum value 0, not TYPE_MINIMUM (off_t). */
  772. return from_header (p, s, "off_t", (uintmax_t) 0,
  773. (uintmax_t) TYPE_MAXIMUM (off_t), false, false);
  774. }
  775. size_t
  776. size_from_header (const char *p, size_t s)
  777. {
  778. return from_header (p, s, "size_t", (uintmax_t) 0,
  779. (uintmax_t) TYPE_MAXIMUM (size_t), false, false);
  780. }
  781. time_t
  782. time_from_header (const char *p, size_t s)
  783. {
  784. return from_header (p, s, "time_t",
  785. - (uintmax_t) TYPE_MINIMUM (time_t),
  786. (uintmax_t) TYPE_MAXIMUM (time_t), false, false);
  787. }
  788. uid_t
  789. uid_from_header (const char *p, size_t s)
  790. {
  791. return from_header (p, s, "uid_t",
  792. - (uintmax_t) TYPE_MINIMUM (uid_t),
  793. (uintmax_t) TYPE_MAXIMUM (uid_t), false, false);
  794. }
  795. uintmax_t
  796. uintmax_from_header (const char *p, size_t s)
  797. {
  798. return from_header (p, s, "uintmax_t", (uintmax_t) 0,
  799. TYPE_MAXIMUM (uintmax_t), false, false);
  800. }
  801. /* Format O as a null-terminated decimal string into BUF _backwards_;
  802. return pointer to start of result. */
  803. char *
  804. stringify_uintmax_t_backwards (uintmax_t o, char *buf)
  805. {
  806. *--buf = '\0';
  807. do
  808. *--buf = '0' + (int) (o % 10);
  809. while ((o /= 10) != 0);
  810. return buf;
  811. }
  812. /* Return a printable representation of T. The result points to
  813. static storage that can be reused in the next call to this
  814. function, to ctime, or to asctime. */
  815. char const *
  816. tartime (time_t t)
  817. {
  818. static char buffer[max (UINTMAX_STRSIZE_BOUND + 1,
  819. INT_STRLEN_BOUND (int) + 16)];
  820. char *p;
  821. #if USE_OLD_CTIME
  822. p = ctime (&t);
  823. if (p)
  824. {
  825. char const *time_stamp = p + 4;
  826. for (p += 16; p[3] != '\n'; p++)
  827. p[0] = p[3];
  828. p[0] = '\0';
  829. return time_stamp;
  830. }
  831. #else
  832. /* Use ISO 8610 format. See:
  833. http://www.cl.cam.ac.uk/~mgk25/iso-time.html */
  834. struct tm *tm = utc_option ? gmtime (&t) : localtime (&t);
  835. if (tm)
  836. {
  837. sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
  838. tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
  839. tm->tm_hour, tm->tm_min, tm->tm_sec);
  840. return buffer;
  841. }
  842. #endif
  843. /* The time stamp cannot be broken down, most likely because it
  844. is out of range. Convert it as an integer,
  845. right-adjusted in a field with the same width as the usual
  846. 19-byte 4-year ISO time format. */
  847. p = stringify_uintmax_t_backwards (t < 0 ? - (uintmax_t) t : (uintmax_t) t,
  848. buffer + sizeof buffer);
  849. if (t < 0)
  850. *--p = '-';
  851. while (buffer + sizeof buffer - 19 - 1 < p)
  852. *--p = ' ';
  853. return p;
  854. }
  855. /* Actually print it.
  856. Plain and fancy file header block logging. Non-verbose just prints
  857. the name, e.g. for "tar t" or "tar x". This should just contain
  858. file names, so it can be fed back into tar with xargs or the "-T"
  859. option. The verbose option can give a bunch of info, one line per
  860. file. I doubt anybody tries to parse its format, or if they do,
  861. they shouldn't. Unix tar is pretty random here anyway. */
  862. /* FIXME: Note that print_header uses the globals HEAD, HSTAT, and
  863. HEAD_STANDARD, which must be set up in advance. Not very clean.. */
  864. /* UGSWIDTH starts with 18, so with user and group names <= 8 chars, the
  865. columns never shift during the listing. */
  866. #define UGSWIDTH 18
  867. static int ugswidth = UGSWIDTH; /* maximum width encountered so far */
  868. /* DATEWIDTH is the number of columns taken by the date and time fields. */
  869. #if USE_OLD_CDATE
  870. # define DATEWIDTH 19
  871. #else
  872. # define DATEWIDTH 18
  873. #endif
  874. void
  875. print_header (struct tar_stat_info *st, off_t block_ordinal)
  876. {
  877. char modes[11];
  878. char const *time_stamp;
  879. char *temp_name = st->orig_file_name ? st->orig_file_name : st->file_name;
  880. /* These hold formatted ints. */
  881. char uform[UINTMAX_STRSIZE_BOUND], gform[UINTMAX_STRSIZE_BOUND];
  882. char *user, *group;
  883. char size[2 * UINTMAX_STRSIZE_BOUND];
  884. /* holds formatted size or major,minor */
  885. char uintbuf[UINTMAX_STRSIZE_BOUND];
  886. int pad;
  887. if (block_number_option)
  888. {
  889. char buf[UINTMAX_STRSIZE_BOUND];
  890. if (block_ordinal < 0)
  891. block_ordinal = current_block_ordinal ();
  892. block_ordinal -= recent_long_name_blocks;
  893. block_ordinal -= recent_long_link_blocks;
  894. fprintf (stdlis, _("block %s: "),
  895. STRINGIFY_BIGINT (block_ordinal, buf));
  896. }
  897. if (verbose_option <= 1)
  898. {
  899. /* Just the fax, mam. */
  900. fprintf (stdlis, "%s\n", quotearg (temp_name));
  901. }
  902. else
  903. {
  904. /* File type and modes. */
  905. modes[0] = '?';
  906. switch (current_header->header.typeflag)
  907. {
  908. case GNUTYPE_VOLHDR:
  909. modes[0] = 'V';
  910. break;
  911. case GNUTYPE_MULTIVOL:
  912. modes[0] = 'M';
  913. break;
  914. case GNUTYPE_NAMES:
  915. modes[0] = 'N';
  916. break;
  917. case GNUTYPE_LONGNAME:
  918. case GNUTYPE_LONGLINK:
  919. modes[0] = 'L';
  920. ERROR ((0, 0, _("Unexpected long name header")));
  921. break;
  922. case GNUTYPE_SPARSE:
  923. case REGTYPE:
  924. case AREGTYPE:
  925. modes[0] = '-';
  926. if (temp_name[strlen (temp_name) - 1] == '/')
  927. modes[0] = 'd';
  928. break;
  929. case LNKTYPE:
  930. modes[0] = 'h';
  931. break;
  932. case GNUTYPE_DUMPDIR:
  933. modes[0] = 'd';
  934. break;
  935. case DIRTYPE:
  936. modes[0] = 'd';
  937. break;
  938. case SYMTYPE:
  939. modes[0] = 'l';
  940. break;
  941. case BLKTYPE:
  942. modes[0] = 'b';
  943. break;
  944. case CHRTYPE:
  945. modes[0] = 'c';
  946. break;
  947. case FIFOTYPE:
  948. modes[0] = 'p';
  949. break;
  950. case CONTTYPE:
  951. modes[0] = 'C';
  952. break;
  953. }
  954. decode_mode (st->stat.st_mode, modes + 1);
  955. /* Time stamp. */
  956. time_stamp = tartime (st->stat.st_mtime);
  957. /* User and group names. */
  958. if (st->uname
  959. && st->uname[0]
  960. && current_format != V7_FORMAT
  961. && !numeric_owner_option)
  962. user = st->uname;
  963. else
  964. {
  965. /* Try parsing it as an unsigned integer first, and as a
  966. uid_t if that fails. This method can list positive user
  967. ids that are too large to fit in a uid_t. */
  968. uintmax_t u = from_header (current_header->header.uid,
  969. sizeof current_header->header.uid, 0,
  970. (uintmax_t) 0,
  971. (uintmax_t) TYPE_MAXIMUM (uintmax_t),
  972. false, false);
  973. if (u != -1)
  974. user = STRINGIFY_BIGINT (u, uform);
  975. else
  976. {
  977. sprintf (uform, "%ld",
  978. (long) UID_FROM_HEADER (current_header->header.uid));
  979. user = uform;
  980. }
  981. }
  982. if (st->gname
  983. && st->gname[0]
  984. && current_format != V7_FORMAT
  985. && !numeric_owner_option)
  986. group = st->gname;
  987. else
  988. {
  989. /* Try parsing it as an unsigned integer first, and as a
  990. gid_t if that fails. This method can list positive group
  991. ids that are too large to fit in a gid_t. */
  992. uintmax_t g = from_header (current_header->header.gid,
  993. sizeof current_header->header.gid, 0,
  994. (uintmax_t) 0,
  995. (uintmax_t) TYPE_MAXIMUM (uintmax_t),
  996. false, false);
  997. if (g != -1)
  998. group = STRINGIFY_BIGINT (g, gform);
  999. else
  1000. {
  1001. sprintf (gform, "%ld",
  1002. (long) GID_FROM_HEADER (current_header->header.gid));
  1003. group = gform;
  1004. }
  1005. }
  1006. /* Format the file size or major/minor device numbers. */
  1007. switch (current_header->header.typeflag)
  1008. {
  1009. case CHRTYPE:
  1010. case BLKTYPE:
  1011. strcpy (size,
  1012. STRINGIFY_BIGINT (major (st->stat.st_rdev), uintbuf));
  1013. strcat (size, ",");
  1014. strcat (size,
  1015. STRINGIFY_BIGINT (minor (st->stat.st_rdev), uintbuf));
  1016. break;
  1017. default:
  1018. /* st->stat.st_size keeps stored file size */
  1019. strcpy (size, STRINGIFY_BIGINT (st->stat.st_size, uintbuf));
  1020. break;
  1021. }
  1022. /* Figure out padding and print the whole line. */
  1023. pad = strlen (user) + strlen (group) + strlen (size) + 1;
  1024. if (pad > ugswidth)
  1025. ugswidth = pad;
  1026. fprintf (stdlis, "%s %s/%s %*s%s %s",
  1027. modes, user, group, ugswidth - pad, "", size, time_stamp);
  1028. fprintf (stdlis, " %s", quotearg (temp_name));
  1029. switch (current_header->header.typeflag)
  1030. {
  1031. case SYMTYPE:
  1032. fprintf (stdlis, " -> %s\n", quotearg (st->link_name));
  1033. break;
  1034. case LNKTYPE:
  1035. fprintf (stdlis, _(" link to %s\n"), quotearg (st->link_name));
  1036. break;
  1037. default:
  1038. {
  1039. char type_string[2];
  1040. type_string[0] = current_header->header.typeflag;
  1041. type_string[1] = '\0';
  1042. fprintf (stdlis, _(" unknown file type %s\n"),
  1043. quote (type_string));
  1044. }
  1045. break;
  1046. case AREGTYPE:
  1047. case REGTYPE:
  1048. case GNUTYPE_SPARSE:
  1049. case CHRTYPE:
  1050. case BLKTYPE:
  1051. case DIRTYPE:
  1052. case FIFOTYPE:
  1053. case CONTTYPE:
  1054. case GNUTYPE_DUMPDIR:
  1055. putc ('\n', stdlis);
  1056. break;
  1057. case GNUTYPE_LONGLINK:
  1058. fprintf (stdlis, _("--Long Link--\n"));
  1059. break;
  1060. case GNUTYPE_LONGNAME:
  1061. fprintf (stdlis, _("--Long Name--\n"));
  1062. break;
  1063. case GNUTYPE_VOLHDR:
  1064. fprintf (stdlis, _("--Volume Header--\n"));
  1065. break;
  1066. case GNUTYPE_MULTIVOL:
  1067. strcpy (size,
  1068. STRINGIFY_BIGINT
  1069. (UINTMAX_FROM_HEADER (current_header->oldgnu_header.offset),
  1070. uintbuf));
  1071. fprintf (stdlis, _("--Continued at byte %s--\n"), size);
  1072. break;
  1073. case GNUTYPE_NAMES:
  1074. fprintf (stdlis, _("--Mangled file names--\n"));
  1075. break;
  1076. }
  1077. }
  1078. fflush (stdlis);
  1079. }
  1080. /* Print a similar line when we make a directory automatically. */
  1081. void
  1082. print_for_mkdir (char *dirname, int length, mode_t mode)
  1083. {
  1084. char modes[11];
  1085. if (verbose_option > 1)
  1086. {
  1087. /* File type and modes. */
  1088. modes[0] = 'd';
  1089. decode_mode (mode, modes + 1);
  1090. if (block_number_option)
  1091. {
  1092. char buf[UINTMAX_STRSIZE_BOUND];
  1093. fprintf (stdlis, _("block %s: "),
  1094. STRINGIFY_BIGINT (current_block_ordinal (), buf));
  1095. }
  1096. fprintf (stdlis, "%s %*s %.*s\n", modes, ugswidth + DATEWIDTH,
  1097. _("Creating directory:"), length, quotearg (dirname));
  1098. }
  1099. }
  1100. /* Skip over SIZE bytes of data in blocks in the archive. */
  1101. void
  1102. skip_file (off_t size)
  1103. {
  1104. union block *x;
  1105. if (multi_volume_option)
  1106. {
  1107. save_totsize = size;
  1108. save_sizeleft = size;
  1109. }
  1110. if (seekable_archive)
  1111. {
  1112. off_t nblk = seek_archive (size);
  1113. if (nblk >= 0)
  1114. {
  1115. size -= nblk * BLOCKSIZE;
  1116. if (multi_volume_option) /* Argh.. */
  1117. save_sizeleft -= nblk * BLOCKSIZE;
  1118. }
  1119. else
  1120. seekable_archive = false;
  1121. }
  1122. while (size > 0)
  1123. {
  1124. x = find_next_block ();
  1125. if (! x)
  1126. FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
  1127. set_next_block_after (x);
  1128. size -= BLOCKSIZE;
  1129. if (multi_volume_option)
  1130. save_sizeleft -= BLOCKSIZE;
  1131. }
  1132. }
  1133. /* Skip the current member in the archive.
  1134. NOTE: Current header must be decoded before calling this function. */
  1135. void
  1136. skip_member (void)
  1137. {
  1138. char save_typeflag = current_header->header.typeflag;
  1139. set_next_block_after (current_header);
  1140. assign_string (&save_name, current_stat_info.file_name);
  1141. if (current_stat_info.is_sparse)
  1142. sparse_skip_file (&current_stat_info);
  1143. else if (save_typeflag != DIRTYPE)
  1144. skip_file (current_stat_info.stat.st_size);
  1145. }