home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / gnu / tar.txt / tar-1.12 / doc / tar.info-5 (.txt) < prev    next >
GNU Info File  |  1997-04-25  |  46KB  |  790 lines

  1. This is Info file tar.info, produced by Makeinfo version 1.67 from the
  2. input file tar.texi.
  3. START-INFO-DIR-ENTRY
  4. * tar: (tar).            Making tape (or disk) archives.
  5. END-INFO-DIR-ENTRY
  6.    This file documents GNU `tar', a utility used to store, backup, and
  7. transport files.
  8.    Copyright (C) 1992, 1994, 1995, 1996, 1997 Free Software Foundation,
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20.    This file documents GNU `tar', which is a utility used to store,
  21. backup, and transport files.  `tar' is a tape (or disk) archiver.  This
  22. manual documents the release 1.12.
  23. File: tar.info,  Node: Date input formats,  Next: Formats,  Prev: Choosing,  Up: Top
  24. Date input formats
  25. ******************
  26.      Our units of temporal measurement, from seconds on up to months,
  27.      are so complicated, asymmetrical and disjunctive so as to make
  28.      coherent mental reckoning in time all but impossible.  Indeed, had
  29.      some tyrannical god contrived to enslave our minds to time, to
  30.      make it all but impossible for us to escape subjection to sodden
  31.      routines and unpleasant surprises, he could hardly have done
  32.      better than handing down our present system.  It is like a set of
  33.      trapezoidal building blocks, with no vertical or horizontal
  34.      surfaces, like a language in which the simplest thought demands
  35.      ornate constructions, useless particles and lengthy
  36.      circumlocutions.  Unlike the more successful patterns of language
  37.      and science, which enable us to face experience boldly or at least
  38.      level-headedly, our system of temporal calculation silently and
  39.      persistently encourages our terror of time.
  40.      ...  It is as though architects had to measure length in feet,
  41.      width in meters and height in ells; as though basic instruction
  42.      manuals demanded a knowledge of five different languages.  It is
  43.      no wonder then that we often look into our own immediate past or
  44.      future, last Tuesday or a week from Sunday, with feelings of
  45.      helpless confusion.  ...
  46.      -- Robert Grudin, `Time and the Art of Living'.
  47.    This section describes the textual date representations that GNU
  48. programs accept.  These are the strings you, as a user, can supply as
  49. arguments to the various programs.  The C interface (via the `getdate'
  50. function) is not described here.
  51.    Although the date syntax here can represent any possible time since
  52. zero A.D., computer integers are not big enough for such a
  53. (comparatively) long time.  The earliest date semantically allowed on
  54. Unix systems is midnight, 1 January 1970 UCT.
  55. * Menu:
  56. * General date syntax::         Common rules.
  57. * Calendar date item::          19 Dec 1994.
  58. * Time of day item::            9:20pm.
  59. * Timezone item::               EST, DST, BST, UCT, AHST, ...
  60. * Day of week item::            Monday and others.
  61. * Relative item in date strings::  next tuesday, 2 years ago.
  62. * Pure numbers in date strings::  19931219, 1440.
  63. * Authors of getdate::          Bellovin, Salz, Berets, et al.
  64. File: tar.info,  Node: General date syntax,  Next: Calendar date item,  Prev: Date input formats,  Up: Date input formats
  65. General date syntax
  66. ===================
  67.    A "date" is a string, possibly empty, containing many items
  68. separated by whitespace.  The whitespace may be omitted when no
  69. ambiguity arises.  The empty string means the beginning of today (i.e.,
  70. midnight).  Order of the items is immaterial.  A date string may contain
  71. many flavors of items:
  72.    * calendar date items
  73.    * time of the day items
  74.    * time zone items
  75.    * day of the week items
  76.    * relative items
  77.    * pure numbers.
  78. We describe each of these item types in turn, below.
  79.    A few numbers may be written out in words in most contexts.  This is
  80. most useful for specifying day of the week items or relative items (see
  81. below).  Here is the list: `first' for 1, `next' for 2, `third' for 3,
  82. `fourth' for 4, `fifth' for 5, `sixth' for 6, `seventh' for 7, `eighth'
  83. for 8, `ninth' for 9, `tenth' for 10, `eleventh' for 11 and `twelfth'
  84. for 12.  Also, `last' means exactly -1.
  85.    When a month is written this way, it is still considered to be
  86. written numerically, instead of being "spelled in full"; this changes
  87. the allowed strings.
  88.    Alphabetic case is completely ignored in dates.  Comments may be
  89. introduced between round parentheses, as long as included parentheses
  90. are properly nested.  Hyphens not followed by a digit are currently
  91. ignored.  Leading zeros on numbers are ignored.
  92. File: tar.info,  Node: Calendar date item,  Next: Time of day item,  Prev: General date syntax,  Up: Date input formats
  93. Calendar date item
  94. ==================
  95.    A "calendar date item" specifies a day of the year.  It is specified
  96. differently, depending on whether the month is specified numerically or
  97. literally.  All these strings specify the same calendar date:
  98.      1970-09-17           # ISO 8601.
  99.      70-9-17              # This century assumed by default.
  100.      70-09-17             # Leading zeros are ignored.
  101.      9/17/72              # Common U.S. writing.
  102.      24 September 1972
  103.      24 Sept 72           # September has a special abbreviation.
  104.      24 Sep 72            # Three-letter abbreviations always allowed.
  105.      Sep 24, 1972
  106.      24-sep-72
  107.      24sep72
  108.    The year can also be omitted.  In this case, the last specified year
  109. is used, or the current year if none.  For example:
  110.      9/17
  111.      sep 17
  112.    Here are the rules.
  113.    For numeric months, the ISO 8601 format `YEAR-MONTH-DAY' is allowed,
  114. where YEAR is any positive number, MONTH is a number between 01 and 12,
  115. and DAY is a number between 01 and 31.  A leading zero must be present
  116. if a number is less than ten.  If YEAR is less than 100, then 1900 is
  117. added to it to force a date in this century.  The construct
  118. `MONTH/DAY/YEAR', popular in the United States, is accepted.  Also
  119. `MONTH/DAY', omitting the year.
  120.    Literal months may be spelled out in full: `January', `February',
  121. `March', `April', `May', `June', `July', `August', `September',
  122. `October', `November' or `December'.  Literal months may be abbreviated
  123. to their first three letters, possibly followed by an abbreviating dot.
  124. It is also permitted to write `Sept' instead of `September'.
  125.    When months are written literally, the calendar date may be given as
  126. any of the following:
  127.      DAY MONTH YEAR
  128.      DAY MONTH
  129.      MONTH DAY YEAR
  130.      DAY-MONTH-YEAR
  131.    Or, omitting the year:
  132.      MONTH DAY
  133. File: tar.info,  Node: Time of day item,  Next: Timezone item,  Prev: Calendar date item,  Up: Date input formats
  134. Time of day item
  135. ================
  136.    A "time of day item" in date strings specifies the time on a given
  137. day.  Here are some examples, all of which represent the same time:
  138.      20:02:0
  139.      20:02
  140.      8:02pm
  141.      20:02-0500      # In EST (Eastern U.S. Standard Time).
  142.    More generally, the time of the day may be given as
  143. `HOUR:MINUTE:SECOND', where HOUR is a number between 0 and 23, MINUTE
  144. is a number between 0 and 59, and SECOND is a number between 0 and 59.
  145. Alternatively, `:SECOND' can be omitted, in which case it is taken to
  146. be zero.
  147.    If the time is followed by `am' or `pm' (or `a.m.' or `p.m.'), HOUR
  148. is restricted to run from 1 to 12, and `:MINUTE' may be omitted (taken
  149. to be zero).  `am' indicates the first half of the day, `pm' indicates
  150. the second half of the day.  In this notation, 12 is the predecessor of
  151. 1: midnight is `12am' while noon is `12pm'.
  152.    The time may alternatively be followed by a timezone correction,
  153. expressed as `SHHMM', where S is `+' or `-', HH is a number of zone
  154. hours and MM is a number of zone minutes.  When a timezone correction
  155. is given this way, it forces interpretation of the time in UTC,
  156. overriding any previous specification for the timezone or the local
  157. timezone.  The MINUTE part of the time of the day may not be elided
  158. when a timezone correction is used.  This is the only way to specify a
  159. timezone correction by fractional parts of an hour.
  160.    Either `am'/`pm' or a timezone correction may be specified, but not
  161. both.
  162. File: tar.info,  Node: Timezone item,  Next: Day of week item,  Prev: Time of day item,  Up: Date input formats
  163. Timezone item
  164. =============
  165.    A "timezone item" specifies an international timezone, indicated by
  166. a small set of letters.  Any included period is ignored.  Military
  167. timezone designations use a single letter.  Currently, only integral
  168. zone hours may be represented in a timezone item.  See the previous
  169. section for a finer control over the timezone correction.
  170.    Here are many non-daylight-savings-time timezones, indexed by the
  171. zone hour value.
  172.      `GMT' for Greenwich Mean, `UT' or `UTC' for Universal
  173.      (Coordinated), `WET' for Western European and `Z' for militaries.
  174.      `WAT' for West Africa and `A' for militaries.
  175.      `AT' for Azores and `B' for militaries.
  176.      `C' for militaries.
  177.      `AST' for Atlantic Standard and `D' for militaries.
  178.      `E' for militaries and `EST' for Eastern Standard.
  179.      `CST' for Central Standard and `F' for militaries.
  180.      `G' for militaries and `MST' for Mountain Standard.
  181.      `H' for militaries and `PST' for Pacific Standard.
  182.      `I' for militaries and `YST' for Yukon Standard.
  183. +1000
  184.      `AHST' for Alaska-Hawaii Standard, `CAT' for Central Alaska, `HST'
  185.      for Hawaii Standard and `K' for militaries.
  186. +1100
  187.      `L' for militaries and `NT' for Nome.
  188. +1200
  189.      `IDLW' for International Date Line West and `M' for militaries.
  190.      `CET' for Central European, `FWT' for French Winter, `MET' for
  191.      Middle European, `MEWT' for Middle European Winter, `N' for
  192.      militaries and `SWT' for Swedish Winter.
  193.      `EET' for Eastern European, USSR Zone 1 and `O' for militaries.
  194.      `BT' for Baghdad, USSR Zone 2 and `P' for militaries.
  195.      `Q' for militaries and `ZP4' for USSR Zone 3.
  196.      `R' for militaries and `ZP5' for USSR Zone 4.
  197.      `S' for militaries and `ZP6' for USSR Zone 5.
  198.      `T' for militaries and `WAST' for West Australian Standard.
  199.      `CCT' for China Coast, USSR Zone 7 and `U' for militaries.
  200.      `JST' for Japan Standard, USSR Zone 8 and `V' for militaries.
  201. -1000
  202.      `EAST' for East Australian Standard, `GST' for Guam Standard, USSR
  203.      Zone 9 and `W' for militaries.
  204. -1100
  205.      `X' for militaries.
  206. -1200
  207.      `IDLE' for International Date Line East, `NZST' for New Zealand
  208.      Standard, `NZT' for New Zealand and `Y' for militaries.
  209.    Here are many DST timezones, indexed by the zone hour value.  Also,
  210. by following a non-DST timezone by the string `DST' in a separate word
  211. (that is, separated by some whitespace), the corresponding DST timezone
  212. may be specified.
  213.      `BST' for British Summer.
  214.      `ADT' for Atlantic Daylight.
  215.      `EDT' for Eastern Daylight.
  216.      `CDT' for Central Daylight.
  217.      `MDT' for Mountain Daylight.
  218.      `PDT' for Pacific Daylight.
  219.      `YDT' for Yukon Daylight.
  220. +1000
  221.      `HDT' for Hawaii Daylight.
  222.      `MEST' for Middle European Summer, `MESZ' for Middle European
  223.      Summer, `SST' for Swedish Summer and `FST' for French Summer.
  224.      `WADT' for West Australian Daylight.
  225. -1000
  226.      `EADT' for Eastern Australian Daylight.
  227. -1200
  228.      `NZDT' for New Zealand Daylight.
  229. File: tar.info,  Node: Day of week item,  Next: Relative item in date strings,  Prev: Timezone item,  Up: Date input formats
  230. Day of week item
  231. ================
  232.    The explicit mention of a day of the week will forward the date
  233. (only if necessary) to reach that day of the week in the future.
  234.    Days of the week may be spelled out in full: `Sunday', `Monday',
  235. `Tuesday', `Wednesday', `Thursday', `Friday' or `Saturday'.  Days may
  236. be abbreviated to their first three letters, optionally followed by a
  237. period.  The special abbreviations `Tues' for `Tuesday', `Wednes' for
  238. `Wednesday' and `Thur' or `Thurs' for `Thursday' are also allowed.
  239.    A number may precede a day of the week item to move forward
  240. supplementary weeks.  It is best used in expression like `third
  241. monday'.  In this context, `last DAY' or `next DAY' is also acceptable;
  242. they move one week before or after the day that DAY by itself would
  243. represent.
  244.    A comma following a day of the week item is ignored.
  245. File: tar.info,  Node: Relative item in date strings,  Next: Pure numbers in date strings,  Prev: Day of week item,  Up: Date input formats
  246. Relative item in date strings
  247. =============================
  248.    "Relative items" adjust a date (or the current date if none) forward
  249. or backward.  The effects of relative items accumulate.  Here are some
  250. examples:
  251.      1 year
  252.      1 year ago
  253.      3 years
  254.      2 days
  255.    The unit of time displacement may be selected by the string `year'
  256. or `month' for moving by whole years or months.  These are fuzzy units,
  257. as years and months are not all of equal duration.  More precise units
  258. are `fortnight' which is worth 14 days, `week' worth 7 days, `day'
  259. worth 24 hours, `hour' worth 60 minutes, `minute' or `min' worth 60
  260. seconds, and `second' or `sec' worth one second.  An `s' suffix on
  261. these units is accepted and ignored.
  262.    The unit of time may be preceded by a multiplier, given as an
  263. optionally signed number.  Unsigned numbers are taken as positively
  264. signed.  No number at all implies 1 for a multiplier.  Following a
  265. relative item by the string `ago' is equivalent to preceding the unit
  266. by a multiplicator with value -1.
  267.    The string `tomorrow' is worth one day in the future (equivalent to
  268. `day'), the string `yesterday' is worth one day in the past (equivalent
  269. to `day ago').
  270.    The strings `now' or `today' are relative items corresponding to
  271. zero-valued time displacement, these strings come from the fact a
  272. zero-valued time displacement represents the current time when not
  273. otherwise change by previous items.  They may be used to stress other
  274. items, like in `12:00 today'.  The string `this' also has the meaning
  275. of a zero-valued time displacement, but is preferred in date strings
  276. like `this thursday'.
  277.    When a relative item makes the resulting date to cross the boundary
  278. between DST and non-DST (or vice-versa), the hour is adjusted according
  279. to the local time.
  280. File: tar.info,  Node: Pure numbers in date strings,  Next: Authors of getdate,  Prev: Relative item in date strings,  Up: Date input formats
  281. Pure numbers in date strings
  282. ============================
  283.    The precise intepretation of a pure decimal number is dependent of
  284. the context in the date string.
  285.    If the decimal number is of the form YYYYMMDD and no other calendar
  286. date item (*note Calendar date item::.) appears before it in the date
  287. string, then YYYY is read as the year, MM as the month number and DD as
  288. the day of the month, for the specified calendar date.
  289.    If the decimal number is of the form HHMM and no other time of day
  290. item appears before it in the date string, then HH is read as the hour
  291. of the day and MM as the minute of the hour, for the specified time of
  292. the day.  MM can also be omitted.
  293.    If both a calendar date and a time of day appear to the left of a
  294. number in the date string, but no relative item, then the number
  295. overrides the year.
  296. File: tar.info,  Node: Authors of getdate,  Prev: Pure numbers in date strings,  Up: Date input formats
  297. Authors of `getdate'
  298. ====================
  299.    `getdate' was originally implemented by Steven M. Bellovin
  300. (`smb@research.att.com') while at the University of North Carolina at
  301. Chapel Hill.  The code was later tweaked by a couple of people on
  302. Usenet, then completely overhauled by Rich $alz (`rsalz@bbn.com') and
  303. Jim Berets (`jberets@bbn.com') in August, 1990.  Various revisions for
  304. the GNU system were made by David MacKenzie, Jim Meyering, and others.
  305.    This chapter was originally produced by Franc,ois Pinard
  306. (`pinard@iro.umontreal.ca') from the `getdate.y' source code, and then
  307. edited by K. Berry (`kb@cs.umb.edu').
  308. File: tar.info,  Node: Formats,  Next: Media,  Prev: Date input formats,  Up: Top
  309. Controlling the Archive Format
  310. ******************************
  311. * Menu:
  312. * Portability::                 Making `tar' Archives More Portable
  313. * Compression::                 Using Less Space through Compression
  314. * Attributes::                  Handling File Attributes
  315. * Standard::                    The Standard Format
  316. * Extensions::                  GNU Extensions to the Archive Format
  317. * cpio::                        Comparison of `tar' and `cpio'
  318. File: tar.info,  Node: Portability,  Next: Compression,  Prev: Formats,  Up: Formats
  319. Making `tar' Archives More Portable
  320. ===================================
  321.    Creating a `tar' archive on a particular system that is meant to be
  322. useful later on many other machines and with other versions of `tar' is
  323. more challenging than you might think.  `tar' archive formats have been
  324. evolving since the first versions of Unix.  Many such formats are
  325. around, and are not always comptible with each other.  This section
  326. discusses a few problems, and gives some advice about making `tar'
  327. archives more portable.
  328.    One golden rule is simplicity.  For example, limit your `tar'
  329. archives to contain only regular files and directories, avoiding other
  330. kind of special files.  Do not attempt to save sparse files or
  331. contiguous files as such.  Let's discuss a few more problems, in turn.
  332. * Menu:
  333. * Portable Names::              Portable Names
  334. * dereference::                 Symbolic Links
  335. * old::                         Old V7 Archives
  336. * posix::                       POSIX archives
  337. * Checksumming::                Checksumming Problems
  338. File: tar.info,  Node: Portable Names,  Next: dereference,  Prev: Portability,  Up: Portability
  339. Portable Names
  340. --------------
  341.    Use *straight* file and directory names, made up of printable ASCII
  342. characters, avoiding colons, slashes, backslashes, spaces, and other
  343. *dangerous* characters.  Avoid deep directory nesting.  Accounting for
  344. oldish System V machines, limit your file and directory names to 14
  345. characters or less.
  346.    If you intend to have your `tar' archives to be read under MSDOS,
  347. you should not rely on case distinction for file names, and you might
  348. use the GNU `doschk' program for helping you further diagnosing illegal
  349. MSDOS names, which are even more limited than System V's.
  350. File: tar.info,  Node: dereference,  Next: old,  Prev: Portable Names,  Up: Portability
  351. Symbolic Links
  352. --------------
  353.    Normally, when `tar' archives a symbolic link, it writes a block to
  354. the archive naming the target of the link.  In that way, the `tar'
  355. archive is a faithful record of the filesystem contents.
  356. `--dereference' (`-h') is used with `--create' (`-c'), and causes `tar'
  357. to archive the files symbolic links point to, instead of the links
  358. themselves.  When this option is used, when `tar' encounters a symbolic
  359. link, it will archive the linked-to file, instead of simply recording
  360. the presence of a symbolic link.
  361.    The name under which the file is stored in the file system is not
  362. recorded in the archive.  To record both the symbolic link name and the
  363. file name in the system, archive the file under both names.  If all
  364. links were recorded automatically by `tar', an extracted file might be
  365. linked to a file name that no longer exists in the file system.
  366.    If a linked-to file is encountered again by `tar' while creating the
  367. same archive, an entire second copy of it will be stored.  (This
  368. *might* be considered a bug.)
  369.    So, for portable archives, do not archive symbolic links as such,
  370. and use `--dereference' (`-h'): many systems do not support symbolic
  371. links, and moreover, your distribution might be unusable if it contains
  372. unresolved symbolic links.
  373. File: tar.info,  Node: old,  Next: posix,  Prev: dereference,  Up: Portability
  374. Old V7 Archives
  375. ---------------
  376.    Certain old versions of `tar' cannot handle additional information
  377. recorded by newer `tar' programs.  To create an archive in V7 format
  378. (not ANSI), which can be read by these old versions, specify the
  379. `--old-archive' (`-o') option in conjunction with the `--create'
  380. (`-c').  `tar' also accepts `--portability' for this option.  When you
  381. specify it, `tar' leaves out information about directories, pipes,
  382. fifos, contiguous files, and device files, and specifies file ownership
  383. by group and user IDs instead of group and user names.
  384.    When updating an archive, do not use `--old-archive' (`-o') unless
  385. the archive was created with using this option.
  386.    In most cases, a *new* format archive can be read by an *old* `tar'
  387. program without serious trouble, so this option should seldom be
  388. needed.  On the other hand, most modern `tar's are able to read old
  389. format archives, so it might be safer for you to always use
  390. `--old-archive' (`-o') for your distributions.
  391. File: tar.info,  Node: posix,  Next: Checksumming,  Prev: old,  Up: Portability
  392. GNU `tar' and POSIX `tar'
  393. -------------------------
  394.    GNU `tar' was based on an early draft of the POSIX 1003.1 `ustar'
  395. standard.  GNU extensions to `tar', such as the support for file names
  396. longer than 100 characters, use portions of the `tar' header record
  397. which were specified in that POSIX draft as unused.  Subsequent changes
  398. in POSIX have allocated the same parts of the header record for other
  399. purposes.  As a result, GNU `tar' is incompatible with the current
  400. POSIX spec, and with `tar' programs that follow it.
  401.    We plan to reimplement these GNU extensions in a new way which is
  402. upward compatible with the latest POSIX `tar' format, but we don't know
  403. when this will be done.
  404.    In the mean time, there is simply no telling what might happen if you
  405. read a GNU `tar' archive, which uses the GNU extensions, using some
  406. other `tar' program.  So if you want to read the archive with another
  407. `tar' program, be sure to write it using the `--old-archive' option
  408. (`-o').
  409.    Traditionally, old `tar's have a limit of 100 characters.  GNU `tar'
  410. attempted two different approaches to overcome this limit, using and
  411. extending a format specified by a draft of some P1003.1.  The first way
  412. was not that successful, and involved `@MaNgLeD@' file names, or such;
  413. while a second approach used `././@LongLink' and other tricks, yielding
  414. better success.  In theory, GNU `tar' should be able to handle file
  415. names of practically unlimited length.  So, if GNU `tar' fails to dump
  416. and retrieve files having more than 100 characters, then there is a bug
  417. in GNU `tar', indeed.
  418.    But, being strictly POSIX, the limit was still 100 characters.  For
  419. various other purposes, GNU `tar' used areas left unassigned in the
  420. POSIX draft.  POSIX later revised P1003.1 `ustar' format by assigning
  421. previously unused header fields, in such a way that the upper limit for
  422. file name length was raised to 256 characters.  However, the actual
  423. POSIX limit oscillates between 100 and 256, depending on the precise
  424. location of slashes in full file name (this is rather ugly).  Since GNU
  425. `tar' use the same fields for quite other purposes, it became
  426. incompatible with the latest POSIX standards.
  427.    For longer or non-fitting file names, we plan to use yet another set
  428. of GNU extensions, but this time, complying with the provisions POSIX
  429. offers for extending the format, rather than conflicting with it.
  430. Whenever an archive uses old GNU `tar' extension format or POSIX
  431. extensions, would it be for very long file names or other specialities,
  432. this archive becomes non-portable to other `tar' implementations.  In
  433. fact, anything can happen.  The most forgiving `tar's will merely
  434. unpack the file using a wrong name, and maybe create another file named
  435. something like `@LongName', with the true file name in it.  `tar's not
  436. protecting themselves may segment violate!
  437.    Compatibility concerns make all this thing more difficult, as we
  438. will have to support *all* these things together, for a while.  GNU
  439. `tar' should be able to produce and read true POSIX format files, while
  440. being able to detect old GNU `tar' formats, besides old V7 format, and
  441. process them conveniently.  It would take years before this whole area
  442. stabilizes...
  443.    There are plans to raise this 100 limit to 256, and yet produce POSIX
  444. conformant archives.  Past 256, I do not know yet if GNU `tar' will go
  445. non-POSIX again, or merely refuse to archive the file.
  446.    There are plans so GNU `tar' support more fully the latest POSIX
  447. format, while being able to read old V7 format, GNU (semi-POSIX plus
  448. extension), as well as full POSIX.  One may ask if there is part of the
  449. POSIX format that we still cannot support.  This simple question has a
  450. complex answer.  Maybe that, on intimate look, some strong limitations
  451. will pop up, but until now, nothing sounds too difficult (but see
  452. below).  I only have these few pages of POSIX telling about `Extended
  453. tar Format' (P1003.1-1990 - section 10.1.1), and there are references
  454. to other parts of the standard I do not have, which should normally
  455. enforce limitations on stored file names (I suspect things like fixing
  456. what `/' and `<NUL>' means).  There are also some points which the
  457. standard does not make clear, Existing practice will then drive what I
  458. should do.
  459.    POSIX mandates that, when a file name cannot fit within 100 to 256
  460. characters (the variance comes from the fact a `/' is ideally needed as
  461. the 156'th character), or a link name cannot fit within 100 characters,
  462. a warning should be issued and the file *not* be stored.  Unless some
  463. `--posix' option is given (or `POSIXLY_CORRECT' is set), I suspect that
  464. GNU `tar' should disobey this specification, and automatically switch
  465. to using GNU extensions to overcome file name or link name length
  466. limitations.
  467.    There is a problem, however, which I did not intimately studied yet.
  468. Given a truly POSIX archive with names having more than 100 characters,
  469. I guess that GNU `tar' up to 1.11.8 will process it as if it were an
  470. old V7 archive, and be fooled by some fields which are coded
  471. differently.  So, the question is to decide if the next generation of
  472. GNU `tar' should produce POSIX format by default, whenever possible,
  473. producing archives older versions of GNU `tar' might not be able to read
  474. correctly.  I fear that we will have to suffer such a choice one of
  475. these days, if we want GNU `tar' to go closer to POSIX.  We can rush it.
  476. Another possibility is to produce the current GNU `tar' format by
  477. default for a few years, but have GNU `tar' versions from some 1.POSIX
  478. and up able to recognize all three formats, and let older GNU `tar'
  479. fade out slowly.  Then, we could switch to producing POSIX format by
  480. default, with not much harm to those still having (very old at that
  481. time) GNU `tar' versions prior to 1.POSIX.
  482.    POSIX format cannot represent very long names, volume headers,
  483. splitting of files in multi-volumes, sparse files, and incremental
  484. dumps; these would be all disallowed if `--posix' or `POSIXLY_CORRECT'.
  485. Otherwise, if `tar' is given long names, or `-[VMSgG]', then it should
  486. automatically go non-POSIX.  I think this is easily granted without
  487. much discussion.
  488.    Another point is that only `mtime' is stored in POSIX archives,
  489. while GNU `tar' currently also store `atime' and `ctime'.  If we want
  490. GNU `tar' to go closer to POSIX, my choice would be to drop `atime' and
  491. `ctime' support on average.  On the other hand, I perceive that full
  492. dumps or incremental dumps need `atime' and `ctime' support, so for
  493. those special applications, POSIX has to be avoided altogether.
  494.    A few users requested that `--sparse' (`-S') be always active by
  495. default, I think that before replying to them, we have to decide if we
  496. want GNU `tar' to go closer to POSIX on average, while producing files.
  497. My choice would be to go closer to POSIX in the long run.  Besides
  498. possible double reading, I do not see any point of not trying to save
  499. files as sparse when creating archives which are neither POSIX nor
  500. old-V7, so the actual `--sparse' (`-S') would become selected by
  501. default when producing such archives, whatever the reason is.  So,
  502. `--sparse' (`-S') alone might be redefined to force GNU-format
  503. archives, and recover its previous meaning from this fact.
  504.    GNU-format as it exists now can easily fool other POSIX `tar', as it
  505. uses fields which POSIX considers to be part of the file name prefix.
  506. I wonder if it would not be a good idea, in the long run, to try
  507. changing GNU-format so any added field (like `ctime', `atime', file
  508. offset in subsequent volumes, or sparse file descriptions) be wholly
  509. and always pushed into an extension block, instead of using space in
  510. the POSIX header block.  I could manage to do that portably between
  511. future GNU `tar's.  So other POSIX `tar's might be at least able to
  512. provide kind of correct listings for the archives produced by GNU
  513. `tar', if not able to process them otherwise.
  514.    Using these projected extensions might induce older `tar's to fail.
  515. We would use the same approach as for POSIX.  I'll put out a `tar'
  516. capable of reading POSIXier, yet extended archives, but will not produce
  517. this format by default, in GNU mode.  In a few years, when newer GNU
  518. `tar's will have flooded out `tar' 1.11.X and previous, we could switch
  519. to producing POSIXier extended archives, with no real harm to users, as
  520. almost all existing GNU `tar's will be ready to read POSIXier format.
  521. In fact, I'll do both changes at the same time, in a few years, and
  522. just prepare `tar' for both changes, without effecting them, from
  523. 1.POSIX.  (Both changes: 1--using POSIX convention for getting over 100
  524. characters; 2--avoiding mangling POSIX headers for GNU extensions,
  525. using only POSIX mandated extension techniques).
  526.    So, a future `tar' will have a `--posix' flag forcing the usage of
  527. truly POSIX headers, and so, producing archives previous GNU `tar' will
  528. not be able to read.  So, *once* pretest will announce that feature, it
  529. would be particularly useful that users test how exchangeable will be
  530. archives between GNU `tar' with `--posix' and other POSIX `tar'.
  531.    In a few years, when GNU `tar' will produce POSIX headers by
  532. default, `--posix' will have a strong meaning and will disallow GNU
  533. extensions.  But in the meantime, for a long while, `--posix' in GNU
  534. tar will not disallow GNU extensions like `--label=ARCHIVE-LABEL' (`-V
  535. ARCHIVE-LABEL'), `--multi-volume' (`-M'), `--sparse' (`-S'), or very
  536. long file or link names.  However, `--posix' with GNU extensions will
  537. use POSIX headers with reserved-for-users extensions to headers, and I
  538. will be curious to know how well or bad POSIX `tar's will react to
  539. these.
  540.    GNU `tar' prior to 1.POSIX, and after 1.POSIX without `--posix',
  541. generates and checks `ustar  ', with two suffixed spaces.  This is
  542. sufficient for older GNU `tar' not to recognize POSIX archives, and
  543. consequently, wrongly decide those archives are in old V7 format.  It
  544. is a useful bug for me, because GNU `tar' has other POSIX
  545. incompatibilities, and I need to segregate GNU `tar' semi-POSIX
  546. archives from truly POSIX archives, for GNU `tar' should be somewhat
  547. compatible with itself, while migrating closer to latest POSIX
  548. standards.  So, I'll be very careful about how and when I will do the
  549. correction.
  550. File: tar.info,  Node: Checksumming,  Prev: posix,  Up: Portability
  551. Checksumming Problems
  552. ---------------------
  553.    SunOS and HP-UX `tar' fail to accept archives created using GNU
  554. `tar' and containing non-ASCII file names, that is, file names having
  555. characters with the eight bit set, because they use signed checksums,
  556. while GNU `tar' uses unsigned checksums while creating archives, as per
  557. POSIX standards.  On reading, GNU `tar' computes both checksums and
  558. accept any.  It is somewhat worrying that a lot of people may go around
  559. doing backup of their files using faulty (or at least non-standard)
  560. software, not learning about it until it's time to restore their
  561. missing files with an incompatible file extractor, or vice versa.
  562.    GNU `tar' compute checksums both ways, and accept any on read, so
  563. GNU tar can read Sun tapes even with their wrong checksums.  GNU `tar'
  564. produces the standard checksum, however, raising incompatibilities with
  565. Sun.  That is to say, GNU `tar' has not been modified to *produce*
  566. incorrect archives to be read by buggy `tar''s.  I've been told that
  567. more recent Sun `tar' now read standard archives, so maybe Sun did a
  568. similar patch, after all?
  569.    The story seems to be that when Sun first imported `tar' sources on
  570. their system, they recompiled it without realizing that the checksums
  571. were computed differently, because of a change in the default signing
  572. of `char''s in their compiler.  So they started computing checksums
  573. wrongly.  When they later realized their mistake, they merely decided
  574. to stay compatible with it, and with themselves afterwards.
  575. Presumably, but I do not really know, HP-UX has chosen that their `tar'
  576. archives to be compatible with Sun's.  The current standards do not
  577. favor Sun `tar' format.  In any case, it now falls on the shoulders of
  578. SunOS and HP-UX users to get a `tar' able to read the good archives
  579. they receive.
  580. File: tar.info,  Node: Compression,  Next: Attributes,  Prev: Portability,  Up: Formats
  581. Using Less Space through Compression
  582. ====================================
  583. * Menu:
  584. * gzip::                        Creating and Reading Compressed Archives
  585. * sparse::                      Archiving Sparse Files
  586. File: tar.info,  Node: gzip,  Next: sparse,  Prev: Compression,  Up: Compression
  587. Creating and Reading Compressed Archives
  588. ----------------------------------------
  589.      *(This message will disappear, once this node revised.)*
  590. `--gzip'
  591. `--ungzip'
  592.      Filter the archive through `gzip'.
  593.    Some format parameters must be taken into consideration when
  594. modifying an archive: .  Compressed archives cannot be modified.
  595.    You can use `--gzip' and `--gunzip' on physical devices (tape
  596. drives, etc.) and remote files as well as on normal files; data to or
  597. from such devices or remote files is reblocked by another copy of the
  598. `tar' program to enforce the specified (or default) record size.  The
  599. default compression parameters are used; if you need to override them,
  600. avoid the `--gzip' (`--gunzip', `--ungzip', `-z') option and run `gzip'
  601. explicitly.  (Or set the `GZIP' environment variable.)
  602.    The `--gzip' (`--gunzip', `--ungzip', `-z') option does not work
  603. with the `--multi-volume' (`-M') option, or with the `--update' (`-u'),
  604. `--append' (`-r'), `--concatenate' (`--catenate', `-A'), or `--delete'
  605. operations.
  606.    It is not exact to say that GNU `tar' is to work in concert with
  607. `gzip' in a way similar to `zip', say.  Surely, it is possible that
  608. `tar' and `gzip' be done with a single call, like in:
  609.      $ tar cfz archive.tar.gz subdir
  610. to save all of `subdir' into a `gzip''ed archive.  Later you can do:
  611.      $ tar xfz archive.tar.gz
  612. to explode and unpack.
  613.    The difference is that the whole archive is compressed.  With `zip',
  614. archive members are archived individually.  `tar''s method yields
  615. better compression.  On the other hand, one can view the contents of a
  616. `zip' archive without having to decompress it.  As for the `tar' and
  617. `gzip' tandem, you need to decompress the archive to see its contents.
  618. However, this may be done without needing disk space, by using pipes
  619. internally:
  620.      $ tar tfz archive.tar.gz
  621.    About corrupted compressed archives: `gzip''ed files have no
  622. redundancy, for maximum compression.  The adaptive nature of the
  623. compression scheme means that the compression tables are implicitly
  624. spread all over the archive.  If you lose a few blocks, the dynamic
  625. construction of the compression tables becomes unsychronized, and there
  626. is little chance that you could recover later in the archive.
  627.    There are pending suggestions for having a per-volume or per-file
  628. compression in GNU `tar'.  This would allow for viewing the contents
  629. without decompression, and for resynchronizing decompression at every
  630. volume or file, in case of corrupted archives.  Doing so, we might
  631. loose some compressibility.  But this would have make recovering easier.
  632. So, there are pros and cons.  We'll see!
  633. `--compress'
  634. `--uncompress'
  635.      Filter the archive through `compress'.  Otherwise like `--gzip'
  636.      (`--gunzip', `--ungzip', `-z').
  637. `--use-compress-program=PROG'
  638.      Filter through PROG (must accept `-d').
  639.    `--compress' (`--uncompress', `-Z') stores an archive in compressed
  640. format.  This option is useful in saving time over networks and space
  641. in pipes, and when storage space is at a premium.  `--compress'
  642. (`--uncompress', `-Z') causes `tar' to compress when writing the
  643. archive, or to uncompress when reading the archive.
  644.    To perform compression and uncompression on the archive, `tar' runs
  645. the `compress' utility.  `tar' uses the default compression parameters;
  646. if you need to override them, avoid the `--compress' (`--uncompress',
  647. `-Z') option and run the `compress' utility explicitly.  It is useful
  648. to be able to call the `compress' utility from within `tar' because the
  649. `compress' utility by itself cannot access remote tape drives.
  650.    The `--compress' (`--uncompress', `-Z') option will not work in
  651. conjunction with the `--multi-volume' (`-M') option or the `--append'
  652. (`-r'), `--update' (`-u'), `--append' (`-r') and `--delete' operations.
  653. *Note Operations::, for more information on these operations.
  654.    If there is no compress utility available, `tar' will report an
  655. error.  *Please note* that the `compress' program may be covered by a
  656. patent, and therefore we recommend you stop using it.
  657. `--compress'
  658. `--uncompress'
  659.      When this option is specified, `tar' will compress (when writing
  660.      an archive), or uncompress (when reading an archive).  Used in
  661.      conjunction with the `--create' (`-c'), `--extract' (`--get',
  662.      `-x'), `--list' (`-t') and `--compare' (`--diff', `-d') operations.
  663.    You can have archives be compressed by using the `--gzip'
  664. (`--gunzip', `--ungzip', `-z') option.  This will arrange for `tar' to
  665. use the `gzip' program to be used to compress or uncompress the archive
  666. wren writing or reading it.
  667.    To use the older, obsolete, `compress' program, use the `--compress'
  668. (`--uncompress', `-Z') option.  The GNU Project recommends you not use
  669. `compress', because there is a patent covering the algorithm it uses.
  670. You could be sued for patent infringment merely by running `compress'.
  671.    I have one question, or maybe it's a suggestion if there isn't a way
  672. to do it now. I would like to use `--gzip' (`--gunzip', `--ungzip',
  673. `-z'), but I'd also like the output to be fed through a program like
  674. GNU `ecc' (actually, right now that's `exactly' what I'd like to use
  675. :-)), basically adding ECC protection on top of compression.  It seems
  676. as if this should be quite easy to do, but I can't work out exactly how
  677. to go about it.  Of course, I can pipe the standard output of `tar'
  678. through `ecc', but then I lose (though I haven't started using it yet,
  679. I confess) the ability to have `tar' use `rmt' for it's I/O (I think).
  680.    I think the most straightforward thing would be to let me specify a
  681. general set of filters outboard of compression (preferably ordered, so
  682. the order can be automatically reversed on input operations, and with
  683. the options they require specifiable), but beggars shouldn't be
  684. choosers and anything you decide on would be fine with me.
  685.    By the way, I like `ecc' but if (as the comments say) it can't deal
  686. with loss of block sync, I'm tempted to throw some time at adding that
  687. capability.  Supposing I were to actually do such a thing and get it
  688. (apparantly) working, do you accept contributed changes to utilities
  689. like that?  (Leigh Clayton `loc@soliton.com', May 1995).
  690.    Isn't that exactly the role of the `--use-compress-prog=PROGRAM'
  691. option?  I never tried it myself, but I suspect you may want to write a
  692. PROG script or program able to filter stdin to stdout to way you want.
  693. It should recognize the `-d' option, for when extraction is needed
  694. rather than creation.
  695.    It has been reported that if one writes compressed data (through the
  696. `--gzip' (`--gunzip', `--ungzip', `-z') or `--compress'
  697. (`--uncompress', `-Z') options) to a DLT and tries to use the DLT
  698. compression mode, the data will actually get bigger and one will end up
  699. with less space on the tape.
  700. File: tar.info,  Node: sparse,  Prev: gzip,  Up: Compression
  701. Archiving Sparse Files
  702. ----------------------
  703.      *(This message will disappear, once this node revised.)*
  704. `--sparse'
  705.      Handle sparse files efficiently.
  706.    This option causes all files to be put in the archive to be tested
  707. for sparseness, and handled specially if they are.  The `--sparse'
  708. (`-S') option is useful when many `dbm' files, for example, are being
  709. backed up.  Using this option dramatically decreases the amount of
  710. space needed to store such a file.
  711.    In later versions, this option may be removed, and the testing and
  712. treatment of sparse files may be done automatically with any special
  713. GNU options.  For now, it is an option needing to be specified on the
  714. command line with the creation or updating of an archive.
  715.    Files in the filesystem occasionally have "holes."  A hole in a file
  716. is a section of the file's contents which was never written.  The
  717. contents of a hole read as all zeros.  On many operating systems,
  718. actual disk storage is not allocated for holes, but they are counted in
  719. the length of the file.  If you archive such a file, `tar' could create
  720. an archive longer than the original.  To have `tar' attempt to
  721. recognize the holes in a file, use `--sparse' (`-S').  When you use the
  722. `--sparse' (`-S') option, then, for any file using less disk space than
  723. would be expected from its length, `tar' searches the file for
  724. consecutive stretches of zeros.  It then records in the archive for the
  725. file where the consecutive stretches of zeros are, and only archives
  726. the "real contents" of the file.  On extraction (using `--sparse'
  727. (`-S') is not needed on extraction) any such files have hols created
  728. wherever the continuous stretches of zeros were found.  Thus, if you
  729. use `--sparse' (`-S'), `tar' archives won't take more space than the
  730. original.
  731.    A file is sparse if it contains blocks of zeros whose existence is
  732. recorded, but that have no space allocated on disk.  When you specify
  733. the `--sparse' (`-S') option in conjunction with the `--create' (`-c')
  734. operation, `tar' tests all files for sparseness while archiving.  If
  735. `tar' finds a file to be sparse, it uses a sparse representation of the
  736. file in the archive.  *Note create::, for more information about
  737. creating archives.
  738.    `--sparse' (`-S') is useful when archiving files, such as dbm files,
  739. likely to contain many nulls.  This option dramatically decreases the
  740. amount of space needed to store such an archive.
  741.      *Please Note:* Always use `--sparse' (`-S') when performing file
  742.      system backups, to avoid archiving the expanded forms of files
  743.      stored sparsely in the system.
  744.      Even if your system has no sparse files currently, some may be
  745.      created in the future.  If you use `--sparse' (`-S') while making
  746.      file system backups as a matter of course, you can be assured the
  747.      archive will never take more space on the media than the files
  748.      take on disk (otherwise, archiving a disk filled with sparse files
  749.      might take hundreds of tapes).
  750.    `tar' ignores the `--sparse' (`-S') option when reading an archive.
  751. `--sparse'
  752.      Files stored sparsely in the file system are represented sparsely
  753.      in the archive.  Use in conjunction with write operations.
  754.    However, users should be well aware that at archive creation time,
  755. GNU `tar' still has to read whole disk file to locate the "holes", and
  756. so, even if sparse files use little space on disk and in the archive,
  757. they may sometimes require inordinate amount of time for reading and
  758. examining all-zero blocks of a file.  Although it works, it's painfully
  759. slow for a large (sparse) file, even though the resulting tar archive
  760. may be small.  (One user reports that dumping a `core' file of over 400
  761. megabytes, but with only about 3 megabytes of actual data, took about 9
  762. minutes on a Sun Sparstation ELC, with full CPU utilisation.)
  763.    This reading is required in all cases and is not related to the fact
  764. the `--sparse' (`-S') option is used or not, so by merely *not* using
  765. the option, you are not saving time(1).
  766.    Programs like `dump' do not have to read the entire file; by
  767. examining the file system directly, they can determine in advance
  768. exactly where the holes are and thus avoid reading through them.  The
  769. only data it need read are the actual allocated data blocks.  GNU `tar'
  770. uses a more portable and straightforward archiving approach, it would
  771. be fairly difficult that it does otherwise.  Elizabeth Zwicky writes to
  772. `comp.unix.internals', on 1990-12-10:
  773.      What I did say is that you cannot tell the difference between a
  774.      hole and an equivalent number of nulls without reading raw blocks.
  775.      `st_blocks' at best tells you how many holes there are; it
  776.      doesn't tell you *where*.  Just as programs may, conceivably, care
  777.      what `st_blocks' is (care to name one that does?), they may also
  778.      care where the holes are (I have no examples of this one either,
  779.      but it's equally imaginable).
  780.      I conclude from this that good archivers are not portable.  One can
  781.      arguably conclude that if you want a portable program, you can in
  782.      good conscience restore files with as many holes as possible,
  783.      since you can't get it right.
  784.    ---------- Footnotes ----------
  785.    (1)  Well!  We should say the whole truth, here.  When `--sparse'
  786. (`-S') is selected while creating an archive, the current `tar'
  787. algorithm requires sparse files to be read twice, not once.  We hope to
  788. develop a new archive format for saving sparse files in which one pass
  789. will be sufficient.
  790.