Movatterモバイル変換


[0]ホーム

URL:


<<<PreviousHomeNext >>>


NAME

pax - portable archive interchange

SYNOPSIS

pax[-dv] [-c|-n] [-H|-L] [-ooptions][-farchive] [-sreplstr]...
      
[pattern...]

pax -r
[-c|-n] [-dikuv] [-H|-L] [-farchive][-ooptions]...[-pstring]...
      
[-sreplstr]...[pattern...]

pax -w
[-dituvX] [-H|-L] [-bblocksize] [[-a][-farchive]] [-ooptions]...
      
[-sreplstr]...[-xformat] [file...]

pax -r -w
[-diklntuvX] [-H|-L] [-ooptions]...[-pstring]...
      
[-sreplstr]...[file...]directory

DESCRIPTION

Thepax utility shall read, write, and write lists of the members of archive files and copy directory hierarchies. Avariety of archive formats shall be supported; see the-xformat option.

The action to be taken depends on the presence of the-r and-w options. The four combinations of-r and-w are referred to as the four modes of operation:list,read,write, andcopy modes,corresponding respectively to the four forms shown in the SYNOPSIS section.

list
Inlist mode (when neither-r nor-w are specified),pax shall write the names of the members ofthe archive file read from the standard input, with pathnames matching the specified patterns, to standard output. If a named fileis of type directory, the file hierarchy rooted at that file shall be listed as well.
read
Inread mode (when-r is specified, but-w is not),pax shall extract the members of the archivefile read from the standard input, with pathnames matching the specified patterns. If an extracted file is of type directory, thefile hierarchy rooted at that file shall be extracted as well. The extracted files shall be created performing pathname resolutionwith the directory in whichpax was invoked as the current working directory.

If an attempt is made to extract a directory when the directory already exists, this shall not be considered an error. If anattempt is made to extract a FIFO when the FIFO already exists, this shall not be considered an error.

The ownership, access, and modification times, and file mode of the restored files are discussed under the-p option.

write
Inwrite mode (when-w is specified, but-r is not),pax shall write the contents of thefile operands to the standard output in an archive format. If nofile operands are specified, a list of files tocopy, one per line, shall be read from the standard input and each entry in this list shall be processed as if it had been afile operand on the command line. A file of type directory shall include all of the files in the file hierarchy rooted atthe file.
copy
Incopy mode (when both-r and-w are specified),pax shall copy thefile operands to thedestination directory.

If nofile operands are specified, a list of files to copy, one per line, shall be read from the standard input. A fileof type directory shall include all of the files in the file hierarchy rooted at the file.

The effect of thecopy shall be as if the copied files were written to apax format archive file and thensubsequently extracted, except that copying of sockets may be supported even if archiving them in write mode is not supported, andthat there may be hard links between the original and the copied files. If the destination directory is a subdirectory of one ofthe files to be copied, the results are unspecified. If the destination directory is a file of a type not defined by the SystemInterfaces volume of POSIX.1-2017, the results are implementation-defined; otherwise, it shall be an error for the file named bythedirectory operand not to exist, not be writable by the user, or not be a file of type directory.

Inread orcopy modes, if intermediate directories are necessary to extract an archive member,pax shallperform actions equivalent to themkdir() function defined in the System Interfacesvolume of POSIX.1-2017, called with the following arguments:

If any specifiedpattern orfile operands are not matched by at least one file or archive member,pax shallwrite a diagnostic message to standard error for each one that did not match and exit with a non-zero exit status.

The archive formats described in the EXTENDED DESCRIPTION section shall be automatically detected on input. The default outputarchive format shall be implementation-defined.

A single archive can span multiple files. Thepax utility shall determine, in an implementation-defined manner, what fileto read or write as the next file.

If the selected archive format supports the specification of linked files, it shall be an error if these files cannot be linkedwhen the archive is extracted. For archive formats that do not store file contents with each name that causes a hard link, if thefile that contains the data is not extracted during thispax session, either the data shall be restored from the originalfile, or a diagnostic message shall be displayed with the name of a file that can be used to extract the data. In traversingdirectories,pax shall detect infinite loops; that is, entering a previously visited directory that is an ancestor of thelast file visited. When it detects an infinite loop,pax shall write a diagnostic message to standard error and shallterminate.

OPTIONS

Thepax utility shall conform to XBDUtility Syntax Guidelines, except that the order of presentation of the-o,-p, and-s options is significant.

The following options shall be supported:

-r
Read an archive file from standard input.
-w
Write files to the standard output in the specified archive format.
-a
Append files to the end of the archive. It is implementation-defined which devices on the system support appending. Additionalfile formats unspecified by this volume of POSIX.1-2017 may impose restrictions on appending.
-b blocksize
Block the output at a positive decimal integer number of bytes per write to the archive file. Devices and archive formats mayimpose restrictions on blocking. Blocking shall be automatically determined on input. Conforming applications shall not specify ablocksize value larger than 32256. Default blocking when creating archives depends on the archive format. (See the-xoption below.)
-c
Match all file or archive members except those specified by thepattern orfile operands.
-d
Cause files of type directory being copied or archived or archive members of type directory being extracted or listed to matchonly the file or archive member itself and not the file hierarchy rooted at the file.
-f archive
Specify the pathname of the input or output archive, overriding the default standard input (inlist orreadmodes) or standard output (write mode).
-H
If a symbolic link referencing a file of type directory is specified on the command line,pax shall archive the filehierarchy rooted in the file referenced by the link, using the name of the link as the root of the file hierarchy. Otherwise, if asymbolic link referencing a file of any other file type whichpax can normally archive is specified on the command line,thenpax shall archive the file referenced by the link, using the name of the link. The default behavior, when neither-H or-L are specified, shall be to archive the symbolic link itself.
-i
Interactively rename files or archive members. For each archive member matching apattern operand or file matching afile operand, a prompt shall be written to the file/dev/tty. The prompt shall contain the name of the file orarchive member, but the format is otherwise unspecified. A line shall then be read from/dev/tty. If this line is blank, thefile or archive member shall be skipped. If this line consists of a single period, the file or archive member shall be processedwith no modification to its name. Otherwise, its name shall be replaced with the contents of the line. Thepax utility shallimmediately exit with a non-zero exit status if end-of-file is encountered when reading a response or if/dev/tty cannot beopened for reading and writing.

The results of extracting a hard link to a file that has been renamed during extraction are unspecified.

-k
Prevent the overwriting of existing files.
-l
(The letter ell.) Incopy mode, hard links shall be made between the source and destination file hierarchies wheneverpossible. If specified in conjunction with-H or-L, when a symbolic link is encountered, the hard link created inthe destination file hierarchy shall be to the file referenced by the symbolic link. If specified when neither-H nor-L is specified, when a symbolic link is encountered, the implementation shall create a hard link to the symbolic link inthe source file hierarchy or copy the symbolic link to the destination.
-L
If a symbolic link referencing a file of type directory is specified on the command line or encountered during the traversal ofa file hierarchy,pax shall archive the file hierarchy rooted in the file referenced by the link, using the name of the linkas the root of the file hierarchy. Otherwise, if a symbolic link referencing a file of any other file type whichpax cannormally archive is specified on the command line or encountered during the traversal of a file hierarchy,pax shall archivethe file referenced by the link, using the name of the link. The default behavior, when neither-H or-L arespecified, shall be to archive the symbolic link itself.
-n
Select the first archive member that matches eachpattern operand. No more than one archive member shall be matched foreach pattern (although members of type directory shall still match the file hierarchy rooted at that file).
-o options
Provide information to the implementation to modify the algorithm for extracting or writing files. The value ofoptionsshall consist of one or more <comma>-separated keywords of the form:
keyword[[:]=value][,keyword[[:]=value], ...]

Some keywords apply only to certain file formats, as indicated with each description. Use of keywords that are inapplicable tothe file format being processed produces undefined results.

Keywords in theoptions argument shall be a string that would be a valid portable filename as described in XBDPortable Filename Character Set.

Note:
Keywords are not expected to be filenames, merely to follow the same character composition rules as portable filenames.

Keywords can be preceded with white space. Thevalue field shall consist of zero or more characters; withinvalue,the application shall precede any literal <comma> with a <backslash>, which shall be ignored, but preserves the<comma> as part ofvalue. A <comma> as the final character, or a <comma> followed solely by white space asthe final characters, inoptions shall be ignored. Multiple-o options can be specified; if keywords given to thesemultiple-o options conflict, the keywords and values appearing later in command line sequence shall take precedence and theearlier shall be silently ignored. The following keyword values ofoptions shall be supported for the file formats asindicated:

delete=pattern
(Applicable only to the-xpax format.) When used inwrite orcopy mode,pax shall omit fromextended header records that it produces any keywords matching the string pattern. When used inread orlist mode,pax shall ignore any keywords matching the string pattern in the extended header records. In both cases, matching shall beperformed using the pattern matching notation described inPatterns Matchinga Single Character andPatterns Matching Multiple Characters. For example:
-odelete=security.*

would suppress security-related information. Seepax Extended Header for extended header recordkeyword usage.

When multiple-odelete=pattern options are specified, the patterns shall be additive; all keywords matching thespecified string patterns shall be omitted from extended header records thatpax produces.

exthdr.name=string
(Applicable only to the-xpax format.) This keyword allows user control over the name that is written into theustar header blocks for the extended header produced under the circumstances described inpaxHeader Block. The name shall be the contents ofstring, after the following character substitutions have been made:

string

 

Includes:

Replaced by:

%d

The directory name of the file, equivalent to the result of thedirname utility on the translated pathname.

%f

The filename of the file, equivalent to the result of thebasenameutility on the translated pathname.

%p

The process ID of thepax process.

%%

A'%' character.

Any other'%' characters instring produce undefined results.

If no-oexthdr.name=string is specified,pax shall use the following default value:

%d/PaxHeaders.%p/%f
globexthdr.name=string
(Applicable only to the-xpax format.) When used inwrite orcopy mode with the appropriate options,pax shall create global extended header records withustar header blocks that will be treated as regular files byprevious versions ofpax. This keyword allows user control over the name that is written into theustar header blocksfor global extended header records. The name shall be the contents of string, after the following character substitutions have beenmade:

string

 

Includes:

Replaced by:

%n

An integer that represents the sequence number of the global extended header record in the archive, starting at1.

%p

The process ID of thepax process.

%%

A'%' character.

Any other'%' characters instring produce undefined results.

If no-oglobexthdr.name=string is specified,pax shall use the following default value:

$TMPDIR/GlobalHead.%p.%n

where $TMPDIR represents the value of theTMPDIR environment variable. IfTMPDIR is not set,paxshall use/tmp.

