tar.5.html 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  1. <!-- Creator : groff version 1.22.4 -->
  2. <!-- CreationDate: Tue Jul 18 07:11:07 2023 -->
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  4. "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta name="generator" content="groff -Thtml, see www.gnu.org">
  8. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  9. <meta name="Content-Style" content="text/css">
  10. <style type="text/css">
  11. p { margin-top: 0; margin-bottom: 0; vertical-align: top }
  12. pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
  13. table { margin-top: 0; margin-bottom: 0; vertical-align: top }
  14. h1 { text-align: center }
  15. </style>
  16. <title></title>
  17. </head>
  18. <body>
  19. <hr>
  20. <p>TAR(5) BSD File Formats Manual TAR(5)</p>
  21. <p style="margin-top: 1em"><b>NAME</b></p>
  22. <p style="margin-left:6%;"><b>tar</b> &mdash; format of
  23. tape archive files</p>
  24. <p style="margin-top: 1em"><b>DESCRIPTION</b></p>
  25. <p style="margin-left:6%;">The <b>tar</b> archive format
  26. collects any number of files, directories, and other file
  27. system objects (symbolic links, device nodes, etc.) into a
  28. single stream of bytes. The format was originally designed
  29. to be used with tape drives that operate with fixed-size
  30. blocks, but is widely used as a general packaging
  31. mechanism.</p>
  32. <p style="margin-left:6%; margin-top: 1em"><b>General
  33. Format</b> <br>
  34. A <b>tar</b> archive consists of a series of 512-byte
  35. records. Each file system object requires a header record
  36. which stores basic metadata (pathname, owner, permissions,
  37. etc.) and zero or more records containing any file data. The
  38. end of the archive is indicated by two records consisting
  39. entirely of zero bytes.</p>
  40. <p style="margin-left:6%; margin-top: 1em">For
  41. compatibility with tape drives that use fixed block sizes,
  42. programs that read or write tar files always read or write a
  43. fixed number of records with each I/O operation. These
  44. &ldquo;blocks&rdquo; are always a multiple of the record
  45. size. The maximum block size supported by early
  46. implementations was 10240 bytes or 20 records. This is still
  47. the default for most implementations although block sizes of
  48. 1MiB (2048 records) or larger are commonly used with modern
  49. high-speed tape drives. (Note: the terms &ldquo;block&rdquo;
  50. and &ldquo;record&rdquo; here are not entirely standard;
  51. this document follows the convention established by John
  52. Gilmore in documenting <b>pdtar</b>.)</p>
  53. <p style="margin-left:6%; margin-top: 1em"><b>Old-Style
  54. Archive Format</b> <br>
  55. The original tar archive format has been extended many times
  56. to include additional information that various implementors
  57. found necessary. This section describes the variant
  58. implemented by the tar command included in Version&nbsp;7
  59. AT&amp;T UNIX, which seems to be the earliest widely-used
  60. version of the tar program.</p>
  61. <p style="margin-left:6%; margin-top: 1em">The header
  62. record for an old-style <b>tar</b> archive consists of the
  63. following:</p>
  64. <p style="margin-left:14%; margin-top: 1em">struct
  65. header_old_tar {</p>
  66. <table width="100%" border="0" rules="none" frame="void"
  67. cellspacing="0" cellpadding="0">
  68. <tr valign="top" align="left">
  69. <td width="24%"></td>
  70. <td width="11%">
  71. <p>char name[100];</p></td>
  72. <td width="65%">
  73. </td></tr>
  74. <tr valign="top" align="left">
  75. <td width="24%"></td>
  76. <td width="11%">
  77. <p>char mode[8];</p></td>
  78. <td width="65%">
  79. </td></tr>
  80. <tr valign="top" align="left">
  81. <td width="24%"></td>
  82. <td width="11%">
  83. <p>char uid[8];</p></td>
  84. <td width="65%">
  85. </td></tr>
  86. <tr valign="top" align="left">
  87. <td width="24%"></td>
  88. <td width="11%">
  89. <p>char gid[8];</p></td>
  90. <td width="65%">
  91. </td></tr>
  92. <tr valign="top" align="left">
  93. <td width="24%"></td>
  94. <td width="11%">
  95. <p>char size[12];</p></td>
  96. <td width="65%">
  97. </td></tr>
  98. <tr valign="top" align="left">
  99. <td width="24%"></td>
  100. <td width="11%">
  101. <p>char mtime[12];</p></td>
  102. <td width="65%">
  103. </td></tr>
  104. <tr valign="top" align="left">
  105. <td width="24%"></td>
  106. <td width="11%">
  107. <p>char checksum[8];</p></td>
  108. <td width="65%">
  109. </td></tr>
  110. <tr valign="top" align="left">
  111. <td width="24%"></td>
  112. <td width="11%">
  113. <p>char linkflag[1];</p></td>
  114. <td width="65%">
  115. </td></tr>
  116. <tr valign="top" align="left">
  117. <td width="24%"></td>
  118. <td width="11%">
  119. <p>char linkname[100];</p></td>
  120. <td width="65%">
  121. </td></tr>
  122. <tr valign="top" align="left">
  123. <td width="24%"></td>
  124. <td width="11%">
  125. <p>char pad[255];</p></td>
  126. <td width="65%">
  127. </td></tr>
  128. </table>
  129. <p style="margin-left:14%;">};</p>
  130. <p style="margin-left:6%;">All unused bytes in the header
  131. record are filled with nulls.</p>
  132. <p style="margin-top: 1em"><i>name</i></p>
  133. <p style="margin-left:17%; margin-top: 1em">Pathname,
  134. stored as a null-terminated string. Early tar
  135. implementations only stored regular files (including
  136. hardlinks to those files). One common early convention used
  137. a trailing &quot;/&quot; character to indicate a directory
  138. name, allowing directory permissions and owner information
  139. to be archived and restored.</p>
  140. <p style="margin-top: 1em"><i>mode</i></p>
  141. <p style="margin-left:17%; margin-top: 1em">File mode,
  142. stored as an octal number in ASCII.</p>
  143. <p style="margin-top: 1em"><i>uid</i>, <i>gid</i></p>
  144. <p style="margin-left:17%;">User id and group id of owner,
  145. as octal numbers in ASCII.</p>
  146. <p style="margin-top: 1em"><i>size</i></p>
  147. <p style="margin-left:17%; margin-top: 1em">Size of file,
  148. as octal number in ASCII. For regular files only, this
  149. indicates the amount of data that follows the header. In
  150. particular, this field was ignored by early tar
  151. implementations when extracting hardlinks. Modern writers
  152. should always store a zero length for hardlink entries.</p>
  153. <p style="margin-top: 1em"><i>mtime</i></p>
  154. <p style="margin-left:17%; margin-top: 1em">Modification
  155. time of file, as an octal number in ASCII. This indicates
  156. the number of seconds since the start of the epoch, 00:00:00
  157. UTC January 1, 1970. Note that negative values should be
  158. avoided here, as they are handled inconsistently.</p>
  159. <p style="margin-top: 1em"><i>checksum</i></p>
  160. <p style="margin-left:17%;">Header checksum, stored as an
  161. octal number in ASCII. To compute the checksum, set the
  162. checksum field to all spaces, then sum all bytes in the
  163. header using unsigned arithmetic. This field should be
  164. stored as six octal digits followed by a null and a space
  165. character. Note that many early implementations of tar used
  166. signed arithmetic for the checksum field, which can cause
  167. interoperability problems when transferring archives between
  168. systems. Modern robust readers compute the checksum both
  169. ways and accept the header if either computation
  170. matches.</p>
  171. <p style="margin-top: 1em"><i>linkflag</i>,
  172. <i>linkname</i></p>
  173. <p style="margin-left:17%;">In order to preserve hardlinks
  174. and conserve tape, a file with multiple links is only
  175. written to the archive the first time it is encountered. The
  176. next time it is encountered, the <i>linkflag</i> is set to
  177. an ASCII &rsquo;1&rsquo; and the <i>linkname</i> field holds
  178. the first name under which this file appears. (Note that
  179. regular files have a null value in the <i>linkflag</i>
  180. field.)</p>
  181. <p style="margin-left:6%; margin-top: 1em">Early tar
  182. implementations varied in how they terminated these fields.
  183. The tar command in Version&nbsp;7 AT&amp;T UNIX used the
  184. following conventions (this is also documented in early BSD
  185. manpages): the pathname must be null-terminated; the mode,
  186. uid, and gid fields must end in a space and a null byte; the
  187. size and mtime fields must end in a space; the checksum is
  188. terminated by a null and a space. Early implementations
  189. filled the numeric fields with leading spaces. This seems to
  190. have been common practice until the IEEE Std 1003.1-1988
  191. (&ldquo;POSIX.1&rdquo;) standard was released. For best
  192. portability, modern implementations should fill the numeric
  193. fields with leading zeros.</p>
  194. <p style="margin-left:6%; margin-top: 1em"><b>Pre-POSIX
  195. Archives</b> <br>
  196. An early draft of IEEE Std 1003.1-1988
  197. (&ldquo;POSIX.1&rdquo;) served as the basis for John
  198. Gilmore&rsquo;s <b>pdtar</b> program and many system
  199. implementations from the late 1980s and early 1990s. These
  200. archives generally follow the POSIX ustar format described
  201. below with the following variations:</p>
  202. <p><b>&bull;</b></p>
  203. <p style="margin-left:17%;">The magic value consists of the
  204. five characters &ldquo;ustar&rdquo; followed by a space. The
  205. version field contains a space character followed by a
  206. null.</p>
  207. <p><b>&bull;</b></p>
  208. <p style="margin-left:17%;">The numeric fields are
  209. generally filled with leading spaces (not leading zeros as
  210. recommended in the final standard).</p>
  211. <p><b>&bull;</b></p>
  212. <p style="margin-left:17%;">The prefix field is often not
  213. used, limiting pathnames to the 100 characters of old-style
  214. archives.</p>
  215. <p style="margin-left:6%; margin-top: 1em"><b>POSIX ustar
  216. Archives</b> <br>
  217. IEEE Std 1003.1-1988 (&ldquo;POSIX.1&rdquo;) defined a
  218. standard tar file format to be read and written by compliant
  219. implementations of tar(1). This format is often called the
  220. &ldquo;ustar&rdquo; format, after the magic value used in
  221. the header. (The name is an acronym for &ldquo;Unix Standard
  222. TAR&rdquo;.) It extends the historic format with new
  223. fields:</p>
  224. <p style="margin-left:14%; margin-top: 1em">struct
  225. header_posix_ustar {</p>
  226. <table width="100%" border="0" rules="none" frame="void"
  227. cellspacing="0" cellpadding="0">
  228. <tr valign="top" align="left">
  229. <td width="24%"></td>
  230. <td width="11%">
  231. <p>char name[100];</p></td>
  232. <td width="65%">
  233. </td></tr>
  234. <tr valign="top" align="left">
  235. <td width="24%"></td>
  236. <td width="11%">
  237. <p>char mode[8];</p></td>
  238. <td width="65%">
  239. </td></tr>
  240. <tr valign="top" align="left">
  241. <td width="24%"></td>
  242. <td width="11%">
  243. <p>char uid[8];</p></td>
  244. <td width="65%">
  245. </td></tr>
  246. <tr valign="top" align="left">
  247. <td width="24%"></td>
  248. <td width="11%">
  249. <p>char gid[8];</p></td>
  250. <td width="65%">
  251. </td></tr>
  252. <tr valign="top" align="left">
  253. <td width="24%"></td>
  254. <td width="11%">
  255. <p>char size[12];</p></td>
  256. <td width="65%">
  257. </td></tr>
  258. <tr valign="top" align="left">
  259. <td width="24%"></td>
  260. <td width="11%">
  261. <p>char mtime[12];</p></td>
  262. <td width="65%">
  263. </td></tr>
  264. <tr valign="top" align="left">
  265. <td width="24%"></td>
  266. <td width="11%">
  267. <p>char checksum[8];</p></td>
  268. <td width="65%">
  269. </td></tr>
  270. <tr valign="top" align="left">
  271. <td width="24%"></td>
  272. <td width="11%">
  273. <p>char typeflag[1];</p></td>
  274. <td width="65%">
  275. </td></tr>
  276. <tr valign="top" align="left">
  277. <td width="24%"></td>
  278. <td width="11%">
  279. <p>char linkname[100];</p></td>
  280. <td width="65%">
  281. </td></tr>
  282. <tr valign="top" align="left">
  283. <td width="24%"></td>
  284. <td width="11%">
  285. <p>char magic[6];</p></td>
  286. <td width="65%">
  287. </td></tr>
  288. <tr valign="top" align="left">
  289. <td width="24%"></td>
  290. <td width="11%">
  291. <p>char version[2];</p></td>
  292. <td width="65%">
  293. </td></tr>
  294. <tr valign="top" align="left">
  295. <td width="24%"></td>
  296. <td width="11%">
  297. <p>char uname[32];</p></td>
  298. <td width="65%">
  299. </td></tr>
  300. <tr valign="top" align="left">
  301. <td width="24%"></td>
  302. <td width="11%">
  303. <p>char gname[32];</p></td>
  304. <td width="65%">
  305. </td></tr>
  306. <tr valign="top" align="left">
  307. <td width="24%"></td>
  308. <td width="11%">
  309. <p>char devmajor[8];</p></td>
  310. <td width="65%">
  311. </td></tr>
  312. <tr valign="top" align="left">
  313. <td width="24%"></td>
  314. <td width="11%">
  315. <p>char devminor[8];</p></td>
  316. <td width="65%">
  317. </td></tr>
  318. <tr valign="top" align="left">
  319. <td width="24%"></td>
  320. <td width="11%">
  321. <p>char prefix[155];</p></td>
  322. <td width="65%">
  323. </td></tr>
  324. <tr valign="top" align="left">
  325. <td width="24%"></td>
  326. <td width="11%">
  327. <p>char pad[12];</p></td>
  328. <td width="65%">
  329. </td></tr>
  330. </table>
  331. <p style="margin-left:14%;">};</p>
  332. <p style="margin-top: 1em"><i>typeflag</i></p>
  333. <p style="margin-left:17%;">Type of entry. POSIX extended
  334. the earlier <i>linkflag</i> field with several new type
  335. values:</p>
  336. <p>&ldquo;0&rdquo;</p>
  337. <p style="margin-left:27%; margin-top: 1em">Regular file.
  338. NUL should be treated as a synonym, for compatibility
  339. purposes.</p>
  340. <p>&ldquo;1&rdquo;</p>
  341. <p style="margin-left:27%; margin-top: 1em">Hard link.</p>
  342. <p>&ldquo;2&rdquo;</p>
  343. <p style="margin-left:27%; margin-top: 1em">Symbolic
  344. link.</p>
  345. <p>&ldquo;3&rdquo;</p>
  346. <p style="margin-left:27%; margin-top: 1em">Character
  347. device node.</p>
  348. <p>&ldquo;4&rdquo;</p>
  349. <p style="margin-left:27%; margin-top: 1em">Block device
  350. node.</p>
  351. <p>&ldquo;5&rdquo;</p>
  352. <p style="margin-left:27%; margin-top: 1em">Directory.</p>
  353. <p>&ldquo;6&rdquo;</p>
  354. <p style="margin-left:27%; margin-top: 1em">FIFO node.</p>
  355. <p>&ldquo;7&rdquo;</p>
  356. <p style="margin-left:27%; margin-top: 1em">Reserved.</p>
  357. <p>Other</p>
  358. <p style="margin-left:27%; margin-top: 1em">A
  359. POSIX-compliant implementation must treat any unrecognized
  360. typeflag value as a regular file. In particular, writers
  361. should ensure that all entries have a valid filename so that
  362. they can be restored by readers that do not support the
  363. corresponding extension. Uppercase letters &quot;A&quot;
  364. through &quot;Z&quot; are reserved for custom extensions.
  365. Note that sockets and whiteout entries are not
  366. archivable.</p>
  367. <p style="margin-left:17%;">It is worth noting that the
  368. <i>size</i> field, in particular, has different meanings
  369. depending on the type. For regular files, of course, it
  370. indicates the amount of data following the header. For
  371. directories, it may be used to indicate the total size of
  372. all files in the directory, for use by operating systems
  373. that pre-allocate directory space. For all other types, it
  374. should be set to zero by writers and ignored by readers.</p>
  375. <p style="margin-top: 1em"><i>magic</i></p>
  376. <p style="margin-left:17%; margin-top: 1em">Contains the
  377. magic value &ldquo;ustar&rdquo; followed by a NUL byte to
  378. indicate that this is a POSIX standard archive. Full
  379. compliance requires the uname and gname fields be properly
  380. set.</p>
  381. <p style="margin-top: 1em"><i>version</i></p>
  382. <p style="margin-left:17%;">Version. This should be
  383. &ldquo;00&rdquo; (two copies of the ASCII digit zero) for
  384. POSIX standard archives.</p>
  385. <p style="margin-top: 1em"><i>uname</i>, <i>gname</i></p>
  386. <p style="margin-left:17%;">User and group names, as
  387. null-terminated ASCII strings. These should be used in
  388. preference to the uid/gid values when they are set and the
  389. corresponding names exist on the system.</p>
  390. <p style="margin-top: 1em"><i>devmajor</i>,
  391. <i>devminor</i></p>
  392. <p style="margin-left:17%;">Major and minor numbers for
  393. character device or block device entry.</p>
  394. <p style="margin-top: 1em"><i>name</i>, <i>prefix</i></p>
  395. <p style="margin-left:17%;">If the pathname is too long to
  396. fit in the 100 bytes provided by the standard format, it can
  397. be split at any <i>/</i> character with the first portion
  398. going into the prefix field. If the prefix field is not
  399. empty, the reader will prepend the prefix value and a
  400. <i>/</i> character to the regular name field to obtain the
  401. full pathname. The standard does not require a trailing
  402. <i>/</i> character on directory names, though most
  403. implementations still include this for compatibility
  404. reasons.</p>
  405. <p style="margin-left:6%; margin-top: 1em">Note that all
  406. unused bytes must be set to NUL.</p>
  407. <p style="margin-left:6%; margin-top: 1em">Field
  408. termination is specified slightly differently by POSIX than
  409. by previous implementations. The <i>magic</i>, <i>uname</i>,
  410. and <i>gname</i> fields must have a trailing NUL. The
  411. <i>pathname</i>, <i>linkname</i>, and <i>prefix</i> fields
  412. must have a trailing NUL unless they fill the entire field.
  413. (In particular, it is possible to store a 256-character
  414. pathname if it happens to have a <i>/</i> as the 156th
  415. character.) POSIX requires numeric fields to be zero-padded
  416. in the front, and requires them to be terminated with either
  417. space or NUL characters.</p>
  418. <p style="margin-left:6%; margin-top: 1em">Currently, most
  419. tar implementations comply with the ustar format,
  420. occasionally extending it by adding new fields to the blank
  421. area at the end of the header record.</p>
  422. <p style="margin-left:6%; margin-top: 1em"><b>Numeric
  423. Extensions</b> <br>
  424. There have been several attempts to extend the range of
  425. sizes or times supported by modifying how numbers are stored
  426. in the header.</p>
  427. <p style="margin-left:6%; margin-top: 1em">One obvious
  428. extension to increase the size of files is to eliminate the
  429. terminating characters from the various numeric fields. For
  430. example, the standard only allows the size field to contain
  431. 11 octal digits, reserving the twelfth byte for a trailing
  432. NUL character. Allowing 12 octal digits allows file sizes up
  433. to 64 GB.</p>
  434. <p style="margin-left:6%; margin-top: 1em">Another
  435. extension, utilized by GNU tar, star, and other newer
  436. <b>tar</b> implementations, permits binary numbers in the
  437. standard numeric fields. This is flagged by setting the high
  438. bit of the first byte. The remainder of the field is treated
  439. as a signed twos-complement value. This permits 95-bit
  440. values for the length and time fields and 63-bit values for
  441. the uid, gid, and device numbers. In particular, this
  442. provides a consistent way to handle negative time values.
  443. GNU tar supports this extension for the length, mtime,
  444. ctime, and atime fields. Joerg Schilling&rsquo;s star
  445. program and the libarchive library support this extension
  446. for all numeric fields. Note that this extension is largely
  447. obsoleted by the extended attribute record provided by the
  448. pax interchange format.</p>
  449. <p style="margin-left:6%; margin-top: 1em">Another early
  450. GNU extension allowed base-64 values rather than octal. This
  451. extension was short-lived and is no longer supported by any
  452. implementation.</p>
  453. <p style="margin-left:6%; margin-top: 1em"><b>Pax
  454. Interchange Format</b> <br>
  455. There are many attributes that cannot be portably stored in
  456. a POSIX ustar archive. IEEE Std 1003.1-2001
  457. (&ldquo;POSIX.1&rdquo;) defined a &ldquo;pax interchange
  458. format&rdquo; that uses two new types of entries to hold
  459. text-formatted metadata that applies to following entries.
  460. Note that a pax interchange format archive is a ustar
  461. archive in every respect. The new data is stored in
  462. ustar-compatible archive entries that use the
  463. &ldquo;x&rdquo; or &ldquo;g&rdquo; typeflag. In particular,
  464. older implementations that do not fully support these
  465. extensions will extract the metadata into regular files,
  466. where the metadata can be examined as necessary.</p>
  467. <p style="margin-left:6%; margin-top: 1em">An entry in a
  468. pax interchange format archive consists of one or two
  469. standard ustar entries, each with its own header and data.
  470. The first optional entry stores the extended attributes for
  471. the following entry. This optional first entry has an
  472. &quot;x&quot; typeflag and a size field that indicates the
  473. total size of the extended attributes. The extended
  474. attributes themselves are stored as a series of text-format
  475. lines encoded in the portable UTF-8 encoding. Each line
  476. consists of a decimal number, a space, a key string, an
  477. equals sign, a value string, and a new line. The decimal
  478. number indicates the length of the entire line, including
  479. the initial length field and the trailing newline. An
  480. example of such a field is:</p>
  481. <p style="margin-left:14%;">25 ctime=1084839148.1212\n</p>
  482. <p style="margin-left:6%;">Keys in all lowercase are
  483. standard keys. Vendors can add their own keys by prefixing
  484. them with an all uppercase vendor name and a period. Note
  485. that, unlike the historic header, numeric values are stored
  486. using decimal, not octal. A description of some common keys
  487. follows:</p>
  488. <p style="margin-top: 1em"><b>atime</b>, <b>ctime</b>,
  489. <b>mtime</b></p>
  490. <p style="margin-left:17%;">File access, inode change, and
  491. modification times. These fields can be negative or include
  492. a decimal point and a fractional value.</p>
  493. <p style="margin-top: 1em"><b>hdrcharset</b></p>
  494. <p style="margin-left:17%;">The character set used by the
  495. pax extension values. By default, all textual values in the
  496. pax extended attributes are assumed to be in UTF-8,
  497. including pathnames, user names, and group names. In some
  498. cases, it is not possible to translate local conventions
  499. into UTF-8. If this key is present and the value is the
  500. six-character ASCII string &ldquo;BINARY&rdquo;, then all
  501. textual values are assumed to be in a platform-dependent
  502. multi-byte encoding. Note that there are only two valid
  503. values for this key: &ldquo;BINARY&rdquo; or
  504. &ldquo;ISO-IR&nbsp;10646&nbsp;2000&nbsp;UTF-8&rdquo;. No
  505. other values are permitted by the standard, and the latter
  506. value should generally not be used as it is the default when
  507. this key is not specified. In particular, this flag should
  508. not be used as a general mechanism to allow filenames to be
  509. stored in arbitrary encodings.</p>
  510. <p style="margin-top: 1em"><b>uname</b>, <b>uid</b>,
  511. <b>gname</b>, <b>gid</b></p>
  512. <p style="margin-left:17%;">User name, group name, and
  513. numeric UID and GID values. The user name and group name
  514. stored here are encoded in UTF8 and can thus include
  515. non-ASCII characters. The UID and GID fields can be of
  516. arbitrary length.</p>
  517. <p style="margin-top: 1em"><b>linkpath</b></p>
  518. <p style="margin-left:17%;">The full path of the linked-to
  519. file. Note that this is encoded in UTF8 and can thus include
  520. non-ASCII characters.</p>
  521. <p style="margin-top: 1em"><b>path</b></p>
  522. <p style="margin-left:17%; margin-top: 1em">The full
  523. pathname of the entry. Note that this is encoded in UTF8 and
  524. can thus include non-ASCII characters.</p>
  525. <p style="margin-top: 1em"><b>realtime.*</b>,
  526. <b>security.*</b></p>
  527. <p style="margin-left:17%;">These keys are reserved and may
  528. be used for future standardization.</p>
  529. <p style="margin-top: 1em"><b>size</b></p>
  530. <p style="margin-left:17%; margin-top: 1em">The size of the
  531. file. Note that there is no length limit on this field,
  532. allowing conforming archives to store files much larger than
  533. the historic 8GB limit.</p>
  534. <p style="margin-top: 1em"><b>SCHILY.*</b></p>
  535. <p style="margin-left:17%;">Vendor-specific attributes used
  536. by Joerg Schilling&rsquo;s <b>star</b> implementation.</p>
  537. <p style="margin-top: 1em"><b>SCHILY.acl.access</b>,
  538. <b>SCHILY.acl.default</b>, <b>SCHILY.acl.ace</b></p>
  539. <p style="margin-left:17%;">Stores the access, default and
  540. NFSv4 ACLs as textual strings in a format that is an
  541. extension of the format specified by POSIX.1e draft 17. In
  542. particular, each user or group access specification can
  543. include an additional colon-separated field with the numeric
  544. UID or GID. This allows ACLs to be restored on systems that
  545. may not have complete user or group information available
  546. (such as when NIS/YP or LDAP services are temporarily
  547. unavailable).</p>
  548. <p style="margin-top: 1em"><b>SCHILY.devminor</b>,
  549. <b>SCHILY.devmajor</b></p>
  550. <p style="margin-left:17%;">The full minor and major
  551. numbers for device nodes.</p>
  552. <p style="margin-top: 1em"><b>SCHILY.fflags</b></p>
  553. <p style="margin-left:17%;">The file flags.</p>
  554. <p style="margin-top: 1em"><b>SCHILY.realsize</b></p>
  555. <p style="margin-left:17%;">The full size of the file on
  556. disk. XXX explain? XXX</p>
  557. <p style="margin-top: 1em"><b>SCHILY.dev</b>,
  558. <b>SCHILY.ino</b>, <b>SCHILY.nlinks</b></p>
  559. <p style="margin-left:17%;">The device number, inode
  560. number, and link count for the entry. In particular, note
  561. that a pax interchange format archive using Joerg
  562. Schilling&rsquo;s <b>SCHILY.*</b> extensions can store all
  563. of the data from <i>struct stat</i>.</p>
  564. <p style="margin-top: 1em"><b>LIBARCHIVE.*</b></p>
  565. <p style="margin-left:17%;">Vendor-specific attributes used
  566. by the <b>libarchive</b> library and programs that use
  567. it.</p>
  568. <p style="margin-top: 1em"><b>LIBARCHIVE.creationtime</b></p>
  569. <p style="margin-left:17%;">The time when the file was
  570. created. (This should not be confused with the POSIX
  571. &ldquo;ctime&rdquo; attribute, which refers to the time when
  572. the file metadata was last changed.)</p>
  573. <p style="margin-top: 1em"><b>LIBARCHIVE.xattr</b>.<i>namespace</i>.<i>key</i></p>
  574. <p style="margin-left:17%;">Libarchive stores
  575. POSIX.1e-style extended attributes using keys of this form.
  576. The <i>key</i> value is URL-encoded: All non-ASCII
  577. characters and the two special characters &ldquo;=&rdquo;
  578. and &ldquo;%&rdquo; are encoded as &ldquo;%&rdquo; followed
  579. by two uppercase hexadecimal digits. The value of this key
  580. is the extended attribute value encoded in base 64. XXX
  581. Detail the base-64 format here XXX</p>
  582. <p style="margin-top: 1em"><b>VENDOR.*</b></p>
  583. <p style="margin-left:17%;">XXX document other
  584. vendor-specific extensions XXX</p>
  585. <p style="margin-left:6%; margin-top: 1em">Any values
  586. stored in an extended attribute override the corresponding
  587. values in the regular tar header. Note that compliant
  588. readers should ignore the regular fields when they are
  589. overridden. This is important, as existing archivers are
  590. known to store non-compliant values in the standard header
  591. fields in this situation. There are no limits on length for
  592. any of these fields. In particular, numeric fields can be
  593. arbitrarily large. All text fields are encoded in UTF8.
  594. Compliant writers should store only portable 7-bit ASCII
  595. characters in the standard ustar header and use extended
  596. attributes whenever a text value contains non-ASCII
  597. characters.</p>
  598. <p style="margin-left:6%; margin-top: 1em">In addition to
  599. the <b>x</b> entry described above, the pax interchange
  600. format also supports a <b>g</b> entry. The <b>g</b> entry is
  601. identical in format, but specifies attributes that serve as
  602. defaults for all subsequent archive entries. The <b>g</b>
  603. entry is not widely used.</p>
  604. <p style="margin-left:6%; margin-top: 1em">Besides the new
  605. <b>x</b> and <b>g</b> entries, the pax interchange format
  606. has a few other minor variations from the earlier ustar
  607. format. The most troubling one is that hardlinks are
  608. permitted to have data following them. This allows readers
  609. to restore any hardlink to a file without having to rewind
  610. the archive to find an earlier entry. However, it creates
  611. complications for robust readers, as it is no longer clear
  612. whether or not they should ignore the size field for
  613. hardlink entries.</p>
  614. <p style="margin-left:6%; margin-top: 1em"><b>GNU Tar
  615. Archives</b> <br>
  616. The GNU tar program started with a pre-POSIX format similar
  617. to that described earlier and has extended it using several
  618. different mechanisms: It added new fields to the empty space
  619. in the header (some of which was later used by POSIX for
  620. conflicting purposes); it allowed the header to be continued
  621. over multiple records; and it defined new entries that
  622. modify following entries (similar in principle to the
  623. <b>x</b> entry described above, but each GNU special entry
  624. is single-purpose, unlike the general-purpose <b>x</b>
  625. entry). As a result, GNU tar archives are not POSIX
  626. compatible, although more lenient POSIX-compliant readers
  627. can successfully extract most GNU tar archives.</p>
  628. <p style="margin-left:14%; margin-top: 1em">struct
  629. header_gnu_tar {</p>
  630. <table width="100%" border="0" rules="none" frame="void"
  631. cellspacing="0" cellpadding="0">
  632. <tr valign="top" align="left">
  633. <td width="24%"></td>
  634. <td width="11%">
  635. <p>char name[100];</p></td>
  636. <td width="10%"></td>
  637. <td width="55%">
  638. </td></tr>
  639. <tr valign="top" align="left">
  640. <td width="24%"></td>
  641. <td width="11%">
  642. <p>char mode[8];</p></td>
  643. <td width="10%"></td>
  644. <td width="55%">
  645. </td></tr>
  646. <tr valign="top" align="left">
  647. <td width="24%"></td>
  648. <td width="11%">
  649. <p>char uid[8];</p></td>
  650. <td width="10%"></td>
  651. <td width="55%">
  652. </td></tr>
  653. <tr valign="top" align="left">
  654. <td width="24%"></td>
  655. <td width="11%">
  656. <p>char gid[8];</p></td>
  657. <td width="10%"></td>
  658. <td width="55%">
  659. </td></tr>
  660. <tr valign="top" align="left">
  661. <td width="24%"></td>
  662. <td width="11%">
  663. <p>char size[12];</p></td>
  664. <td width="10%"></td>
  665. <td width="55%">
  666. </td></tr>
  667. <tr valign="top" align="left">
  668. <td width="24%"></td>
  669. <td width="11%">
  670. <p>char mtime[12];</p></td>
  671. <td width="10%"></td>
  672. <td width="55%">
  673. </td></tr>
  674. <tr valign="top" align="left">
  675. <td width="24%"></td>
  676. <td width="11%">
  677. <p>char checksum[8];</p></td>
  678. <td width="10%"></td>
  679. <td width="55%">
  680. </td></tr>
  681. <tr valign="top" align="left">
  682. <td width="24%"></td>
  683. <td width="11%">
  684. <p>char typeflag[1];</p></td>
  685. <td width="10%"></td>
  686. <td width="55%">
  687. </td></tr>
  688. <tr valign="top" align="left">
  689. <td width="24%"></td>
  690. <td width="11%">
  691. <p>char linkname[100];</p></td>
  692. <td width="10%"></td>
  693. <td width="55%">
  694. </td></tr>
  695. <tr valign="top" align="left">
  696. <td width="24%"></td>
  697. <td width="11%">
  698. <p>char magic[6];</p></td>
  699. <td width="10%"></td>
  700. <td width="55%">
  701. </td></tr>
  702. <tr valign="top" align="left">
  703. <td width="24%"></td>
  704. <td width="11%">
  705. <p>char version[2];</p></td>
  706. <td width="10%"></td>
  707. <td width="55%">
  708. </td></tr>
  709. <tr valign="top" align="left">
  710. <td width="24%"></td>
  711. <td width="11%">
  712. <p>char uname[32];</p></td>
  713. <td width="10%"></td>
  714. <td width="55%">
  715. </td></tr>
  716. <tr valign="top" align="left">
  717. <td width="24%"></td>
  718. <td width="11%">
  719. <p>char gname[32];</p></td>
  720. <td width="10%"></td>
  721. <td width="55%">
  722. </td></tr>
  723. <tr valign="top" align="left">
  724. <td width="24%"></td>
  725. <td width="11%">
  726. <p>char devmajor[8];</p></td>
  727. <td width="10%"></td>
  728. <td width="55%">
  729. </td></tr>
  730. <tr valign="top" align="left">
  731. <td width="24%"></td>
  732. <td width="11%">
  733. <p>char devminor[8];</p></td>
  734. <td width="10%"></td>
  735. <td width="55%">
  736. </td></tr>
  737. <tr valign="top" align="left">
  738. <td width="24%"></td>
  739. <td width="11%">
  740. <p>char atime[12];</p></td>
  741. <td width="10%"></td>
  742. <td width="55%">
  743. </td></tr>
  744. <tr valign="top" align="left">
  745. <td width="24%"></td>
  746. <td width="11%">
  747. <p>char ctime[12];</p></td>
  748. <td width="10%"></td>
  749. <td width="55%">
  750. </td></tr>
  751. <tr valign="top" align="left">
  752. <td width="24%"></td>
  753. <td width="11%">
  754. <p>char offset[12];</p></td>
  755. <td width="10%"></td>
  756. <td width="55%">
  757. </td></tr>
  758. <tr valign="top" align="left">
  759. <td width="24%"></td>
  760. <td width="11%">
  761. <p>char longnames[4];</p></td>
  762. <td width="10%"></td>
  763. <td width="55%">
  764. </td></tr>
  765. <tr valign="top" align="left">
  766. <td width="24%"></td>
  767. <td width="11%">
  768. <p>char unused[1];</p></td>
  769. <td width="10%"></td>
  770. <td width="55%">
  771. </td></tr>
  772. <tr valign="top" align="left">
  773. <td width="24%"></td>
  774. <td width="11%">
  775. <p>struct {</p></td>
  776. <td width="10%"></td>
  777. <td width="55%">
  778. </td></tr>
  779. <tr valign="top" align="left">
  780. <td width="24%"></td>
  781. <td width="11%">
  782. </td>
  783. <td width="10%">
  784. <p>char offset[12];</p></td>
  785. <td width="55%">
  786. </td></tr>
  787. <tr valign="top" align="left">
  788. <td width="24%"></td>
  789. <td width="11%">
  790. </td>
  791. <td width="10%">
  792. <p>char numbytes[12];</p></td>
  793. <td width="55%">
  794. </td></tr>
  795. <tr valign="top" align="left">
  796. <td width="24%"></td>
  797. <td width="11%">
  798. <p>} sparse[4];</p></td>
  799. <td width="10%"></td>
  800. <td width="55%">
  801. </td></tr>
  802. <tr valign="top" align="left">
  803. <td width="24%"></td>
  804. <td width="11%">
  805. <p>char isextended[1];</p></td>
  806. <td width="10%"></td>
  807. <td width="55%">
  808. </td></tr>
  809. <tr valign="top" align="left">
  810. <td width="24%"></td>
  811. <td width="11%">
  812. <p>char realsize[12];</p></td>
  813. <td width="10%"></td>
  814. <td width="55%">
  815. </td></tr>
  816. <tr valign="top" align="left">
  817. <td width="24%"></td>
  818. <td width="11%">
  819. <p>char pad[17];</p></td>
  820. <td width="10%"></td>
  821. <td width="55%">
  822. </td></tr>
  823. </table>
  824. <p style="margin-left:14%;">};</p>
  825. <p style="margin-top: 1em"><i>typeflag</i></p>
  826. <p style="margin-left:17%;">GNU tar uses the following
  827. special entry types, in addition to those defined by
  828. POSIX:</p>
  829. <p style="margin-top: 1em">7</p>
  830. <p style="margin-left:27%; margin-top: 1em">GNU tar treats
  831. type &quot;7&quot; records identically to type &quot;0&quot;
  832. records, except on one obscure RTOS where they are used to
  833. indicate the pre-allocation of a contiguous file on
  834. disk.</p>
  835. <p style="margin-top: 1em">D</p>
  836. <p style="margin-left:27%; margin-top: 1em">This indicates
  837. a directory entry. Unlike the POSIX-standard &quot;5&quot;
  838. typeflag, the header is followed by data records listing the
  839. names of files in this directory. Each name is preceded by
  840. an ASCII &quot;Y&quot; if the file is stored in this archive
  841. or &quot;N&quot; if the file is not stored in this archive.
  842. Each name is terminated with a null, and an extra null marks
  843. the end of the name list. The purpose of this entry is to
  844. support incremental backups; a program restoring from such
  845. an archive may wish to delete files on disk that did not
  846. exist in the directory when the archive was made.</p>
  847. <p style="margin-left:27%; margin-top: 1em">Note that the
  848. &quot;D&quot; typeflag specifically violates POSIX, which
  849. requires that unrecognized typeflags be restored as normal
  850. files. In this case, restoring the &quot;D&quot; entry as a
  851. file could interfere with subsequent creation of the
  852. like-named directory.</p>
  853. <p style="margin-top: 1em">K</p>
  854. <p style="margin-left:27%; margin-top: 1em">The data for
  855. this entry is a long linkname for the following regular
  856. entry.</p>
  857. <p style="margin-top: 1em">L</p>
  858. <p style="margin-left:27%; margin-top: 1em">The data for
  859. this entry is a long pathname for the following regular
  860. entry.</p>
  861. <p style="margin-top: 1em">M</p>
  862. <p style="margin-left:27%; margin-top: 1em">This is a
  863. continuation of the last file on the previous volume. GNU
  864. multi-volume archives guarantee that each volume begins with
  865. a valid entry header. To ensure this, a file may be split,
  866. with part stored at the end of one volume, and part stored
  867. at the beginning of the next volume. The &quot;M&quot;
  868. typeflag indicates that this entry continues an existing
  869. file. Such entries can only occur as the first or second
  870. entry in an archive (the latter only if the first entry is a
  871. volume label). The <i>size</i> field specifies the size of
  872. this entry. The <i>offset</i> field at bytes 369-380
  873. specifies the offset where this file fragment begins. The
  874. <i>realsize</i> field specifies the total size of the file
  875. (which must equal <i>size</i> plus <i>offset</i>). When
  876. extracting, GNU tar checks that the header file name is the
  877. one it is expecting, that the header offset is in the
  878. correct sequence, and that the sum of offset and size is
  879. equal to realsize.</p>
  880. <p style="margin-top: 1em">N</p>
  881. <p style="margin-left:27%; margin-top: 1em">Type
  882. &quot;N&quot; records are no longer generated by GNU tar.
  883. They contained a list of files to be renamed or symlinked
  884. after extraction; this was originally used to support long
  885. names. The contents of this record are a text description of
  886. the operations to be done, in the form &ldquo;Rename %s to
  887. %s\n&rdquo; or &ldquo;Symlink %s to %s\n&rdquo;; in either
  888. case, both filenames are escaped using K&amp;R C syntax. Due
  889. to security concerns, &quot;N&quot; records are now
  890. generally ignored when reading archives.</p>
  891. <p style="margin-top: 1em">S</p>
  892. <p style="margin-left:27%; margin-top: 1em">This is a
  893. &ldquo;sparse&rdquo; regular file. Sparse files are stored
  894. as a series of fragments. The header contains a list of
  895. fragment offset/length pairs. If more than four such entries
  896. are required, the header is extended as necessary with
  897. &ldquo;extra&rdquo; header extensions (an older format that
  898. is no longer used), or &ldquo;sparse&rdquo; extensions.</p>
  899. <p style="margin-top: 1em">V</p>
  900. <p style="margin-left:27%; margin-top: 1em">The <i>name</i>
  901. field should be interpreted as a tape/volume header name.
  902. This entry should generally be ignored on extraction.</p>
  903. <p style="margin-top: 1em"><i>magic</i></p>
  904. <p style="margin-left:17%; margin-top: 1em">The magic field
  905. holds the five characters &ldquo;ustar&rdquo; followed by a
  906. space. Note that POSIX ustar archives have a trailing
  907. null.</p>
  908. <p style="margin-top: 1em"><i>version</i></p>
  909. <p style="margin-left:17%;">The version field holds a space
  910. character followed by a null. Note that POSIX ustar archives
  911. use two copies of the ASCII digit &ldquo;0&rdquo;.</p>
  912. <p style="margin-top: 1em"><i>atime</i>, <i>ctime</i></p>
  913. <p style="margin-left:17%;">The time the file was last
  914. accessed and the time of last change of file information,
  915. stored in octal as with <i>mtime</i>.</p>
  916. <p style="margin-top: 1em"><i>longnames</i></p>
  917. <p style="margin-left:17%;">This field is apparently no
  918. longer used.</p>
  919. <p style="margin-top: 1em">Sparse <i>offset /
  920. numbytes</i></p>
  921. <p style="margin-left:17%;">Each such structure specifies a
  922. single fragment of a sparse file. The two fields store
  923. values as octal numbers. The fragments are each padded to a
  924. multiple of 512 bytes in the archive. On extraction, the
  925. list of fragments is collected from the header (including
  926. any extension headers), and the data is then read and
  927. written to the file at appropriate offsets.</p>
  928. <p style="margin-top: 1em"><i>isextended</i></p>
  929. <p style="margin-left:17%;">If this is set to non-zero, the
  930. header will be followed by additional &ldquo;sparse
  931. header&rdquo; records. Each such record contains information
  932. about as many as 21 additional sparse blocks as shown
  933. here:</p>
  934. <p style="margin-left:24%; margin-top: 1em">struct
  935. gnu_sparse_header {</p>
  936. <table width="100%" border="0" rules="none" frame="void"
  937. cellspacing="0" cellpadding="0">
  938. <tr valign="top" align="left">
  939. <td width="35%"></td>
  940. <td width="10%">
  941. <p>struct {</p></td>
  942. <td width="10%"></td>
  943. <td width="45%">
  944. </td></tr>
  945. <tr valign="top" align="left">
  946. <td width="35%"></td>
  947. <td width="10%">
  948. </td>
  949. <td width="10%">
  950. <p>char offset[12];</p></td>
  951. <td width="45%">
  952. </td></tr>
  953. <tr valign="top" align="left">
  954. <td width="35%"></td>
  955. <td width="10%">
  956. </td>
  957. <td width="10%">
  958. <p>char numbytes[12];</p></td>
  959. <td width="45%">
  960. </td></tr>
  961. <tr valign="top" align="left">
  962. <td width="35%"></td>
  963. <td width="10%">
  964. <p>} sparse[21];</p></td>
  965. <td width="10%"></td>
  966. <td width="45%">
  967. </td></tr>
  968. <tr valign="top" align="left">
  969. <td width="35%"></td>
  970. <td width="10%">
  971. <p>char isextended[1];</p></td>
  972. <td width="10%"></td>
  973. <td width="45%">
  974. </td></tr>
  975. <tr valign="top" align="left">
  976. <td width="35%"></td>
  977. <td width="10%">
  978. <p>char padding[7];</p></td>
  979. <td width="10%"></td>
  980. <td width="45%">
  981. </td></tr>
  982. </table>
  983. <p style="margin-left:24%;">};</p>
  984. <p style="margin-top: 1em"><i>realsize</i></p>
  985. <p style="margin-left:17%;">A binary representation of the
  986. file&rsquo;s complete size, with a much larger range than
  987. the POSIX file size. In particular, with <b>M</b> type
  988. files, the current entry is only a portion of the file. In
  989. that case, the POSIX size field will indicate the size of
  990. this entry; the <i>realsize</i> field will indicate the
  991. total size of the file.</p>
  992. <p style="margin-left:6%; margin-top: 1em"><b>GNU tar pax
  993. archives</b> <br>
  994. GNU tar 1.14 (XXX check this XXX) and later will write pax
  995. interchange format archives when you specify the
  996. <b>--posix</b> flag. This format follows the pax interchange
  997. format closely, using some <b>SCHILY</b> tags and
  998. introducing new keywords to store sparse file information.
  999. There have been three iterations of the sparse file support,
  1000. referred to as &ldquo;0.0&rdquo;, &ldquo;0.1&rdquo;, and
  1001. &ldquo;1.0&rdquo;.</p>
  1002. <p style="margin-top: 1em"><b>GNU.sparse.numblocks</b>,
  1003. <b>GNU.sparse.offset</b>, <b>GNU.sparse.numbytes</b>,
  1004. <b>GNU.sparse.size</b></p>
  1005. <p style="margin-left:17%;">The &ldquo;0.0&rdquo; format
  1006. used an initial <b>GNU.sparse.numblocks</b> attribute to
  1007. indicate the number of blocks in the file, a pair of
  1008. <b>GNU.sparse.offset</b> and <b>GNU.sparse.numbytes</b> to
  1009. indicate the offset and size of each block, and a single
  1010. <b>GNU.sparse.size</b> to indicate the full size of the
  1011. file. This is not the same as the size in the tar header
  1012. because the latter value does not include the size of any
  1013. holes. This format required that the order of attributes be
  1014. preserved and relied on readers accepting multiple
  1015. appearances of the same attribute names, which is not
  1016. officially permitted by the standards.</p>
  1017. <p style="margin-top: 1em"><b>GNU.sparse.map</b></p>
  1018. <p style="margin-left:17%;">The &ldquo;0.1&rdquo; format
  1019. used a single attribute that stored a comma-separated list
  1020. of decimal numbers. Each pair of numbers indicated the
  1021. offset and size, respectively, of a block of data. This does
  1022. not work well if the archive is extracted by an archiver
  1023. that does not recognize this extension, since many pax
  1024. implementations simply discard unrecognized attributes.</p>
  1025. <p style="margin-top: 1em"><b>GNU.sparse.major</b>,
  1026. <b>GNU.sparse.minor</b>, <b>GNU.sparse.name</b>,
  1027. <b>GNU.sparse.realsize</b></p>
  1028. <p style="margin-left:17%;">The &ldquo;1.0&rdquo; format
  1029. stores the sparse block map in one or more 512-byte blocks
  1030. prepended to the file data in the entry body. The pax
  1031. attributes indicate the existence of this map (via the
  1032. <b>GNU.sparse.major</b> and <b>GNU.sparse.minor</b> fields)
  1033. and the full size of the file. The <b>GNU.sparse.name</b>
  1034. holds the true name of the file. To avoid confusion, the
  1035. name stored in the regular tar header is a modified name so
  1036. that extraction errors will be apparent to users.</p>
  1037. <p style="margin-left:6%; margin-top: 1em"><b>Solaris
  1038. Tar</b> <br>
  1039. XXX More Details Needed XXX</p>
  1040. <p style="margin-left:6%; margin-top: 1em">Solaris tar
  1041. (beginning with SunOS XXX 5.7 ?? XXX) supports an
  1042. &ldquo;extended&rdquo; format that is fundamentally similar
  1043. to pax interchange format, with the following
  1044. differences:</p>
  1045. <p><b>&bull;</b></p>
  1046. <p style="margin-left:17%;">Extended attributes are stored
  1047. in an entry whose type is <b>X</b>, not <b>x</b>, as used by
  1048. pax interchange format. The detailed format of this entry
  1049. appears to be the same as detailed above for the <b>x</b>
  1050. entry.</p>
  1051. <p><b>&bull;</b></p>
  1052. <p style="margin-left:17%;">An additional <b>A</b> header
  1053. is used to store an ACL for the following regular entry. The
  1054. body of this entry contains a seven-digit octal number
  1055. followed by a zero byte, followed by the textual ACL
  1056. description. The octal value is the number of ACL entries
  1057. plus a constant that indicates the ACL type: 01000000 for
  1058. POSIX.1e ACLs and 03000000 for NFSv4 ACLs.</p>
  1059. <p style="margin-left:6%; margin-top: 1em"><b>AIX Tar</b>
  1060. <br>
  1061. XXX More details needed XXX</p>
  1062. <p style="margin-left:6%; margin-top: 1em">AIX Tar uses a
  1063. ustar-formatted header with the type <b>A</b> for storing
  1064. coded ACL information. Unlike the Solaris format, AIX tar
  1065. writes this header after the regular file body to which it
  1066. applies. The pathname in this header is either <b>NFS4</b>
  1067. or <b>AIXC</b> to indicate the type of ACL stored. The
  1068. actual ACL is stored in platform-specific binary format.</p>
  1069. <p style="margin-left:6%; margin-top: 1em"><b>Mac OS X
  1070. Tar</b> <br>
  1071. The tar distributed with Apple&rsquo;s Mac OS X stores most
  1072. regular files as two separate files in the tar archive. The
  1073. two files have the same name except that the first one has
  1074. &ldquo;._&rdquo; prepended to the last path element. This
  1075. special file stores an AppleDouble-encoded binary blob with
  1076. additional metadata about the second file, including ACL,
  1077. extended attributes, and resources. To recreate the original
  1078. file on disk, each separate file can be extracted and the
  1079. Mac OS X <b>copyfile</b>() function can be used to unpack
  1080. the separate metadata file and apply it to th regular file.
  1081. Conversely, the same function provides a &ldquo;pack&rdquo;
  1082. option to encode the extended metadata from a file into a
  1083. separate file whose contents can then be put into a tar
  1084. archive.</p>
  1085. <p style="margin-left:6%; margin-top: 1em">Note that the
  1086. Apple extended attributes interact badly with long
  1087. filenames. Since each file is stored with the full name, a
  1088. separate set of extensions needs to be included in the
  1089. archive for each one, doubling the overhead required for
  1090. files with long names.</p>
  1091. <p style="margin-left:6%; margin-top: 1em"><b>Summary of
  1092. tar type codes</b> <br>
  1093. The following list is a condensed summary of the type codes
  1094. used in tar header records generated by different tar
  1095. implementations. More details about specific implementations
  1096. can be found above:</p>
  1097. <p>NUL</p>
  1098. <p style="margin-left:13%; margin-top: 1em">Early tar
  1099. programs stored a zero byte for regular files.</p>
  1100. <p><b>0</b></p>
  1101. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1102. type code for a regular file.</p>
  1103. <p><b>1</b></p>
  1104. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1105. type code for a hard link description.</p>
  1106. <p><b>2</b></p>
  1107. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1108. type code for a symbolic link description.</p>
  1109. <p><b>3</b></p>
  1110. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1111. type code for a character device node.</p>
  1112. <p><b>4</b></p>
  1113. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1114. type code for a block device node.</p>
  1115. <p><b>5</b></p>
  1116. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1117. type code for a directory.</p>
  1118. <p><b>6</b></p>
  1119. <p style="margin-left:13%; margin-top: 1em">POSIX standard
  1120. type code for a FIFO.</p>
  1121. <p><b>7</b></p>
  1122. <p style="margin-left:13%; margin-top: 1em">POSIX
  1123. reserved.</p>
  1124. <p><b>7</b></p>
  1125. <p style="margin-left:13%; margin-top: 1em">GNU tar used
  1126. for pre-allocated files on some systems.</p>
  1127. <p><b>A</b></p>
  1128. <p style="margin-left:13%; margin-top: 1em">Solaris tar ACL
  1129. description stored prior to a regular file header.</p>
  1130. <p><b>A</b></p>
  1131. <p style="margin-left:13%; margin-top: 1em">AIX tar ACL
  1132. description stored after the file body.</p>
  1133. <p><b>D</b></p>
  1134. <p style="margin-left:13%; margin-top: 1em">GNU tar
  1135. directory dump.</p>
  1136. <p><b>K</b></p>
  1137. <p style="margin-left:13%; margin-top: 1em">GNU tar long
  1138. linkname for the following header.</p>
  1139. <p><b>L</b></p>
  1140. <p style="margin-left:13%; margin-top: 1em">GNU tar long
  1141. pathname for the following header.</p>
  1142. <p><b>M</b></p>
  1143. <p style="margin-left:13%; margin-top: 1em">GNU tar
  1144. multivolume marker, indicating the file is a continuation of
  1145. a file from the previous volume.</p>
  1146. <p><b>N</b></p>
  1147. <p style="margin-left:13%; margin-top: 1em">GNU tar long
  1148. filename support. Deprecated.</p>
  1149. <p><b>S</b></p>
  1150. <p style="margin-left:13%; margin-top: 1em">GNU tar sparse
  1151. regular file.</p>
  1152. <p><b>V</b></p>
  1153. <p style="margin-left:13%; margin-top: 1em">GNU tar
  1154. tape/volume header name.</p>
  1155. <p><b>X</b></p>
  1156. <p style="margin-left:13%; margin-top: 1em">Solaris tar
  1157. general-purpose extension header.</p>
  1158. <p><b>g</b></p>
  1159. <p style="margin-left:13%; margin-top: 1em">POSIX pax
  1160. interchange format global extensions.</p>
  1161. <p><b>x</b></p>
  1162. <p style="margin-left:13%; margin-top: 1em">POSIX pax
  1163. interchange format per-file extensions.</p>
  1164. <p style="margin-top: 1em"><b>SEE ALSO</b></p>
  1165. <p style="margin-left:6%;">ar(1), pax(1), tar(1)</p>
  1166. <p style="margin-top: 1em"><b>STANDARDS</b></p>
  1167. <p style="margin-left:6%;">The <b>tar</b> utility is no
  1168. longer a part of POSIX or the Single Unix Standard. It last
  1169. appeared in Version&nbsp;2 of the Single UNIX Specification
  1170. (&ldquo;SUSv2&rdquo;). It has been supplanted in subsequent
  1171. standards by pax(1). The ustar format is currently part of
  1172. the specification for the pax(1) utility. The pax
  1173. interchange file format is new with IEEE Std 1003.1-2001
  1174. (&ldquo;POSIX.1&rdquo;).</p>
  1175. <p style="margin-top: 1em"><b>HISTORY</b></p>
  1176. <p style="margin-left:6%;">A <b>tar</b> command appeared in
  1177. Seventh Edition Unix, which was released in January, 1979.
  1178. It replaced the <b>tp</b> program from Fourth Edition Unix
  1179. which in turn replaced the <b>tap</b> program from First
  1180. Edition Unix. John Gilmore&rsquo;s <b>pdtar</b>
  1181. public-domain implementation (circa 1987) was highly
  1182. influential and formed the basis of <b>GNU tar</b> (circa
  1183. 1988). Joerg Shilling&rsquo;s <b>star</b> archiver is
  1184. another open-source (CDDL) archiver (originally developed
  1185. circa 1985) which features complete support for pax
  1186. interchange format.</p>
  1187. <p style="margin-left:6%; margin-top: 1em">This
  1188. documentation was written as part of the <b>libarchive</b>
  1189. and <b>bsdtar</b> project by Tim Kientzle
  1190. &lt;[email protected]&gt;.</p>
  1191. <p style="margin-left:6%; margin-top: 1em">BSD
  1192. December&nbsp;27, 2016 BSD</p>
  1193. <hr>
  1194. </body>
  1195. </html>