1 /* Functions for dealing with sparse files
3 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
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
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
24 struct tar_sparse_file
;
25 static bool sparse_select_optab (struct tar_sparse_file
*file
);
27 enum sparse_scan_state
34 struct tar_sparse_optab
36 bool (*init
) (struct tar_sparse_file
*);
37 bool (*done
) (struct tar_sparse_file
*);
38 bool (*sparse_member_p
) (struct tar_sparse_file
*);
39 bool (*dump_header
) (struct tar_sparse_file
*);
40 bool (*fixup_header
) (struct tar_sparse_file
*);
41 bool (*decode_header
) (struct tar_sparse_file
*);
42 bool (*scan_block
) (struct tar_sparse_file
*, enum sparse_scan_state
,
44 bool (*dump_region
) (struct tar_sparse_file
*, size_t);
45 bool (*extract_region
) (struct tar_sparse_file
*, size_t);
48 struct tar_sparse_file
50 int fd
; /* File descriptor */
51 bool seekable
; /* Is fd seekable? */
52 off_t offset
; /* Current offset in fd if seekable==false.
54 off_t dumped_size
; /* Number of bytes actually written
56 struct tar_stat_info
*stat_info
; /* Information about the file */
57 struct tar_sparse_optab
const *optab
; /* Operation table */
58 void *closure
; /* Any additional data optab calls might
62 /* Dump zeros to file->fd until offset is reached. It is used instead of
63 lseek if the output file is not seekable */
65 dump_zeros (struct tar_sparse_file
*file
, off_t offset
)
67 static char const zero_buf
[BLOCKSIZE
];
69 if (offset
< file
->offset
)
75 while (file
->offset
< offset
)
77 size_t size
= (BLOCKSIZE
< offset
- file
->offset
79 : offset
- file
->offset
);
82 wrbytes
= write (file
->fd
, zero_buf
, size
);
89 file
->offset
+= wrbytes
;
96 tar_sparse_member_p (struct tar_sparse_file
*file
)
98 if (file
->optab
->sparse_member_p
)
99 return file
->optab
->sparse_member_p (file
);
104 tar_sparse_init (struct tar_sparse_file
*file
)
106 memset (file
, 0, sizeof *file
);
108 if (!sparse_select_optab (file
))
111 if (file
->optab
->init
)
112 return file
->optab
->init (file
);
118 tar_sparse_done (struct tar_sparse_file
*file
)
120 if (file
->optab
->done
)
121 return file
->optab
->done (file
);
126 tar_sparse_scan (struct tar_sparse_file
*file
, enum sparse_scan_state state
,
129 if (file
->optab
->scan_block
)
130 return file
->optab
->scan_block (file
, state
, block
);
135 tar_sparse_dump_region (struct tar_sparse_file
*file
, size_t i
)
137 if (file
->optab
->dump_region
)
138 return file
->optab
->dump_region (file
, i
);
143 tar_sparse_extract_region (struct tar_sparse_file
*file
, size_t i
)
145 if (file
->optab
->extract_region
)
146 return file
->optab
->extract_region (file
, i
);
151 tar_sparse_dump_header (struct tar_sparse_file
*file
)
153 if (file
->optab
->dump_header
)
154 return file
->optab
->dump_header (file
);
159 tar_sparse_decode_header (struct tar_sparse_file
*file
)
161 if (file
->optab
->decode_header
)
162 return file
->optab
->decode_header (file
);
167 tar_sparse_fixup_header (struct tar_sparse_file
*file
)
169 if (file
->optab
->fixup_header
)
170 return file
->optab
->fixup_header (file
);
176 lseek_or_error (struct tar_sparse_file
*file
, off_t offset
)
179 ? lseek (file
->fd
, offset
, SEEK_SET
) < 0
180 : ! dump_zeros (file
, offset
))
182 seek_diag_details (file
->stat_info
->orig_file_name
, offset
);
188 /* Takes a blockful of data and basically cruises through it to see if
189 it's made *entirely* of zeros, returning a 0 the instant it finds
190 something that is a nonzero, i.e., useful data. */
192 zero_block_p (char const *buffer
, size_t size
)
201 sparse_add_map (struct tar_stat_info
*st
, struct sp_array
const *sp
)
203 struct sp_array
*sparse_map
= st
->sparse_map
;
204 size_t avail
= st
->sparse_map_avail
;
205 if (avail
== st
->sparse_map_size
)
206 st
->sparse_map
= sparse_map
=
207 x2nrealloc (sparse_map
, &st
->sparse_map_size
, sizeof *sparse_map
);
208 sparse_map
[avail
] = *sp
;
209 st
->sparse_map_avail
= avail
+ 1;
212 /* Scan the sparse file and create its map */
214 sparse_scan_file (struct tar_sparse_file
*file
)
216 struct tar_stat_info
*st
= file
->stat_info
;
218 char buffer
[BLOCKSIZE
];
221 struct sp_array sp
= {0, 0};
223 if (!lseek_or_error (file
, 0))
226 st
->archive_file_size
= 0;
228 if (!tar_sparse_scan (file
, scan_begin
, NULL
))
231 while ((count
= safe_read (fd
, buffer
, sizeof buffer
)) != 0
232 && count
!= SAFE_READ_ERROR
)
234 /* Analyze the block. */
235 if (zero_block_p (buffer
, count
))
239 sparse_add_map (st
, &sp
);
241 if (!tar_sparse_scan (file
, scan_block
, NULL
))
247 if (sp
.numbytes
== 0)
249 sp
.numbytes
+= count
;
250 st
->archive_file_size
+= count
;
251 if (!tar_sparse_scan (file
, scan_block
, buffer
))
258 if (sp
.numbytes
== 0)
261 sparse_add_map (st
, &sp
);
262 st
->archive_file_size
+= count
;
263 return tar_sparse_scan (file
, scan_end
, NULL
);
266 static struct tar_sparse_optab
const oldgnu_optab
;
267 static struct tar_sparse_optab
const star_optab
;
268 static struct tar_sparse_optab
const pax_optab
;
271 sparse_select_optab (struct tar_sparse_file
*file
)
273 switch (current_format
== DEFAULT_FORMAT
? archive_format
: current_format
)
280 case GNU_FORMAT
: /*FIXME: This one should disappear? */
281 file
->optab
= &oldgnu_optab
;
285 file
->optab
= &pax_optab
;
289 file
->optab
= &star_optab
;
299 sparse_dump_region (struct tar_sparse_file
*file
, size_t i
)
302 off_t bytes_left
= file
->stat_info
->sparse_map
[i
].numbytes
;
304 if (!lseek_or_error (file
, file
->stat_info
->sparse_map
[i
].offset
))
307 while (bytes_left
> 0)
309 size_t bufsize
= (bytes_left
> BLOCKSIZE
) ? BLOCKSIZE
: bytes_left
;
312 blk
= find_next_block ();
313 bytes_read
= safe_read (file
->fd
, blk
->buffer
, bufsize
);
314 if (bytes_read
== SAFE_READ_ERROR
)
316 read_diag_details (file
->stat_info
->orig_file_name
,
317 (file
->stat_info
->sparse_map
[i
].offset
318 + file
->stat_info
->sparse_map
[i
].numbytes
324 memset (blk
->buffer
+ bytes_read
, 0, BLOCKSIZE
- bytes_read
);
325 bytes_left
-= bytes_read
;
326 file
->dumped_size
+= bytes_read
;
327 set_next_block_after (blk
);
334 sparse_extract_region (struct tar_sparse_file
*file
, size_t i
)
338 if (!lseek_or_error (file
, file
->stat_info
->sparse_map
[i
].offset
))
341 write_size
= file
->stat_info
->sparse_map
[i
].numbytes
;
345 /* Last block of the file is a hole */
346 if (file
->seekable
&& sys_truncate (file
->fd
))
347 truncate_warn (file
->stat_info
->orig_file_name
);
349 else while (write_size
> 0)
352 size_t wrbytes
= (write_size
> BLOCKSIZE
) ? BLOCKSIZE
: write_size
;
353 union block
*blk
= find_next_block ();
356 ERROR ((0, 0, _("Unexpected EOF in archive")));
359 set_next_block_after (blk
);
360 count
= full_write (file
->fd
, blk
->buffer
, wrbytes
);
362 file
->dumped_size
+= count
;
363 mv_size_left (file
->stat_info
->archive_file_size
- file
->dumped_size
);
364 file
->offset
+= count
;
365 if (count
!= wrbytes
)
367 write_error_details (file
->stat_info
->orig_file_name
,
377 /* Interface functions */
379 sparse_dump_file (int fd
, struct tar_stat_info
*st
)
382 struct tar_sparse_file file
;
384 if (!tar_sparse_init (&file
))
385 return dump_status_not_implemented
;
389 file
.seekable
= true; /* File *must* be seekable for dump to work */
391 rc
= sparse_scan_file (&file
);
392 if (rc
&& file
.optab
->dump_region
)
394 tar_sparse_dump_header (&file
);
400 for (i
= 0; rc
&& i
< file
.stat_info
->sparse_map_avail
; i
++)
401 rc
= tar_sparse_dump_region (&file
, i
);
405 pad_archive (file
.stat_info
->archive_file_size
- file
.dumped_size
);
406 return (tar_sparse_done (&file
) && rc
) ? dump_status_ok
: dump_status_short
;
409 /* Returns true if the file represented by stat is a sparse one */
411 sparse_file_p (struct tar_stat_info
*st
)
413 return (ST_NBLOCKS (st
->stat
)
414 < (st
->stat
.st_size
/ ST_NBLOCKSIZE
415 + (st
->stat
.st_size
% ST_NBLOCKSIZE
!= 0)));
419 sparse_member_p (struct tar_stat_info
*st
)
421 struct tar_sparse_file file
;
423 if (!tar_sparse_init (&file
))
426 return tar_sparse_member_p (&file
);
430 sparse_fixup_header (struct tar_stat_info
*st
)
432 struct tar_sparse_file file
;
434 if (!tar_sparse_init (&file
))
437 return tar_sparse_fixup_header (&file
);
441 sparse_extract_file (int fd
, struct tar_stat_info
*st
, off_t
*size
)
444 struct tar_sparse_file file
;
447 if (!tar_sparse_init (&file
))
448 return dump_status_not_implemented
;
452 file
.seekable
= lseek (fd
, 0, SEEK_SET
) == 0;
455 rc
= tar_sparse_decode_header (&file
);
456 for (i
= 0; rc
&& i
< file
.stat_info
->sparse_map_avail
; i
++)
457 rc
= tar_sparse_extract_region (&file
, i
);
458 *size
= file
.stat_info
->archive_file_size
- file
.dumped_size
;
459 return (tar_sparse_done (&file
) && rc
) ? dump_status_ok
: dump_status_short
;
463 sparse_skip_file (struct tar_stat_info
*st
)
466 struct tar_sparse_file file
;
468 if (!tar_sparse_init (&file
))
469 return dump_status_not_implemented
;
474 rc
= tar_sparse_decode_header (&file
);
475 skip_file (file
.stat_info
->archive_file_size
);
476 return (tar_sparse_done (&file
) && rc
) ? dump_status_ok
: dump_status_short
;
481 check_sparse_region (struct tar_sparse_file
*file
, off_t beg
, off_t end
)
483 if (!lseek_or_error (file
, beg
))
489 size_t rdsize
= BLOCKSIZE
< end
- beg
? BLOCKSIZE
: end
- beg
;
490 char diff_buffer
[BLOCKSIZE
];
492 bytes_read
= safe_read (file
->fd
, diff_buffer
, rdsize
);
493 if (bytes_read
== SAFE_READ_ERROR
)
495 read_diag_details (file
->stat_info
->orig_file_name
,
500 if (!zero_block_p (diff_buffer
, bytes_read
))
502 char begbuf
[INT_BUFSIZE_BOUND (off_t
)];
503 report_difference (file
->stat_info
,
504 _("File fragment at %s is not a hole"),
505 offtostr (beg
, begbuf
));
515 check_data_region (struct tar_sparse_file
*file
, size_t i
)
519 if (!lseek_or_error (file
, file
->stat_info
->sparse_map
[i
].offset
))
521 size_left
= file
->stat_info
->sparse_map
[i
].numbytes
;
522 mv_size_left (file
->stat_info
->archive_file_size
- file
->dumped_size
);
524 while (size_left
> 0)
527 size_t rdsize
= (size_left
> BLOCKSIZE
) ? BLOCKSIZE
: size_left
;
528 char diff_buffer
[BLOCKSIZE
];
530 union block
*blk
= find_next_block ();
533 ERROR ((0, 0, _("Unexpected EOF in archive")));
536 set_next_block_after (blk
);
537 bytes_read
= safe_read (file
->fd
, diff_buffer
, rdsize
);
538 if (bytes_read
== SAFE_READ_ERROR
)
540 read_diag_details (file
->stat_info
->orig_file_name
,
541 (file
->stat_info
->sparse_map
[i
].offset
542 + file
->stat_info
->sparse_map
[i
].numbytes
547 file
->dumped_size
+= bytes_read
;
548 size_left
-= bytes_read
;
549 mv_size_left (file
->stat_info
->archive_file_size
- file
->dumped_size
);
550 if (memcmp (blk
->buffer
, diff_buffer
, rdsize
))
552 report_difference (file
->stat_info
, _("Contents differ"));
560 sparse_diff_file (int fd
, struct tar_stat_info
*st
)
563 struct tar_sparse_file file
;
567 if (!tar_sparse_init (&file
))
568 return dump_status_not_implemented
;
572 file
.seekable
= true; /* File *must* be seekable for compare to work */
574 rc
= tar_sparse_decode_header (&file
);
576 for (i
= 0; rc
&& i
< file
.stat_info
->sparse_map_avail
; i
++)
578 rc
= check_sparse_region (&file
,
579 offset
, file
.stat_info
->sparse_map
[i
].offset
)
580 && check_data_region (&file
, i
);
581 offset
= file
.stat_info
->sparse_map
[i
].offset
582 + file
.stat_info
->sparse_map
[i
].numbytes
;
586 skip_file (file
.stat_info
->archive_file_size
- file
.dumped_size
);
589 tar_sparse_done (&file
);
594 /* Old GNU Format. The sparse file information is stored in the
595 oldgnu_header in the following manner:
597 The header is marked with type 'S'. Its `size' field contains
598 the cumulative size of all non-empty blocks of the file. The
599 actual file size is stored in `realsize' member of oldgnu_header.
601 The map of the file is stored in a list of `struct sparse'.
602 Each struct contains offset to the block of data and its
603 size (both as octal numbers). The first file header contains
604 at most 4 such structs (SPARSES_IN_OLDGNU_HEADER). If the map
605 contains more structs, then the field `isextended' of the main
606 header is set to 1 (binary) and the `struct sparse_header'
607 header follows, containing at most 21 following structs
608 (SPARSES_IN_SPARSE_HEADER). If more structs follow, `isextended'
609 field of the extended header is set and next next extension header
612 enum oldgnu_add_status
620 oldgnu_sparse_member_p (struct tar_sparse_file
*file
__attribute__ ((unused
)))
622 return current_header
->header
.typeflag
== GNUTYPE_SPARSE
;
625 /* Add a sparse item to the sparse file and its obstack */
626 static enum oldgnu_add_status
627 oldgnu_add_sparse (struct tar_sparse_file
*file
, struct sparse
*s
)
631 if (s
->numbytes
[0] == '\0')
633 sp
.offset
= OFF_FROM_HEADER (s
->offset
);
634 sp
.numbytes
= SIZE_FROM_HEADER (s
->numbytes
);
636 || file
->stat_info
->stat
.st_size
< sp
.offset
+ sp
.numbytes
637 || file
->stat_info
->archive_file_size
< 0)
640 sparse_add_map (file
->stat_info
, &sp
);
645 oldgnu_fixup_header (struct tar_sparse_file
*file
)
647 /* NOTE! st_size was initialized from the header
648 which actually contains archived size. The following fixes it */
649 file
->stat_info
->archive_file_size
= file
->stat_info
->stat
.st_size
;
650 file
->stat_info
->stat
.st_size
=
651 OFF_FROM_HEADER (current_header
->oldgnu_header
.realsize
);
655 /* Convert old GNU format sparse data to internal representation */
657 oldgnu_get_sparse_info (struct tar_sparse_file
*file
)
660 union block
*h
= current_header
;
662 enum oldgnu_add_status rc
;
664 file
->stat_info
->sparse_map_avail
= 0;
665 for (i
= 0; i
< SPARSES_IN_OLDGNU_HEADER
; i
++)
667 rc
= oldgnu_add_sparse (file
, &h
->oldgnu_header
.sp
[i
]);
672 for (ext_p
= h
->oldgnu_header
.isextended
;
673 rc
== add_ok
&& ext_p
; ext_p
= h
->sparse_header
.isextended
)
675 h
= find_next_block ();
678 ERROR ((0, 0, _("Unexpected EOF in archive")));
681 set_next_block_after (h
);
682 for (i
= 0; i
< SPARSES_IN_SPARSE_HEADER
&& rc
== add_ok
; i
++)
683 rc
= oldgnu_add_sparse (file
, &h
->sparse_header
.sp
[i
]);
688 ERROR ((0, 0, _("%s: invalid sparse archive member"),
689 file
->stat_info
->orig_file_name
));
696 oldgnu_store_sparse_info (struct tar_sparse_file
*file
, size_t *pindex
,
697 struct sparse
*sp
, size_t sparse_size
)
699 for (; *pindex
< file
->stat_info
->sparse_map_avail
700 && sparse_size
> 0; sparse_size
--, sp
++, ++*pindex
)
702 OFF_TO_CHARS (file
->stat_info
->sparse_map
[*pindex
].offset
,
704 SIZE_TO_CHARS (file
->stat_info
->sparse_map
[*pindex
].numbytes
,
710 oldgnu_dump_header (struct tar_sparse_file
*file
)
712 off_t block_ordinal
= current_block_ordinal ();
716 blk
= start_header (file
->stat_info
);
717 blk
->header
.typeflag
= GNUTYPE_SPARSE
;
718 if (file
->stat_info
->sparse_map_avail
> SPARSES_IN_OLDGNU_HEADER
)
719 blk
->oldgnu_header
.isextended
= 1;
721 /* Store the real file size */
722 OFF_TO_CHARS (file
->stat_info
->stat
.st_size
, blk
->oldgnu_header
.realsize
);
723 /* Store the effective (shrunken) file size */
724 OFF_TO_CHARS (file
->stat_info
->archive_file_size
, blk
->header
.size
);
727 oldgnu_store_sparse_info (file
, &i
,
728 blk
->oldgnu_header
.sp
,
729 SPARSES_IN_OLDGNU_HEADER
);
730 blk
->oldgnu_header
.isextended
= i
< file
->stat_info
->sparse_map_avail
;
731 finish_header (file
->stat_info
, blk
, block_ordinal
);
733 while (i
< file
->stat_info
->sparse_map_avail
)
735 blk
= find_next_block ();
736 memset (blk
->buffer
, 0, BLOCKSIZE
);
737 oldgnu_store_sparse_info (file
, &i
,
738 blk
->sparse_header
.sp
,
739 SPARSES_IN_SPARSE_HEADER
);
740 set_next_block_after (blk
);
741 if (i
< file
->stat_info
->sparse_map_avail
)
742 blk
->sparse_header
.isextended
= 1;
749 static struct tar_sparse_optab
const oldgnu_optab
= {
750 NULL
, /* No init function */
751 NULL
, /* No done function */
752 oldgnu_sparse_member_p
,
755 oldgnu_get_sparse_info
,
756 NULL
, /* No scan_block function */
758 sparse_extract_region
,
765 star_sparse_member_p (struct tar_sparse_file
*file
__attribute__ ((unused
)))
767 return current_header
->header
.typeflag
== GNUTYPE_SPARSE
;
771 star_fixup_header (struct tar_sparse_file
*file
)
773 /* NOTE! st_size was initialized from the header
774 which actually contains archived size. The following fixes it */
775 file
->stat_info
->archive_file_size
= file
->stat_info
->stat
.st_size
;
776 file
->stat_info
->stat
.st_size
=
777 OFF_FROM_HEADER (current_header
->star_in_header
.realsize
);
781 /* Convert STAR format sparse data to internal representation */
783 star_get_sparse_info (struct tar_sparse_file
*file
)
786 union block
*h
= current_header
;
788 enum oldgnu_add_status rc
= add_ok
;
790 file
->stat_info
->sparse_map_avail
= 0;
792 if (h
->star_in_header
.prefix
[0] == '\0'
793 && h
->star_in_header
.sp
[0].offset
[10] != '\0')
795 /* Old star format */
796 for (i
= 0; i
< SPARSES_IN_STAR_HEADER
; i
++)
798 rc
= oldgnu_add_sparse (file
, &h
->star_in_header
.sp
[i
]);
802 ext_p
= h
->star_in_header
.isextended
;
807 for (; rc
== add_ok
&& ext_p
; ext_p
= h
->star_ext_header
.isextended
)
809 h
= find_next_block ();
812 ERROR ((0, 0, _("Unexpected EOF in archive")));
815 set_next_block_after (h
);
816 for (i
= 0; i
< SPARSES_IN_STAR_EXT_HEADER
&& rc
== add_ok
; i
++)
817 rc
= oldgnu_add_sparse (file
, &h
->star_ext_header
.sp
[i
]);
822 ERROR ((0, 0, _("%s: invalid sparse archive member"),
823 file
->stat_info
->orig_file_name
));
830 static struct tar_sparse_optab
const star_optab
= {
831 NULL
, /* No init function */
832 NULL
, /* No done function */
833 star_sparse_member_p
,
836 star_get_sparse_info
,
837 NULL
, /* No scan_block function */
838 NULL
, /* No dump region function */
839 sparse_extract_region
,
843 /* GNU PAX sparse file format. The sparse file map is stored in
846 GNU.sparse.size Real size of the stored file
847 GNU.sparse.numblocks Number of blocks in the sparse map
848 GNU.sparse.map Map of non-null data chunks. A string consisting
849 of comma-separated values "offset,size[,offset,size]..."
851 Tar versions 1.14-1.15.1 instead of the latter used:
853 repeat numblocks time
854 GNU.sparse.offset Offset of the next data block
855 GNU.sparse.numbytes Size of the next data block
858 This has been reported as conflicting with the POSIX specs. The reason is
859 that offsets and sizes of non-zero data blocks were stored in multiple
860 instances of GNU.sparse.offset/GNU.sparse.numbytes variables. However,
861 POSIX requires the latest occurrence of the variable to override all
862 previous occurrences.
864 To avoid this incompatibility new keyword GNU.sparse.map was introduced
865 in tar 1.15.2. Some people might still need the 1.14 way of handling
866 sparse files for the compatibility reasons: it can be achieved by
867 specifying `--pax-option delete=GNU.sparse.map' in the command line.
869 See FIXME-1.14-1.15.1-1.20, below.
873 pax_sparse_member_p (struct tar_sparse_file
*file
)
875 return file
->stat_info
->sparse_map_avail
> 0;
879 pax_dump_header (struct tar_sparse_file
*file
)
881 off_t block_ordinal
= current_block_ordinal ();
884 char nbuf
[UINTMAX_STRSIZE_BOUND
];
885 struct sp_array
*map
= file
->stat_info
->sparse_map
;
887 /* Store the real file size */
888 xheader_store ("GNU.sparse.size", file
->stat_info
, NULL
);
889 xheader_store ("GNU.sparse.numblocks", file
->stat_info
, NULL
);
891 /* FIXME-1.14-1.15.1-1.20: See the comment above.
892 Starting with 1.17 this should display a warning about POSIX-incompatible
893 keywords being generated. In 1.20, the true branch of the if block below
894 will be removed and GNU.sparse.map will be marked in xhdr_tab as
897 if (xheader_keyword_deleted_p ("GNU.sparse.map"))
899 for (i
= 0; i
< file
->stat_info
->sparse_map_avail
; i
++)
901 xheader_store ("GNU.sparse.offset", file
->stat_info
, &i
);
902 xheader_store ("GNU.sparse.numbytes", file
->stat_info
, &i
);
907 xheader_string_begin ();
908 for (i
= 0; i
< file
->stat_info
->sparse_map_avail
; i
++)
911 xheader_string_add (",");
912 xheader_string_add (umaxtostr (map
[i
].offset
, nbuf
));
913 xheader_string_add (",");
914 xheader_string_add (umaxtostr (map
[i
].numbytes
, nbuf
));
916 xheader_string_end ("GNU.sparse.map");
918 blk
= start_header (file
->stat_info
);
919 /* Store the effective (shrunken) file size */
920 OFF_TO_CHARS (file
->stat_info
->archive_file_size
, blk
->header
.size
);
921 finish_header (file
->stat_info
, blk
, block_ordinal
);
925 static struct tar_sparse_optab
const pax_optab
= {
926 NULL
, /* No init function */
927 NULL
, /* No done function */
930 NULL
, /* No decode_header function */
931 NULL
, /* No fixup_header function */
932 NULL
, /* No scan_block function */
934 sparse_extract_region
,