invalid=action
(Applicable only to the-xpax format.) This keyword allows user control over the actionpax takes uponencountering values in an extended header record that, inread orcopy mode, are invalid in the destination hierarchyor, inlist mode, cannot be written in the codeset and current locale of the implementation. The following are invalidvalues that shall be recognized bypax:
  • Inread orcopy mode, a filename or link name that contains character encodings invalid in the destinationhierarchy. (For example, the name may contain embedded NULs.)

  • Inread orcopy mode, a filename or link name that is longer than the maximum allowed in the destination hierarchy(for either a pathname component or the entire pathname).

  • Inlist mode, any character string value (filename, link name, user name, and so on) that cannot be written in thecodeset and current locale of the implementation.

The following mutually-exclusive values of theaction argument are supported:

binary
Inwrite mode,pax shall generate ahdrcharset=BINARY extended header record for each file with afilename, link name, group name, owner name, or any other field in an extended header record that cannot be translated to the UTF-8codeset, allowing the archive to contain the files with unencoded extended header record values. Inread orcopymode,pax shall use the values specified in the header without translation, regardless of whether this may overwrite anexisting file with a valid name. Inlist mode,pax shall behave identically to thebypass action.
bypass
Inread orcopy mode,pax shall bypass the file, causing no change to the destination hierarchy. Inlist mode,pax shall write all requested valid values for the file, but its method for writing invalid values isunspecified.
rename
Inread orcopy mode,pax shall act as if the-i option were in effect for each file with invalidfilename or link name values, allowing the user to provide a replacement name interactively. Inlist mode,pax shallbehave identically to thebypass action.
UTF-8
When used inread,copy, orlist mode and a filename, link name, owner name, or any other field in anextended header record cannot be translated from thepax UTF-8 codeset format to the codeset and current locale of theimplementation,pax shall use the actual UTF-8 encoding for the name. If ahdrcharset extended header record is ineffect for this file, the character set specified by that record shall be used instead of UTF-8. If ahdrcharset=BINARY extended header record is in effect for this file, no translation shall be performed.
write
Inread orcopy mode,pax shall write the file, translating the name, regardless of whether this mayoverwrite an existing file with a valid name. Inlist mode,pax shall behave identically to thebypassaction.

If no-oinvalid=option is specified,pax shall act as if-oinvalid=bypass were specified.Any overwriting of existing files that may be allowed by the-oinvalid= actions shall be subject to permission (-p) and modification time (-u) restrictions, and shall be suppressed if the-k option is also specified.

linkdata
(Applicable only to the-xpax format.) Inwrite mode,pax shall write the contents of a file to thearchive even when that file is merely a hard link to a file whose contents have already been written to the archive.
listopt=format
This keyword specifies the output format of the table of contents produced when the-v option is specified inlistmode. SeeList Mode Format Specifications. To avoid ambiguity, thelistopt=format shall bethe only or finalkeyword=value pair in a-o option-argument; all characters in the remainder of the option-argumentshall be considered part of the format string. When multiple-olistopt=format options are specified, the formatstrings shall be considered a single, concatenated string, evaluated in command line order.
times
(Applicable only to the-xpax format.) When used inwrite orcopy mode,pax shall includeatime andmtime extended header records for each file. Seepax Extended Header FileTimes.

In addition to these keywords, if the-xpax format is specified, any of the keywords and values defined inpax Extended Header, including implementation extensions, can be used in-o option-arguments,in either of two modes:

keyword=value
When used inwrite orcopy mode, these keyword/value pairs shall be included at the beginning of the archive astypeflagg global extended header records. When used inread orlist mode, these keyword/value pairsshall act as if they had been at the beginning of the archive astypeflagg global extended header records.
keyword:=value
When used inwrite orcopy mode, these keyword/value pairs shall be included as records at the beginning of atypeflagx extended header for each file. (This shall be equivalent to the <equals-sign> form except that itcreates notypeflagg global extended header records.) When used inread orlist mode, thesekeyword/value pairs shall act as if they were included as records at the end of each extended header; thus, they shall override anyglobal or file-specific extended header record keywords of the same names. For example, in the command:
pax -r -o "gname:=mygroup," <archive

the group name will be forced to a new value for all files read from the archive.

The precedence of-o keywords over various fields in the archive is described inpax ExtendedHeader Keyword Precedence. If the-odelete=pattern,-okeyword=value, or-okeyword:=value options are used to override or remove any extended header data needed to find files in anarchive (e.g.,-o delete=size for a file whose size cannot be represented in austar header or-o size=100for a file whose size is not 100 bytes), the behavior is undefined.

-p string
Specify one or more file characteristic options (privileges). Thestring option-argument shall be a string specifyingfile characteristics to be retained or discarded on extraction. The string shall consist of the specification charactersa,e,m,o, andp. Other implementation-defined characters can be included. Multiplecharacteristics can be concatenated within the same string and multiple-p options can be specified. The meaning of thespecification characters are as follows:
a
Do not preserve file access times.
e
Preserve the user ID, group ID, file mode bits (see XBDFile ModeBits), access time, modification time, and any other implementation-defined file characteristics.
m
Do not preserve file modification times.
o
Preserve the user ID and group ID.
p
Preserve the file mode bits. Other implementation-defined file mode attributes may be preserved.

In the preceding list, "preserve" indicates that an attribute stored in the archive shall be given to the extracted file,subject to the permissions of the invoking process. The access and modification times of the file shall be preserved unlessotherwise specified with the-p option or not stored in the archive. All attributes that are not preserved shall bedetermined as part of the normal file creation action (seeFile Read,Write, and Creation).

If neither thee nor theo specification character is specified, or the user ID and group ID are not preservedfor any reason,pax shall not set the S_ISUID and S_ISGID bits of the file mode.

If the preservation of any of these items fails for any reason,pax shall write a diagnostic message to standard error.Failure to preserve these items shall affect the final exit status, but shall not cause the extracted file to be deleted.

If file characteristic letters in any of thestring option-arguments are duplicated or conflict with each other, the onesgiven last shall take precedence. For example, if-peme is specified, file modification times are preserved.

-s replstr
Modify file or archive member names named bypattern orfile operands according to the substitution expressionreplstr, using the syntax of theed utility. The concepts of "address" and"line" are meaningless in the context of thepax utility, and shall not be supplied. The format shall be:
-s /old/new/[gp]

where as ined,old is a basic regular expression andnew can contain an<ampersand>,'\n' (wheren is a digit) back-references, or subexpression matching. Theold stringshall also be permitted to contain <newline> characters.

Any non-null character can be used as a delimiter ('/' shown here). Multiple-s expressions can be specified;the expressions shall be applied in the order specified, terminating with the first successful substitution. The optional trailing'g' is as defined in theed utility. The optional trailing'p' shallcause successful substitutions to be written to standard error. File or archive member names that substitute to the empty stringshall be ignored when reading and writing archives.

-t
When reading files from the file system, and if the user has the permissions required byutime() to do so, set the access time of each file read to the access time that it had beforebeing read bypax.
-u
Ignore files that are older (having a less recent file modification time) than a pre-existing file or archive member with thesame name. Inread mode, an archive member with the same name as a file in the file system shall be extracted if the archivemember is newer than the file. Inwrite mode, an archive file member with the same name as a file in the file system shallbe superseded if the file is newer than the archive member. If-a is also specified, this is accomplished by appending tothe archive; otherwise, it is unspecified whether this is accomplished by actual replacement in the archive or by appending to thearchive. Incopy mode, the file in the destination hierarchy shall be replaced by the file in the source hierarchy or by alink to the file in the source hierarchy if the file in the source hierarchy is newer.
-v
Inlist mode, produce a verbose table of contents (see the STDOUT section). Otherwise, write archive member pathnames tostandard error (see the STDERR section).
-x format
Specify the output archive format. Thepax utility shall support the following formats:
cpio
Thecpio interchange format; see the EXTENDED DESCRIPTION section. The defaultblocksize for this format forcharacter special archive files shall be 5120. Implementations shall support allblocksize values less than or equal to32256 that are multiples of 512.
pax
Thepax interchange format; see the EXTENDED DESCRIPTION section. The defaultblocksize for this format forcharacter special archive files shall be 5120. Implementations shall support allblocksize values less than or equal to32256 that are multiples of 512.
ustar
Thetar interchange format; see the EXTENDED DESCRIPTION section. The defaultblocksize for this format forcharacter special archive files shall be 10240. Implementations shall support allblocksize values less than or equal to32256 that are multiples of 512.

Implementation-defined formats shall specify a default block size as well as any other block sizes supported for characterspecial archive files.

Any attempt to append to an archive file in a format different from the existing archive format shall causepax to exitimmediately with a non-zero exit status.

-X
When traversing the file hierarchy specified by a pathname,pax shall not descend into directories that have a differentdevice ID (st_dev; see the System Interfaces volume of POSIX.1-2017,stat()).

Specifying more than one of the mutually-exclusive options-H and-L shall not be considered an error and the lastoption specified shall determine the behavior of the utility.

The options that operate on the names of files or archive members (-c,-i,-n,-s,-u, and-v) shall interact as follows. Inread mode, the archive members shall be selected based on the user-specifiedpattern operands as modified by the-c,-n, and-u options. Then, any-s and-i optionsshall modify, in that order, the names of the selected files. The-v option shall write names resulting from thesemodifications.

Inwrite mode, the files shall be selected based on the user-specified pathnames as modified by the-n and-u options. Then, any-s and-i options shall modify, in that order, the names of these selected files. The-v option shall write names resulting from these modifications.

If both the-u and-n options are specified,pax shall not consider a file selected unless it is newer thanthe file to which it is compared.

List Mode Format Specifications

Inlist mode with the-olistopt=format option, theformat argument shall be applied for eachselected file. Thepax utility shall append a <newline> to thelistopt output for each selected file. Theformat argument shall be used as theformat string described in XBDFile Format Notation, with the exceptions 1. through 6. defined in the EXTENDEDDESCRIPTION section ofprintf, plus the following exceptions:

7.
The sequence (keyword) can occur before a format conversion specifier. The conversion argument is defined by the valueofkeyword. The implementation shall support the following keywords:

For example, the sequence"%(charset)s" is the string value of the name of the character set in the extendedheader.

The result of the keyword conversion argument shall be the value from the applicable header field or extended header, withoutany trailing NULs.

All keyword values used as conversion arguments shall be translated from the UTF-8 encoding (or alternative encoding specifiedby anyhdrcharset extended header record) to the character set appropriate for the local file system, user database, and soon, as applicable.

8.
An additional conversion specifier character,T, shall be used to specify time formats. TheT conversionspecifier character can be preceded by the sequence (keyword=subformat), wheresubformat is a date format asdefined bydate operands. The defaultkeyword shall bemtime and thedefault subformat shall be:
%b %e %H:%M %Y
9.
An additional conversion specifier character,M, shall be used to specify the file mode string as defined inls Standard Output. If (keyword) is omitted, themode keyword shall be used. Forexample,%.1M writes the single character corresponding to the <entry type> field of thels-l command.
10.
An additional conversion specifier character,D, shall be used to specify the device for block or special files, ifapplicable, in an implementation-defined format. If not applicable, and (keyword) is specified, then this conversion shallbe equivalent to%(keyword)u. If not applicable, and (keyword) is omitted, then this conversionshall be equivalent to <space>.
11.
An additional conversion specifier character,F, shall be used to specify a pathname. TheF conversioncharacter can be preceded by a sequence of <comma>-separated keywords:
(keyword[,keyword]... )

The values for all the keywords that are non-null shall be concatenated together, each separated by a'/'. The defaultshall be (path) if the keywordpath is defined; otherwise, the default shall be (prefix,name).

12.
An additional conversion specifier character,L, shall be used to specify a symbolic link expansion. If the currentfile is a symbolic link, then%L shall expand to:
"%s -> %s", <value of keyword>, <contents of link>

Otherwise, the%L conversion specification shall be the equivalent of%F.

OPERANDS

The following operands shall be supported:

directory
The destination directory pathname forcopy mode.
file
A pathname of a file to be copied or archived.
pattern
A pattern matching one or more pathnames of archive members. A pattern must be given in the name-generating notation of thepattern matching notation inPattern Matching Notation, including thefilename expansion rules inPatterns Used for Filename Expansion.The default, if nopattern is specified, is to select all members in the archive.

STDIN

Inwrite mode, the standard input shall be used only if nofile operands are specified. It shall be a filecontaining a list of pathnames, each terminated by a <newline> character.

Inlist andread modes, if-f is not specified, the standard input shall be an archive file.

Otherwise, the standard input shall not be used.

INPUT FILES

The input file named by thearchive option-argument, or standard input when the archive is read from there, shall be afile formatted according to one of the specifications in the EXTENDED DESCRIPTION section or some other implementation-definedformat.

The file/dev/tty shall be used to write prompts and read responses.

ENVIRONMENT VARIABLES

The following environment variables shall affect the execution ofpax:

LANG
Provide a default value for the internationalization variables that are unset or null. (See XBDInternationalization Variables the precedence of internationalization variablesused to determine the values of locale categories.)
LC_ALL
If set to a non-empty string value, override the values of all the other internationalization variables.
LC_COLLATE
Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements used in the patternmatching expressions for thepattern operand, the basic regular expression for the-s option, and the extendedregular expression defined for theyesexpr locale keyword in theLC_MESSAGES category.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments and input files), the behavior of character classes used in the extended regularexpression defined for theyesexpr locale keyword in theLC_MESSAGES category, and pattern matching.
LC_MESSAGES
Determine the locale used to process affirmative responses, and the locale used to affect the format and contents of diagnosticmessages and prompts written to standard error.
LC_TIME
Determine the format and contents of date and time strings when the-v option is specified.
NLSPATH
[XSI][Option Start]Determine the location of message catalogs for the processing ofLC_MESSAGES.[Option End]
TMPDIR
Determine the pathname that provides part of the default global extended header record file, as described for the-oglobexthdr= keyword in the OPTIONS section.
TZ
Determine the timezone used to calculate date and time strings when the-v option is specified. IfTZ is unset ornull, an unspecified default timezone shall be used.

ASYNCHRONOUS EVENTS

Default.

STDOUT

Inwrite mode, if-f is not specified, the standard output shall be the archive formatted according to one of thespecifications in the EXTENDED DESCRIPTION section, or some other implementation-defined format (see-xformat).

Inlist mode, when the-olistopt=format has been specified, the selected archive members shall bewritten to standard output using the format described underList Mode Format Specifications. Inlist mode without the-olistopt=format option, the table of contents of the selected archive membersshall be written to standard output using the following format:

"%s\n", <pathname>

If the-v option is specified inlist mode, the table of contents of the selected archive members shall be writtento standard output using the following formats.

For pathnames representing hard links to previous members of the archive:

"%s==%s\n", <ls-llisting>, <linkname>

For all other pathnames:

"%s\n", <ls-llisting>

where <ls  -l listing> shall be the format specified by thels utility with the-l option. When writing pathnames in this format, it is unspecifiedwhat is written for fields for which the underlying archive format does not have the correct information, although the correctnumber of <blank>-separated fields shall be written.

Inlist mode, standard output shall not be buffered more than a pathname (plus any associated information and a<newline> terminator) at a time.

STDERR

If-v is specified inread,write, orcopy modes,pax shall write the pathnames it processesto the standard error output using the following format:

"%s\n", <pathname>

These pathnames shall be written as soon as processing is begun on the file or archive member, and shall be flushed to standarderror. The trailing <newline>, which shall not be buffered, is written when the file has been read or written.

If the-s option is specified, and the replacement string has a trailing'p', substitutions shall be written tostandard error in the following format:

"%s>>%s\n", <original pathname>, <new pathname>

In all operating modes ofpax, optional messages of unspecified format concerning the input archive format and volumenumber, the number of files, blocks, volumes, and media parts as well as other diagnostic messages may be written to standarderror.

In all formats, for both standard output and standard error, it is unspecified how non-printable characters in pathnames or linknames are written.

When using the-xpax archive format, if a filename, link name, group name, owner name, or any other field in anextended header record cannot be translated between the codeset in use for that extended header record and the character set of thecurrent locale,pax shall write a diagnostic message to standard error, shall process the file as described for the-oinvalid= option, and then shall continue processing with the next file.

OUTPUT FILES

Inread mode, the extracted output files shall be of the archived file type. Incopy mode, the copied output filesshall be the type of the file being copied. In either mode, existing files in the destination hierarchy shall be overwritten onlywhen all permission (-p), modification time (-u), and invalid-value (-oinvalid=) tests allowit.

Inwrite mode, the output file named by the-f option-argument shall be a file formatted according to one of thespecifications in the EXTENDED DESCRIPTION section, or some other implementation-defined format.

EXTENDED DESCRIPTION

pax Interchange Format

Apax archive tape or file produced in the-xpax format shall contain a series of blocks. The physicallayout of the archive shall be identical to theustar format described inustar InterchangeFormat. Each file archived shall be represented by the following sequence:

At the end of the archive file there shall be two 512-byte blocks filled with binary zeros, interpreted as an end-of-archiveindicator.

A schematic of an example archive with global extended header records and two actual files is shown inpaxFormat Archive Example. In the example, the second file in the archive has no extended header preceding it, presumably becauseit has no need for extended attributes.

Figure: pax Format Archive Example
pax Header Block

Thepax header block shall be identical to theustar header block described inustarInterchange Format, except that two additionaltypeflag values are defined:

x
Represents extended header records for the following file in the archive (which shall have its ownustar header block).The format of these extended header records shall be as described inpax Extended Header.
g
Represents global extended header records for the following files in the archive. The format of these extended header recordsshall be as described inpax Extended Header. Each value shall affect all subsequent files that donot override that value in their own extended header record and until another global extended header record is reached thatprovides another value for the same field. Thetypeflagg global headers should not be used with interchange mediathat could suffer partial data loss in transporting the archive.

For both of these types, thesize field shall be the size of the extended header records in octets. The other fields inthe header block are not meaningful to this version of thepax utility. However, if this archive is read by apaxutility conforming to the ISO POSIX-2:1993 standard, the header block fields are used to create a regular file that containsthe extended header records as data. Therefore, header block field values should be selected to provide reasonable file access tothis regular file.

A further difference from theustar header block is that data blocks for files oftypeflag 1 (the digit one) (hardlink) may be included, which means that the size field may be greater than zero. Archives created bypax-olinkdata shall include these data blocks with the hard links.

pax Extended Header

Apax extended header contains values that are inappropriate for theustar header block because of limitations inthat format: fields requiring a character encoding other than that described in the ISO/IEC 646:1991 standard, fieldsrepresenting file attributes not described in theustar header, and fields whose format or length do not fit therequirements of theustar header. The values in an extended header add attributes to the following file (or files; see thedescription of thetypeflagg header block) or override values in the following header block(s), as indicated in thefollowing list of keywords.

An extended header shall consist of one or more records, each constructed as follows:

"%d %s=%s\n", <length>, <keyword>, <value>

The extended header records shall be encoded according to the ISO/IEC 10646-1:2000 standard UTF-8 encoding. The<length> field, <blank>, <equals-sign>, and <newline> shown shall be limited to the portablecharacter set, as encoded in UTF-8. The <keyword> fields can be any UTF-8 characters. The <length> fieldshall be the decimal length of the extended header record in octets, including the trailing <newline>. If there is ahdrcharset extended header in effect for a file, thevalue field for anygname,linkpath,path,anduname extended header records shall be encoded using the character set specified by thehdrcharset extendedheader record; otherwise, thevalue field shall be encoded using UTF-8. Thevalue field for all other keywordsspecified by POSIX.1-2017 shall be encoded using UTF-8.

The <keyword> field shall be one of the entries from the following list or a keyword provided as an implementationextension. Keywords consisting entirely of lowercase letters, digits, and periods are reserved for future standardization. Akeyword shall not include an <equals-sign>. (In the following list, the notations "file(s)" or "block(s)" is used toacknowledge that a keyword affects the following single file after atypeflagx extended header, but possiblymultiple files aftertypeflagg. Any requirements in the list forpax to include a record when inwriteorcopy mode shall apply only when such a record has not already been provided through the use of the-o option. Whenused incopy mode,pax shall behave as if an archive had been created with applicable extended header records andthen extracted.)

atime
The file access time for the following file(s), equivalent to the value of thest_atime member of thestatstructure for a file, as described by thestat() function. The access time shall berestored if the process has appropriate privileges required to do so. The format of the <value> shall be as describedinpax Extended Header File Times.
charset
The name of the character set used to encode the data in the following file(s). The entries in the following table are definedto refer to known standards; additional names may be agreed on between the originator and recipient.

<value>

Formal Standard

ISO-IR6461990

ISO/IEC 646:1990

ISO-IR885911998

ISO/IEC 8859-1:1998

ISO-IR885921999

ISO/IEC 8859-2:1999

ISO-IR885931999

ISO/IEC 8859-3:1999

ISO-IR885941998

ISO/IEC 8859-4:1998

ISO-IR885951999

ISO/IEC 8859-5:1999

ISO-IR885961999

ISO/IEC 8859-6:1999

ISO-IR885971987

ISO/IEC 8859-7:1987

ISO-IR885981999

ISO/IEC 8859-8:1999

ISO-IR885991999

ISO/IEC 8859-9:1999

ISO-IR8859101998

ISO/IEC 8859-10:1998

ISO-IR8859131998

ISO/IEC 8859-13:1998

ISO-IR8859141998

ISO/IEC 8859-14:1998

ISO-IR8859151999

ISO/IEC 8859-15:1999

ISO-IR106462000

ISO/IEC 10646:2000

ISO-IR106462000UTF-8

ISO/IEC 10646, UTF-8 encoding

BINARY

None.

The encoding is included in an extended header for information only; whenpax is used as described in POSIX.1-2017, itshall not translate the file data into any other encoding. TheBINARY entry indicates unencoded binary data.

When used inwrite orcopy mode, it is implementation-defined whetherpax includes acharsetextended header record for a file.

comment
A series of characters used as a comment. All characters in the <value> field shall be ignored bypax.
gid
The group ID of the group that owns the file, expressed as a decimal number using digits from the ISO/IEC 646:1991standard. This record shall override thegid field in the following header block(s). When used inwrite orcopy mode,pax shall include agid extended header record for each file whose group ID is greater than 2097151(octal 7777777).
gname
The group of the file(s), formatted as a group name in the group database. This record shall override thegid andgname fields in the following header block(s), and anygid extended header record. When used inread,copy, orlist mode,pax shall translate the name from the encoding in the header record to the character setappropriate for the group database on the receiving system. If any of the characters cannot be translated, and if neither the-oinvalid=UTF-8 option nor the-oinvalid=binary option is specified, the results areimplementation-defined. When used inwrite orcopy mode,pax shall include agname extended headerrecord for each file whose group name cannot be represented entirely with the letters and digits of the portable characterset.
hdrcharset
The name of the character set used to encode the value field of thegname,linkpath,path, andunamepax extended header records. The entries in the following table are defined to refer to known standards;additional names may be agreed between the originator and the recipient.

<value>

Formal Standard

ISO-IR106462000UTF-8

ISO/IEC 10646, UTF-8 encoding

BINARY

None.

If nohdrcharset extended header record is specified, the default character set used to encode all values in extendedheader records shall be the ISO/IEC 10646-1:2000 standard UTF-8 encoding.

TheBINARY entry indicates that all values recorded in extended headers for affected files are unencoded binary data fromthe underlying system.

linkpath
The pathname of a link being created to another file, of any type, previously archived. This record shall override thelinkname field in the followingustar header block(s). The followingustar header block shall determine thetype of link created. Iftypeflag of the following header block is 1, it shall be a hard link. Iftypeflag is 2, itshall be a symbolic link and thelinkpath value shall be the contents of the symbolic link. Thepax utility shalltranslate the name of the link (contents of the symbolic link) from the encoding in the header to the character set appropriate forthe local file system. When used inwrite orcopy mode,pax shall include alinkpath extended headerrecord for each link whose pathname cannot be represented entirely with the members of the portable character set other thanNUL.
mtime
The file modification time of the following file(s), equivalent to the value of thest_mtime member of thestatstructure for a file, as described in thestat() function. This record shall overridethemtime field in the following header block(s). The modification time shall be restored if the process has appropriateprivileges required to do so. The format of the <value> shall be as described inpaxExtended Header File Times.
path
The pathname of the following file(s). This record shall override thename andprefix fields in the followingheader block(s). Thepax utility shall translate the pathname of the file from the encoding in the header to the characterset appropriate for the local file system.

When used inwrite orcopy mode,pax shall include apath extended header record for each file whosepathname cannot be represented entirely with the members of the portable character set other than NUL.

realtime.any
The keywords prefixed by "realtime." are reserved for future standardization.
security.any
The keywords prefixed by "security." are reserved for future standardization.
size
The size of the file in octets, expressed as a decimal number using digits from the ISO/IEC 646:1991 standard. This recordshall override thesize field in the following header block(s). When used inwrite orcopy mode,paxshall include asize extended header record for each file with a size value greater than 8589934591 (octal77777777777).
uid
The user ID of the file owner, expressed as a decimal number using digits from the ISO/IEC 646:1991 standard. This recordshall override theuid field in the following header block(s). When used inwrite orcopy mode,paxshall include auid extended header record for each file whose owner ID is greater than 2097151 (octal 7777777).
uname
The owner of the following file(s), formatted as a user name in the user database. This record shall override theuidanduname fields in the following header block(s), and anyuid extended header record. When used inread,copy, orlist mode,pax shall translate the name from the encoding in the header record to the character setappropriate for the user database on the receiving system. If any of the characters cannot be translated, and if neither the-oinvalid=UTF-8 option nor the-oinvalid=binary option is specified, the results areimplementation-defined. When used inwrite orcopy mode,pax shall include auname extended headerrecord for each file whose user name cannot be represented entirely with the letters and digits of the portable character set.

If the <value> field is zero length, it shall delete any header block field, previously entered extended headervalue, or global extended header value of the same name.

If a keyword in an extended header record (or in a-o option-argument) overrides or deletes a corresponding field in theustar header block,pax shall ignore the contents of that header block field.

Unlike theustar header block fields, NULs shall not delimit <value>s; all characters within the<value> field shall be considered data for the field. None of the length limitations of theustar header blockfields inustar Header Block shall apply to the extended header records.

pax Extended Header Keyword Precedence

This section describes the precedence in which the various header records and fields and command line options are selected toapply to a file in the archive. Whenpax is used inread orlist modes, it shall determine a file attribute inthe following sequence:

  1. If-odelete=keyword-prefix is used, the affected attributes shall be determined from step 7., if applicable, orignored otherwise.

  2. If-okeyword:= is used, the affected attributes shall be ignored.

  3. If-okeyword:=value is used, the affected attribute shall be assigned the value.

  4. If there is atypeflagx extended header record, the affected attribute shall be assigned the<value>. When extended header records conflict, the last one given in the header shall take precedence.

  5. If-okeyword=value is used, the affected attribute shall be assigned the value.

  6. If there is atypeflagg global extended header record, the affected attribute shall be assigned the<value>. When global extended header records conflict, the last one given in the global header shall takeprecedence.

  7. Otherwise, the attribute shall be determined from theustar header block.

pax Extended Header File Times

Thepax utility shall write anmtime record for each file inwrite orcopy modes if the file'smodification time cannot be represented exactly in theustar header logical record described inustar Interchange Format. This can occur if the time is out ofustar range, or if the file system ofthe underlying implementation supports non-integer time granularities and the time is not an integer. All of these time recordsshall be formatted as a decimal representation of the time in seconds since the Epoch. If a <period> ('.' ) decimalpoint character is present, the digits to the right of the point shall represent the units of a subsecond timing granularity, wherethe first digit is tenths of a second and each subsequent digit is a tenth of the previous digit. Inread orcopymode, thepax utility shall truncate the time of a file to the greatest value that is not greater than the input header filetime. Inwrite orcopy mode, thepax utility shall output a time exactly if it can be represented exactly as adecimal number, and otherwise shall generate only enough digits so that the same time shall be recovered if the file is extractedon a system whose underlying implementation supports the same time granularity.

ustar Interchange Format

Austar archive tape or file shall contain a series of logical records. Each logical record shall be a fixed-size logicalrecord of 512 octets (see below). Although this format may be thought of as being stored on 9-track industry-standard 12.7 mm (0.5in) magnetic tape, other types of transportable media are not excluded. Each file archived shall be represented by a header logicalrecord that describes the file, followed by zero or more logical records that give the contents of the file. At the end of thearchive file there shall be two 512-octet logical records filled with binary zeros, interpreted as an end-of-archive indicator.

The logical records may be grouped for physical I/O operations, as described under the-bblocksize and-xustar options. Each group of logical records may be written with a single operation equivalent to thewrite() function. On magnetic tape, the result of this write shall be a single tape physicalblock. The last physical block shall always be the full size, so logical records after the two zero logical records may containundefined data.

The header logical record shall be structured as shown in the following table. All lengths and offsets are in decimal.

Table: ustar Header Block

Field Name

Octet Offset

Length (in Octets)

name

0

100

mode

100

8

uid

108

8

gid

116

8

size

124

12

mtime

136

12

chksum

148

8

typeflag

156

1

linkname

157

100

magic

257

6

version

263

2

uname

265

32

gname

297

32

devmajor

329

8

devminor

337

8

prefix

345

155

All characters in the header logical record shall be represented in the coded character set of the ISO/IEC 646:1991standard. For maximum portability between implementations, names should be selected from characters represented by the portablefilename character set as octets with the most significant bit zero. If an implementation supports the use of characters outside of<slash> and the portable filename character set in names for files, users, and groups, one or more implementation-definedencodings of these characters shall be provided for interchange purposes.

However, thepax utility shall never create filenames on the local system that cannot be accessed via the proceduresdescribed in POSIX.1-2017. If a filename is found on the medium that would create an invalid filename, it is implementation-definedwhether the data from the file is stored on the file hierarchy and under what name it is stored. Thepax utility may chooseto ignore these files as long as it produces an error indicating that the file is being ignored.

Each field within the header logical record is contiguous; that is, there is no padding used. Each character on the archivemedium shall be stored contiguously.

The fieldsmagic,uname, andgname are character strings each terminated by a NUL character. The fieldsname,linkname, andprefix are NUL-terminated character strings except when all characters in the arraycontain non-NUL characters including the last character. Theversion field is two octets containing the characters"00" (zero-zero). Thetypeflag contains a single character. All other fields are leading zero-filled octal numbersusing digits from the ISO/IEC 646:1991 standard IRV. Each numeric field is terminated by one or more <space> or NULcharacters.

Thename and theprefix fields shall produce the pathname of the file. A new pathname shall be formed, ifprefix is not an empty string (its first character is not NUL), by concatenatingprefix (up to the first NULcharacter), a <slash> character, andname; otherwise,name is used alone. In either case,name isterminated at the first NUL character. Ifprefix begins with a NUL character, it shall be ignored. In this manner, pathnamesof at most 256 characters can be supported. If a pathname does not fit in the space provided,pax shall notify the user ofthe error, and shall not store any part of the file-header or data-on the medium.

Thelinkname field, described below, shall not use theprefix to produce a pathname. As such, alinkname islimited to 100 characters. If the name does not fit in the space provided,pax shall notify the user of the error, and shallnot attempt to store the link on the medium.

Themode field provides 12 bits encoded in the ISO/IEC 646:1991 standard octal digit representation. The encodedbits shall represent the following values:

Table: ustarmode Field

Bit Value

POSIX.1-2017 Bit

Description

04000

S_ISUID

Set UID on execution.

02000

S_ISGID

Set GID on execution.

01000

<reserved>

Reserved for future standardization.

00400

S_IRUSR

Read permission for file owner class.

00200

S_IWUSR

Write permission for file owner class.

00100

S_IXUSR

Execute/search permission for file owner class.

00040

S_IRGRP

Read permission for file group class.

00020

S_IWGRP

Write permission for file group class.

00010

S_IXGRP

Execute/search permission for file group class.

00004

S_IROTH

Read permission for file other class.

00002

S_IWOTH

Write permission for file other class.

00001

S_IXOTH

Execute/search permission for file other class.

When appropriate privileges are required to set one of these mode bits, and the user restoring the files from the archive doesnot have appropriate privileges, the mode bits for which the user does not have appropriate privileges shall be ignored. Some ofthe mode bits in the archive format are not mentioned elsewhere in this volume of POSIX.1-2017. If the implementation does notsupport those bits, they may be ignored.

Theuid andgid fields are the user and group ID of the owner and group of the file, respectively.

Thesize field is the size of the file in octets. If thetypeflag field is set to specify a file to be of type 1(a link) or 2 (a symbolic link), thesize field shall be specified as zero. If thetypeflag field is set to specify afile of type 5 (directory), thesize field shall be interpreted as described under the definition of that record type. Nodata logical records are stored for types 1, 2, or 5. If thetypeflag field is set to 3 (character special file), 4 (blockspecial file), or 6 (FIFO), the meaning of thesize field is unspecified by this volume of POSIX.1-2017, and no data logicalrecords shall be stored on the medium. Additionally, for type 6, thesize field shall be ignored when reading. If thetypeflag field is set to any other value, the number of logical records written following the header shall be (size+511)/512, ignoring any fraction in the result of the division.

Themtime field shall be the modification time of the file at the time it was archived. It is the ISO/IEC 646:1991standard representation of the octal value of the modification time obtained from thestat() function.

Thechksum field shall be the ISO/IEC 646:1991 standard IRV representation of the octal value of the simple sum ofall octets in the header logical record. Each octet in the header shall be treated as an unsigned value. These values shall beadded to an unsigned integer, initialized to zero, the precision of which is not less than 17 bits. When calculating the checksum,thechksum field is treated as if it were all <space> characters.

Thetypeflag field specifies the type of file archived. If a particular implementation does not recognize the type, orthe user does not have appropriate privileges to create that type, the file shall be extracted as if it were a regular file if thefile type is defined to have a meaning for thesize field that could cause data logical records to be written on the medium(see the previous description forsize). If conversion to a regular file occurs, thepax utility shall produce anerror indicating that the conversion took place. All of thetypeflag fields shall be coded in the ISO/IEC 646:1991standard IRV:

0
Represents a regular file. For backwards-compatibility, atypeflag value of binary zero ('\0' ) should berecognized as meaning a regular file when extracting files from the archive. Archives written with this version of the archive fileformat create regular files with atypeflag value of the ISO/IEC 646:1991 standard IRV'0'.
1
Represents a file linked to another file, of any type, previously archived. Such files are identified by having the same deviceand file serial numbers, and pathnames that refer to different directory entries. All such files shall be archived as linked files.The linked-to name is specified in thelinkname field with a NUL-character terminator if it is less than 100 octets inlength.
2
Represents a symbolic link. The contents of the symbolic link shall be stored in thelinkname field.
3,4
Represent character special files and block special files respectively. In this case thedevmajor anddevminorfields shall contain information defining the device, the format of which is unspecified by this volume of POSIX.1-2017.Implementations may map the device specifications to their own local specification or may ignore the entry.
5
Specifies a directory or subdirectory. On systems where disk allocation is performed on a directory basis, thesizefield shall contain the maximum number of octets (which may be rounded to the nearest disk block allocation unit) that thedirectory may hold. Asize field of zero indicates no such limiting. Systems that do not support limiting in this mannershould ignore thesize field.
6
Specifies a FIFO special file. Note that the archiving of a FIFO file archives the existence of this file and not itscontents.
7
Reserved to represent a file to which an implementation has associated some high-performance attribute. Implementations withoutsuch extensions should treat this file as a regular file (type 0).
A-Z
The letters'A' to'Z', inclusive, are reserved for custom implementations. All other values are reservedfor future versions of this standard.

It is unspecified whether files with pathnames that refer to the same directory entry are archived as linked files or asseparate files. If they are archived as linked files, this means that attempting to extract both pathnames from the resultingarchive will always cause an error (unless the-u option is used) because the link cannot be created.

It is unspecified whether files with the same device and file serial numbers being appended to an archive are treated as linkedfiles to members that were in the archive before the append.

Attempts to archive a socket shall produce a diagnostic message whenustar interchange format is used, but may be allowedwhenpax interchange format is used. Handling of other file types is implementation-defined.

Themagic field is the specification that this archive was output in this archive format. If this field containsustar (the five characters from the ISO/IEC 646:1991 standard IRV shown followed by NUL), theuname andgname fields shall contain the ISO/IEC 646:1991 standard IRV representation of the owner and group of the file,respectively (truncated to fit, if necessary). When the file is restored by a privileged, protection-preserving version of theutility, the user and group databases shall be scanned for these names. If found, the user and group IDs contained within thesefiles shall be used rather than the values contained within theuid andgid fields.

cpio Interchange Format

The octet-orientedcpio archive format shall be a series of entries, each comprising a header that describes the file,the name of the file, and then the contents of the file.

An archive may be recorded as a series of fixed-size blocks of octets. This blocking shall be used only to make physical I/Omore efficient. The last group of blocks shall always be at the full size.

For the octet-orientedcpio archive format, the individual entry information shall be in the order indicated anddescribed by the following table; see also the<cpio.h> header.

Table: Octet-Oriented cpio Archive Entry

Header Field Name

Length (in Octets)

Interpreted as

c_magic

6

Octal number

c_dev

6

Octal number

c_ino

6

Octal number

c_mode

6

Octal number

c_uid

6

Octal number

c_gid

6

Octal number

c_nlink

6

Octal number

c_rdev

6

Octal number

c_mtime

11

Octal number

c_namesize

6

Octal number

c_filesize

11

Octal number

Filename Field Name

Length

Interpreted as

c_name

c_namesize

Pathname string

File Data Field Name

Length

Interpreted as

c_filedata

c_filesize

Data

cpio Header

For each file in the archive, a header as defined previously shall be written. The information in the header fields is writtenas streams of the ISO/IEC 646:1991 standard characters interpreted as octal numbers. The octal numbers shall be extended tothe necessary length by appending the ISO/IEC 646:1991 standard IRV zeros at the most-significant-digit end of the number; theresult is written to the most-significant digit of the stream of octets first. The fields shall be interpreted as follows:

c_magic
Identify the archive as being a transportable archive by containing the identifying value"070707".
c_devc_ino
Contains values that uniquely identify the file within the archive (that is, no files contain the same pair ofc_dev andc_ino values unless they are links to the same file). The values shall be determined in an unspecified manner.
c_mode
Contains the file type and access permissions as defined in the following table.
Table: Values for cpio c_mode Field

File Permissions Name

Value

Indicates

C_IRUSR

000400

Read by owner

C_IWUSR

000200

Write by owner

C_IXUSR

000100

Execute by owner

C_IRGRP

000040

Read by group

C_IWGRP

000020

Write by group

C_IXGRP

000010

Execute by group

C_IROTH

000004

Read by others

C_IWOTH

000002

Write by others

C_IXOTH

000001

Execute by others

C_ISUID

004000

Setuid

C_ISGID

002000

Setgid

C_ISVTX

001000

Reserved

File Type Name

Value

Indicates

C_ISDIR

040000

Directory

C_ISFIFO

010000

FIFO

C_ISREG

0100000

Regular file

C_ISLNK

0120000

Symbolic link

C_ISBLK

060000

Block special file

C_ISCHR

020000

Character special file

C_ISSOCK

0140000

Socket

C_ISCTG

0110000

Reserved

Directories, FIFOs, symbolic links, and regular files shall be supported on a system conforming to this volume of POSIX.1-2017;additional values defined previously are reserved for compatibility with existing systems. Additional file types may be supported;however, such files should not be written to archives intended to be transported to other systems.

c_uid
Contains the user ID of the owner.
c_gid
Contains the group ID of the group.
c_nlink
Contains a number greater than or equal to the number of links in the archive referencing the file. If the-a option isused to append to acpio archive, then thepax utility need not account for the files in the existing part of thearchive when calculating thec_nlink values for the appended part of the archive, and need not alter thec_nlinkvalues in the existing part of the archive if additional files with the samec_dev andc_ino values are appended tothe archive.
c_rdev
Contains implementation-defined information for character or block special files.
c_mtime
Contains the latest time of modification of the file at the time the archive was created.
c_namesize
Contains the length of the pathname, including the terminating NUL character.
c_filesize
Contains the length in octets of the data section following the header structure.
cpio Filename

Thec_name field shall contain the pathname of the file. The length of this field in octets is the value ofc_namesize.

If a filename is found on the medium that would create an invalid pathname, it is implementation-defined whether the data fromthe file is stored on the file hierarchy and under what name it is stored.

All characters shall be represented in the ISO/IEC 646:1991 standard IRV. For maximum portability between implementations,names should be selected from characters represented by the portable filename character set as octets with the most significant bitzero. If an implementation supports the use of characters outside the portable filename character set in names for files, users,and groups, one or more implementation-defined encodings of these characters shall be provided for interchange purposes. However,thepax utility shall never create filenames on the local system that cannot be accessed via the procedures describedpreviously in this volume of POSIX.1-2017. If a filename is found on the medium that would create an invalid filename, it isimplementation-defined whether the data from the file is stored on the local file system and under what name it is stored. Thepax utility may choose to ignore these files as long as it produces an error indicating that the file is being ignored.

cpio File Data

Followingc_name, there shall bec_filesize octets of data. Interpretation of such data occurs in a mannerdependent on the file. For regular files, the data shall consist of the contents of the file. For symbolic links, the data shallconsist of the contents of the symbolic link. Ifc_filesize is zero, no data shall be contained inc_filedata.

When restoring from an archive:

cpio Special Entries

FIFO special files, directories, and the trailer shall be recorded withc_filesize equal to zero. Symbolic links shall berecorded withc_filesize equal to the length of the contents of the symbolic link. For other special files,c_filesize is unspecified by this volume of POSIX.1-2017. The header for the next file entry in the archive shall be writtendirectly after the last octet of the file entry preceding it. A header denoting the filenameTRAILER!!! shall indicate theend of the archive; the contents of octets in the last block of the archive following such a header are undefined.

EXIT STATUS

The following exit values shall be returned:

 0
All files were processed successfully.
>0
An error occurred.

CONSEQUENCES OF ERRORS

Ifpax cannot create a file or a link when reading an archive or cannot find a file when writing an archive, or cannotpreserve the user ID, group ID, or file mode when the-p option is specified, a diagnostic message shall be written tostandard error and a non-zero exit status shall be returned, but processing shall continue. In the case wherepax cannotcreate a link to a file,pax shall not, by default, create a second copy of the file.

If the extraction of a file from an archive is prematurely terminated by a signal or error,pax may have only partiallyextracted the file or (if the-n option was not specified) may have extracted a file of the same name as that specified bythe user, but which is not the file the user wanted. Additionally, the file modes of extracted directories may have additional bitsfrom the S_IRWXU mask set as well as incorrect modification and access times.


The following sections are informative.

APPLICATION USAGE

Caution is advised when using the-a option to append to acpio format archive. If any of the files being appendedhappen to be given the samec_dev andc_ino values as a file in the existing part of the archive, then they may betreated as links to that file on extraction. Thus, it is risky to use-a withcpio format except when it is done onthe same system that the original archive was created on, and with the samepax utility, and in the knowledge that there hasbeen little or no file system activity since the original archive was created that could lead to any of the files appended beinggiven the samec_dev andc_ino values as an unrelated file in the existing part of the archive. Also, when(intentionally) appending additional links to a file in the existing part of the archive, thec_nlink values in the modifiedarchive can be smaller than the number of links to the file in the archive, which may mean that the links are not preserved onextraction.

The-p (privileges) option was invented to reconcile differences between historicaltar andcpioimplementations. In particular, the two utilities use-m in diametrically opposed ways. The-p option also provides aconsistent means of extending the ways in which future file attributes can be addressed, such as for enhanced security systems orhigh-performance files. Although it may seem complex, there are really two modes that are most commonly used:

-p e
``Preserve everything". This would be used by the historical superuser, someone with all appropriate privileges, to preserveall aspects of the files as they are recorded in the archive. Thee flag is the sum ofo andp, and otherimplementation-defined attributes.
-p p
``Preserve" the file mode bits. This would be used by the user with regular privileges who wished to preserve aspects of thefile other than the ownership. The file times are preserved by default, but two other flags are offered to disable these and usethe time of extraction.

The one pathname per line format of standard input precludes pathnames containing <newline> characters. Although suchpathnames violate the portable filename guidelines, they may exist and their presence may inhibit usage ofpax within shellscripts. This problem is inherited from historical archive programs. The problem can be avoided by listing filename arguments onthe command line instead of on standard input.

It is almost certain that appropriate privileges are required forpax to accomplish parts of this volume of POSIX.1-2017.Specifically, creating files of type block special or character special, restoring file access times unless the files are owned bythe user (the-t option), or preserving file owner, group, and mode (the-p option) all probably require appropriateprivileges.

Inread mode, implementations are permitted to overwrite files when the archive has multiple members with the same name.This may fail if permissions on the first version of the file do not permit it to be overwritten.

Thecpio andustar formats can only support files up to 8589934592 bytes (8 * 2^30) in size.

When archives containing binary header information are listed , the filenames printed may cause strange behavior on someterminals.

When all of the following are true:

  1. A file of type directory is being placed into an archive.

  2. Theustar archive format is being used.

  3. The pathname of the directory is less than or equal to 155 bytes long (it will fit in theprefix field in theustar header block).

  4. The last component of the pathname of the directory is longer than 100 bytes long (it will not fit in thename field intheustar header block).

some implementations of thepax utility will place the entire directory pathname in theprefix field, set thename field to an empty string, and place the directory in the archive. Other implementations of thepax utility willgive an error under these conditions because thename field is not large enough to hold the last component of the directoryname. This standard allows either behavior. However, when extracting a directory from austar format archive, this standardrequires that all implementations be able to extract a directory even if thename field contains an empty string as long astheprefix field does not also contain an empty string.

EXAMPLES

The following command:

pax -w -f /dev/rmt/1m .

copies the contents of the current directory to tape drive 1, medium density (assuming historical System V device namingprocedures-the historical BSD device name would be/dev/rmt9).

The following commands:

mkdirnewdirpax -rwolddir newdir

copy theolddir directory hierarchy tonewdir.

pax -r -s ',^//*usr//*,,' -f a.pax

reads the archivea.pax, with all files rooted in/usr in the archive extracted relative to the currentdirectory.

Using the option:

-o listopt="%M %(atime)T %(size)D %(name)s"

overrides the default output description in Standard Output and instead writes:

-rw-rw--- Jan 12 15:53 2003 1492 /usr/foo/bar

Using the options:

-o listopt='%L\t%(size)D\n%.7' \-o listopt='(name)s\n%(atime)T\n%T'

overrides the default output description in Standard Output and instead writes:

/usr/foo/bar -> /tmp   1492/usr/foJan 12 15:53 1991Jan 31 15:53 2003

RATIONALE

Thepax utility was new for the ISO POSIX-2:1993 standard. It represents a peaceful compromise between advocates ofthe historicaltar andcpio utilities.

A fundamental difference betweencpio andtar was in the way directories were treated. Thecpio utility didnot treat directories differently from other files, and to select a directory and its contents required that each file in thehierarchy be explicitly specified. Fortar, a directory matched every file in the file hierarchy it rooted.

Thepax utility offers both interfaces; by default, directories map into the file hierarchy they root. The-doption causespax to skip any file not explicitly referenced, ascpio historically did. Thetar-style behavior was chosen as the default because it was believed that this was the more common usage and becausetaris the more commonly available interface, as it was historically provided on both System V and BSD implementations.

The data interchange format specification in this volume of POSIX.1-2017 requires that processes with "appropriate privileges''shall always restore the ownership and permissions of extracted files exactly as archived. If viewed from the historic equivalencebetween superuser and "appropriate privileges", there are two problems with this requirement. First, users running as superusersmay unknowingly set dangerous permissions on extracted files. Second, it is needlessly limiting, in that superusers cannot extractfiles and own them as superuser unless the archive was created by the superuser. (It should be noted that restoration of ownershipsand permissions for the superuser, by default, is historical practice incpio, but not intar.) In order to avoidthese two problems, thepax specification has an additional "privilege" mechanism, the-p option. Only apaxinvocation with the privileges needed, and which has the-p option set using thee specification character, hasappropriate privileges to restore full ownership and permission information.

Note also that this volume of POSIX.1-2017 requires that the file ownership and access permissions shall be set, on extraction,in the same fashion as thecreat() function when provided with the mode stored in thearchive. This means that the file creation mask of the user is applied to the file permissions.

Users should note that directories may be created bypax while extracting files with permissions that are different fromthose that existed at the time the archive was created. When extracting sensitive information into a directory hierarchy that nolonger exists, users are encouraged to set their file creation mask appropriately to protect these files during extraction.

The table of contents output is written to standard output to facilitate pipeline processing.

An early proposal had hard links displaying for all pathnames. This was removed because it complicates the output of the casewhere-v is not specified and does not match historicalcpio usage. The hard-link information is available in the-v display.

The description of the-l option allows implementations to make hard links to symbolic links. Earlier versions of thisstandard did not specify any way to create a hard link to a symbolic link, but many implementations provided this capability as anextension. If there are hard links to symbolic links when an archive is created, the implementation is required to archive the hardlink in the archive (unless-H or-L is specified). When inread mode and incopy mode, implementationssupporting hard links to symbolic links should use them when appropriate.

The archive formats inherited from the POSIX.1-1990 standard have certain restrictions that have been brought along fromhistorical usage. For example, there are restrictions on the length of pathnames stored in the archive. Whenpax is used incopy(-rw) mode (copying directory hierarchies), the ability to use extensions from the-xpax formatovercomes these restrictions.

The defaultblocksize value of 5120 bytes forcpio was selected because it is one of the standard block-sizevalues forcpio, set when the-B option is specified. (The other default block-size value forcpio is 512bytes, and this was considered to be too small.) The default block value of 10240 bytes fortar was selected because that isthe standard block-size value for BSDtar. The maximum block size of 32256 bytes (215-512 bytes)is the largest multiple of 512 bytes that fits into a signed 16-bit tape controller transfer register. There are known limitationsin some historical systems that would prevent larger blocks from being accepted. Historical values were chosen to improvecompatibility with historical scripts usingdd or similar utilities to manipulatearchives. Also, default block sizes for any file type other than character special file has been deleted from this volume ofPOSIX.1-2017 as unimportant and not likely to affect the structure of the resulting archive.

Implementations are permitted to modify the block-size value based on the archive format or the device to which the archive isbeing written. This is to provide implementations with the opportunity to take advantage of special types of devices, and it shouldnot be used without a great deal of consideration as it almost certainly decreases archive portability.

The intended use of the-n option was to permit extraction of one or more files from the archive without processing theentire archive. This was viewed by the standard developers as offering significant performance advantages over historicalimplementations. The-n option in early proposals had three effects; the first was to cause special characters in patternsto not be treated specially. The second was to cause only the first file that matched a pattern to be extracted. The third was tocausepax to write a diagnostic message to standard error when no file was found matching a specified pattern. Only thesecond behavior is retained by this volume of POSIX.1-2017, for many reasons. First, it is in general not acceptable for a singleoption to have multiple effects. Second, the ability to make pattern matching characters act as normal characters is useful forparts ofpax other than file extraction. Third, a finer degree of control over the special characters is useful becauseusers may wish to normalize only a single special character in a single filename. Fourth, given a more general escape mechanism,the previous behavior of the-n option can be easily obtained using the-s option or ased script. Finally, writing a diagnostic message when a pattern specified by the user isunmatched by any file is useful behavior in all cases.

In this version, the-n was removed from thecopy mode synopsis ofpax; it is inapplicable because thereare no pattern operands specified in this mode.

There is another method thanpax for copying subtrees in POSIX.1-2017 described as part of thecp utility. Both methods are historical practice:cpprovides a simpler, more intuitive interface, whilepax offers a finer granularity of control. Each provides additionalfunctionality to the other; in particular,pax maintains the hard-link structure of the hierarchy whilecp does not. It is the intention of the standard developers that the results be similar (usingappropriate option combinations in both utilities). The results are not required to be identical; there seemed insufficient gain toapplications to balance the difficulty of implementations having to guarantee that the results would be exactly identical.

A single archive may span more than one file. It is suggested that implementations provide informative messages to the user onstandard error whenever the archive file is changed.

The-d option (do not create intermediate directories not listed in the archive) found in early proposals was originallyprovided as a complement to the historic-d option ofcpio. It has been deleted.

The-s option in early proposals specified a subset of the substitution command from theed utility. As there was no reason for only a subset to be supported, the-s option is nowcompatible with the currented specification. Since the delimiter can be any non-nullcharacter, the following usage with single <space> characters is valid:

pax -s " foo bar " ...

The-t description is worded so as to note that this may cause the access time update caused by some other activity(which occurs while the file is being read) to be overwritten.

The default behavior ofpax with regard to file modification times is the same as historical implementations oftar. It is not the historical behavior ofcpio.

Because the-i option uses/dev/tty, utilities without a controlling terminal are not able to use this option.

The-y option, found in early proposals, has been deleted because a line containing a single <period> for the-i option has equivalent functionality. The special lines for the-i option (a single <period> and the emptyline) are historical practice incpio.

In early drafts, a-echarmap option was included to increase portability of files between systems using differentcoded character sets. This option was omitted because it was apparent that consensus could not be formed for it. In this version,the use of UTF-8 should be an adequate substitute.

The ISO POSIX-2:1993 standard and ISO POSIX-1 standard requirements forpax, however, made it very difficult tocreate a single archive containing files created using extended characters provided by different locales. This version adds thehdrcharset keyword to make it possible to archive files in these cases without dropping files due to translation errors.

Translating filenames and other attributes from a locale's encoding to UTF-8 and then back again can lose information, as theresulting filename might not be byte-for-byte equivalent to the original. To avoid this problem, users can specify the-ohdrcharset=binary option, which will cause the resulting archive to use binary format for all names and attributes. Sucharchives are not portable among hosts that use different native encodings (e.g., EBCDICversus ASCII-based encodings), butthey will allow interchange among the vast majority of POSIX file systems in practical use. Also, the-ohdrcharset=binary option will causepax incopy mode to behave more like other standard utilities such ascp.

If the values specified by the-oexthdr.name=value,-oglobexthdr.name=value, or by$TMPDIR(if-oglobexthdr.name is not specified) require a character encoding other than that described in theISO/IEC 646:1991 standard, apath extended header record will have to be created for the file. If ahdrcharsetextended header record is active for such headers, it will determine the codeset used for the value field in these extendedpath header records. Thesepath extended header records always need to be created when writing an archive even ifhdrcharset=binary has been specified and would contain the same (binary) data that appears in theustar header recordprefix andname fields. (In other words, an extended headerpath record is always required to be generated if theprefix orname fields contain non-ASCII characters even whenhdrcharset=binary is also in effect for thatfile.)

The-k option was added to address international concerns about the dangers involved in the character set transformationsof-e (if the target character set were different from the source, the filenames might be transformed into names matchingexisting files) and also was made more general to protect files transferred between file systems with different {NAME_MAX} values(truncating a filename on a smaller system might also inadvertently overwrite existing files). As stated, it prevents anyoverwriting, even if the target file is older than the source. This version adds more granularity of options to solve this problemby introducing the-oinvalid=option -specifically theUTF-8 andbinary actions. (Note that an existingfile is still subject to overwriting in this case. The-k option closes that loophole.)

Some of the file characteristics referenced in this volume of POSIX.1-2017 might not be supported by some archive formats. Forexample, neither thetar norcpio formats contain the file access time. For this reason, thee specificationcharacter has been provided, intended to cause all file characteristics specified in the archive to be retained.

It is required that extracted directories, by default, have their access and modification times and permissions set to thevalues specified in the archive. This has obvious problems in that the directories are almost certainly modified after beingextracted and that directory permissions may not permit file creation. One possible solution is to create directories with the modespecified in the archive, as modified by theumask of the user, with sufficientpermissions to allow file creation. After all files have been extracted,pax would then reset the access and modificationtimes and permissions as necessary.

The list-mode formatting description borrows heavily from the one defined by theprintf utility. However, since there is no separate operand list to get conversion arguments,the format was extended to allow specifying the name of the conversion argument as part of the conversion specification.

TheT conversion specifier allows time fields to be displayed in any of the date formats. Unlike thels utility,pax does not adjust the format when the date is less than six months in thepast. This makes parsing the output more predictable.

TheD conversion specifier handles the ability to display the major/minor or file size, as withls, by using%-8(size)D.

TheL conversion specifier handles thels display for symbolic links.

Conversion specifiers were added to generate existing known types used forls.

pax Interchange Format

The new POSIX data interchange format was developed primarily to satisfy international concerns that theustar andcpio formats did not provide for file, user, and group names encoded in characters outside a subset of theISO/IEC 646:1991 standard. The standard developers realized that this new POSIX data interchange format should be veryextensible because there were other requirements they foresaw in the near future:

The following were not goals for this format because these are better handled by separate utilities or are inappropriate for aportable format:

The format chosen to support the goals is an extension of theustar format. Of the two formats previously available, onlytheustar format was selected for extensions because:

The new format was designed with one additional goal in mind: reasonable behavior when an oldertar orpax utilityhappened to read an archive. Since the POSIX.1-1990 standard mandated that a "format-reading utility" had to treat unrecognizedtypeflag values as regular files, this allowed the format to include all the extended information in a pseudo-regular filethat preceded each real file. An option is given that allows the archive creator to set up reasonable names for these files on theolder systems. Also, the normative text suggests that reasonable file access values be used for thisustar header block.Making these header files inaccessible for convenient reading and deleting would not be reasonable. File permissions of 600 or 700are suggested.

Theustartypeflag field was used to accommodate the additional functionality of the new format rather than magicor version because the POSIX.1-1990 standard (and, by reference, the previous version ofpax), mandated the behavior of theformat-reading utility when it encountered an unknowntypeflag, but was silent about the other two fields.

Early proposals for the first version of this standard contained a proposed archive format that was based on compatibility withthe standard for tape files (ISO 1001, similar to the format used historically on many mainframes and minicomputers). Thisformat was overly complex and required considerable overhead in volume and header records. Furthermore, the standard developersfelt that it would not be acceptable to the community of POSIX developers, so it was later changed to be a format more closelyrelated to historical practice on POSIX systems.

The prefix and name split of pathnames inustar was replaced by the single path extended header record forsimplicity.

The concept of a global extended header (typeflagg) was controversial. If this were applied to an archive beingrecorded on magnetic tape, a few unreadable blocks at the beginning of the tape could be a serious problem; a utility attempting toextract as many files as possible from a damaged archive could lose a large percentage of file header information in this case.However, if the archive were on a reliable medium, such as a CD-ROM, the global extended header offers considerable potential sizereductions by eliminating redundant information. Thus, the text warns against using the global method for unreliable media andprovides a method for implanting global information in the extended header for each file, rather than in thetypeflagg records.

No facility for data translation or filtering on a per-file basis is included because the standard developers could not inventan interface that would allow this in an efficient manner. If a filter, such as encryption or compression, is to be applied to allthe files, it is more efficient to apply the filter to the entire archive as a single file. The standard developers consideredinterfaces that would invoke a shell script for each file going into or out of the archive, but the system overhead in thisapproach was considered to be too high.

One such approach would be to havefilter= records that give a pathname for an executable. When the program is invoked,the file and archive would be open for standard input/output and all the header fields would be available as environment variablesor command-line arguments. The standard developers did discuss such schemes, but they were omitted from POSIX.1-2017 due toconcerns about excessive overhead. Also, the program itself would need to be in the archive if it were to be used portably.

There is currently no portable means of identifying the character set(s) used for a file in the file system. Therefore,pax has not been given a mechanism to generate charset records automatically. The only portable means of doing this is forthe user to write the archive using the-ocharset=string command line option. This assumes that all of the files inthe archive use the same encoding. The "implementation-defined" text is included to allow for a system that can identify theencodings used for each of its files.

The table of standards that accompanies the charset record description is acknowledged to be very limited. Only a limited numberof character set standards is reasonable for maximal interchange. Any character set is, of course, possible by prior agreement. Itwas suggested that EBCDIC be listed, but it was omitted because it is not defined by a formal standard. Formal standards, and thenonly those with reasonably large followings, can be included here, simply as a matter of practicality. The <value>srepresent names of officially registered character sets in the format required by the ISO 2375:1985 standard.

The normal <comma> or <blank>-separated list rules are not followed in the case of keyword options to allow ease ofargument parsing forgetopts.

Further information on character encodings is inpax Archive Character Set Encoding/Decoding.

The standard developers have reserved keyword name space for vendor extensions. It is suggested that the format to be usedis:

VENDOR.keyword

whereVENDOR is the name of the vendor or organization in all uppercase letters. It is further suggested that the keywordfollowing the <period> be named differently than any of the standard keywords so that it could be used for futurestandardization, if appropriate, by omitting theVENDOR prefix.

The <length> field in the extended header record was included to make it simpler to step through the records, evenif a record contains an unknown format (to a particularpax) with complex interactions of special characters. It alsoprovides a minor integrity checkpoint within the records to aid a program attempting to recover files from a damaged archive.

There are no extended header versions of thedevmajor anddevminor fields because the unspecified formatustar header field should be sufficient. If they are not, vendor-specific extended keywords (such asVENDOR.devmajor)should be used.

Device andi-number labeling of files was not adopted fromcpio; files are interchanged strictly on a symbolicname basis, as inustar.

Just as with theustar format descriptions, the new format makes no special arrangements for multi-volume archives. Eachof thepax archive types is assumed to be inside a single POSIX file and splitting that file over multiple volumes(diskettes, tape cartridges, and so on), processing their labels, and mounting each in the proper sequence are considered to beimplementation details that cannot be described portably.

Thepax format is intended for interchange, not only for backup on a single (family of) systems. It is not as denselypacked as might be possible for backup:

The requirements on restoring from an archive are slightly different from the historical wording, allowing for non-monolithicprivilege to bring forward as much as possible. In particular, attributes such as "high performance file" might be broadly butnot universally granted while set-user-ID orchown() might be much more restricted.There is no implication in POSIX.1-2017 that the security information be honored after it is restored to the file hierarchy, inspite of what might be improperly inferred by the silence on that topic. That is a topic for another standard.

Links are recorded in the fashion described here because a link can be to any file type. It is desirable in general to be ableto restore part of an archive selectively and restore all of those files completely. If the data is not associated with each link,it is not possible to do this. However, the data associated with a file can be large, and when selective restoration is not needed,this can be a significant burden. The archive is structured so that files that have no associated data can always be restored bythe name of any link name of any link, and the user may choose whether data is recorded with each instance of a file that containsdata. The format permits mixing of both types of links in a single archive; this can be done for special needs, andpax isexpected to interpret such archives on input properly, despite the fact that there is nopax option that would force thismixed case on output. (When-olinkdata is used, the output must contain the duplicate data, but the implementationis free to include it or omit it when-olinkdata is not used.)

The time values are included as extended header records for those implementations needing more than the eleven octal digitsallowed by theustar format. Portable file timestamps cannot be negative. Ifpax encounters a file with a negativetimestamp incopy orwrite mode, it can reject the file, substitute a non-negative timestamp, or generate anon-portable timestamp with a leading'-'. Even though some implementations can support finer file-time granularitiesthan seconds, the normative text requires support only for seconds since the Epoch because the ISO POSIX-1 standard statesthem that way. Theustar format includes onlymtime; the new format addsatime andctime for symmetry.Theatime access time restored to the file system will be affected by the-pa and-pe options.Thectime creation time (actuallyinode modification time) is described with appropriate privileges so that it can beignored when writing to the file system. POSIX does not provide a portable means to change file creation time. Nothing is intendedto prevent a non-portable implementation ofpax from restoring the value.

Thegid,size, anduid extended header records were included to allow expansion beyond the sizes specifiedin the regulartar header. New file system architectures are emerging that will exhaust the 12-digit size field. There areprobably not many systems requiring more than 8 digits for user and group IDs, but the extended header values were included forcompleteness, allowing overrides for all of the decimal values in thetar header.

The standard developers intended to describe the effective results ofpax with regard to file ownerships and permissions;implementations are not restricted in timing or sequencing the restoration of such, provided the results are as specified.

Much of the text describing the extended headers refers to use in "write orcopy modes". Thecopy modereferences are due to the normative text: "The effect of the copy shall be as if the copied files were written to an archive fileand then subsequently extracted ...". There is certainly no way to test whetherpax is actually generating the extendedheaders incopy mode, but the effects must be as if it had.

pax Archive Character Set Encoding/Decoding

There is a need to exchange archives of files between systems of different native codesets. Filenames, group names, and usernames must be preserved to the fullest extent possible when an archive is read on the receiving platform. Translation of thecontents of files is not within the scope of thepax utility.

There will also be the need to represent characters that are not available on the receiving platform. These unsupportedcharacters cannot be automatically folded to the local set of characters due to the chance of collisions. This could result inoverwriting previous extracted files from the archive or pre-existing files on the system.

For these reasons, the codeset used to represent characters within the extended header records of thepax archive must besufficiently rich to handle all commonly used character sets. The fields requiring translation include, at a minimum, filenames,user names, group names, and link pathnames. Implementations may wish to have localized extended keywords that use non-portablecharacters.

The standard developers considered the following options:

The approach that incorporates the name of the source codeset poses the problem of codeset name registration, and makes thearchive useless topax archive decoders that do not recognize that codeset.

Because parts of an archive may be corrupted, the standard developers felt that including the character map of the sourcecodeset was too fragile. The loss of this one key component could result in making the entire archive useless. (The differencebetween this and the global extended header decision was that the latter has a workaround-duplicating extended header records onunreliable media-but this would be too burdensome for large character set maps.)

Both of the above approaches also put an undue burden on thepax archive receiver to handle the cross-product of allsource and destination codesets.

To simplify the translation from the source codeset to the canonical form and from the canonical form to the destinationcodeset, the standard developers decided that the internal representation should be a stateless encoding. A stateless encoding isone where each codepoint has the same meaning, without regard to the decoder being in a specific state. An example of a statefulencoding would be the Japanese Shift-JIS; an example of a stateless encoding would be the ISO/IEC 646:1991 standard(equivalent to 7-bit ASCII).

For these reasons, the standard developers decided to adopt a canonical format for the representation of file informationstrings. The obvious, well-endorsed candidate is the ISO/IEC 10646-1:2000 standard (based in part on Unicode), which can beused to represent the characters of virtually all standardized character sets. The standard developers initially agreed upon usingUCS2 (16-bit Unicode) as the internal representation. This repertoire of characters provides a sufficiently rich set to representall commonly-used codesets.

However, the standard developers found that the 16-bit Unicode representation had some problems. It forced the issue ofstandardizing byte ordering. The 2-byte length of each character made the extended header records twice as long for the case ofstrings coded entirely from historical 7-bit ASCII. For these reasons, the standard developers chose the UTF-8 defined in theISO/IEC 10646-1:2000 standard. This multi-byte representation encodes UCS2 or UCS4 characters reliably and deterministically,eliminating the need for a canonical byte ordering. In addition, NUL octets and other characters possibly confusing to POSIX filesystems do not appear, except to represent themselves. It was realized that certain national codesets take up more space after theencoding, due to their placement within the UCS range; it was felt that the usefulness of the encoding of the names outweighs thedisadvantage of size increase for file, user, and group names.

The encoding of UTF-8 is as follows:

UCS4 Hex Encoding  UTF-8 Binary Encoding
00000000-0000007F 0xxxxxxx00000080-000007FF 110xxxxx 10xxxxxx00000800-0000FFFF 1110xxxx 10xxxxxx 10xxxxxx00010000-001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx00200000-03FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx04000000-7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

where each'x' represents a bit value from the character being translated.

ustar Interchange Format

The description of theustar format reflects numerous enhancements over pre-1988 versions of the historicaltarutility. The goal of these changes was not only to provide the functional enhancements desired, but also to retain compatibilitybetween new and old versions. This compatibility has been retained. Archives written using the old archive format are compatiblewith the new format.

Implementors should be aware that the previous file format did not include a mechanism to archive directory type files. For thisreason, the convention of using a filename ending with <slash> was adopted to specify a directory on the archive.

The total size of thename andprefix fields have been set to meet the minimum requirements for {PATH_MAX}. If apathname will fit within thename field, it is recommended that the pathname be stored there without the use of theprefix field. Although the name field is known to be too small to contain {PATH_MAX} characters, the value was not changedin this version of the archive file format to retain backwards-compatibility, and instead the prefix was introduced. Also, becauseof the earlier version of the format, there is no way to remove the restriction on thelinkname field being limited in sizeto just that of thename field.

Thesize field is required to be meaningful in all implementation extensions, although it could be zero. This is requiredso that the data blocks can always be properly counted.

It is suggested that if device special files need to be represented that cannot be represented in the standard format, that oneof the extension types (A-Z) be used, and that the additional information for the special file be represented asdata and be reflected in thesize field.

Attempting to restore a special file type, where it is converted to ordinary data and conflicts with an existing filename, neednot be specially detected by the utility. If run as an ordinary user,pax should not be able to overwrite the entries in,for example,/dev in any case (whether the file is converted to another type or not). If run as a privileged user, it shouldbe able to do so, and it would be considered a bug if it did not. The same is true of ordinary data files and similarly namedspecial files; it is impossible to anticipate the needs of the user (who could really intend to overwrite the file), so thebehavior should be predictable (and thus regular) and rely on the protection system as required.

The value 7 in thetypeflag field is intended to define how contiguous files can be stored in austar archive.POSIX.1-2017 does not require the contiguous file extension, but does define a standard way of archiving such files so that allconforming systems can interpret these file types in a meaningful and consistent manner. On a system that does not support extendedfile types, thepax utility should do the best it can with the file and go on to the next.

The file protection modes are those conventionally used by thels utility. This isextended beyond the usage in the ISO POSIX-2 standard to support the "shared text" or "sticky" bit. It is intended thatthe conformance document should not document anything beyond the existence of and support of such a mode. Further extensions areexpected to these bits, particularly with overloading the set-user-ID and set-group-ID flags.

cpio Interchange Format

The reference to appropriate privileges in thecpio format refers to an error on standard output; theustar formatdoes not make comparable statements.

The model for this format was the historical System Vcpio-c data interchange format. This model documents theportable version of thecpio format and not the binary version. It has the flexibility to transfer data of any typedescribed within POSIX.1-2017, yet is extensible to transfer data types specific to extensions beyond POSIX.1-2017 (for example,contiguous files). Because it describes existing practice, there is no question of maintaining upwards-compatibility.

cpio Header

There has been some concern that the size of thec_ino field of the header is too small to handle those systems that havevery largeinode numbers. However, thec_ino field in the header is used strictly as a hard-link resolution mechanismfor archives. It is not necessarily the same value as theinode number of the file in the location from which that file isextracted.

The namec_magic is based on historical usage.

cpio Filename

For most historical implementations of thecpio utility, {PATH_MAX} octets can be used to describe the pathname withoutthe addition of any other header fields (the NUL character would be included in this count). {PATH_MAX} is the minimum value forpathname size, documented as 256 bytes. However, an implementation may usec_namesize to determine the exact length of thepathname. With the current description of the<cpio.h> header, this pathnamesize can be as large as a number that is described in six octal digits.

Two values are documented under thec_mode field values to provide for extensibility for known file types:

0110 000
Reserved for contiguous files. The implementation may treat the rest of the information for this archive like a regular file.If this file type is undefined, the implementation may create the file as a regular file.

This provides for extensibility of thecpio format while allowing for the ability to read old archives. Files of anunknown type may be read as "regular files" on some implementations. On a system that does not support extended file types, thepax utility should do the best it can with the file and go on to the next.

FUTURE DIRECTIONS

None.

SEE ALSO

Shell Command Language,cp,ed,getopts,ls,printf

XBDFile Mode Bits,File Format Notation,EnvironmentVariables,Utility Syntax Guidelines,<cpio.h>,<tar.h>

XSHchown,creat,fstatat,mkdir,mkfifo,utime,write

CHANGE HISTORY

First released in Issue 4.

Issue 5

A note is added to the APPLICATION USAGE indicating that thecpio andtar formats can only support files up to 8gigabytes in size.

Issue 6

Thepax utility is aligned with the IEEE P1003.2b draft standard:

TheTZ entry is added to the ENVIRONMENT VARIABLES section.

IEEE PASC Interpretation 1003.2 #168 is applied, clarifying thatmkdir() andmkfifo() calls can ignore an [EEXIST] error when extracting an archive.

IEEE PASC Interpretation 1003.2 #180 is applied, clarifying how extracted files are created when inread mode.

IEEE PASC Interpretation 1003.2 #181 is applied, clarifying the description of the-t option.

IEEE PASC Interpretation 1003.2 #195 is applied.

IEEE PASC Interpretation 1003.2 #206 is applied, clarifying the handling of links for the-H,-L, and-loptions.

IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/35 is applied, adding the process ID of thepax processinto certain fields. This change provides a method for the implementation to ensure that different instances ofpaxextracting a file named/a/b/foo will not collide when processing the extended header information associated withfoo.

IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/36 is applied, changing-x B to-xpax inthe OPTIONS section.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/20 is applied, updating the SYNOPSIS to be consistent with thenormative text.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/21 is applied, updating the DESCRIPTION to describe the behaviorwhen files to be linked are symbolic links and the system is not capable of making hard links to symbolic links.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/22 is applied, updating the OPTIONS section to describe thebehavior for how multiple-odelete=pattern options are to be handled.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/23 is applied, updating thewrite option within theOPTIONS section.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/24 is applied, adding a paragraph into the OPTIONS section thatstates that specifying more than one of the mutually-exclusive options (-H and-L) is not considered an error andthat the last option specified will determine the behavior of the utility.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/25 is applied, removing thectime paragraph within theEXTENDED DESCRIPTION. There is a contradiction in the definition of thectime keyword for thepax extended header, inthat thest_ctime member of thestat structure does not refer to a file creation time. No field in the standardstat structure from<sys/stat.h> includes a file creation time.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/26 is applied, making it clear thattypeflag 1 (ustar Interchange Format) applies not only to files that are hard-linked, but also to files that are aliased via symboliclinks.

IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/27 is applied, clarifying thecpioc_nlinkfield.

Issue 7

Austin Group Interpretations 1003.1-2001 #011, #036, #086, and #109 are applied.

Austin Group Interpretation 1003.1-2001 #126 is applied, changing the description of theLC_MESSAGES environmentvariable.

SD5-XCU-ERN-2 is applied, making-c and-n mutually-exclusive in the SYNOPSIS.

SD5-XCU-ERN-3 is applied, revising the default behavior of-H and-L.

SD5-XCU-ERN-5, SD5-XCU-ERN-6, SD5-XCU-ERN-7, SD5-XCU-ERN-60 are applied.

SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.

Thepax utility is no longer allowed to create separate identical symbolic links when extracting linked symbolic linksfrom an archive.

POSIX.1-2008, Technical Corrigendum 1, XCU/TC1-2008/0128 [260], XCU/TC1-2008/0129 [261], XCU/TC1-2008/0130 [261],XCU/TC1-2008/0131 [313], and XCU/TC1-2008/0132 [233] are applied.

POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0152 [886], XCU/TC2-2008/0153 [814], XCU/TC2-2008/0154 [886], andXCU/TC2-2008/0155 [707] are applied.

End of informative text.

 

return to top of page


<<<PreviousHomeNext >>>


[8]ページ先頭

©2009-2025 Movatter.jp