The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

pax - portable archive interchange

 SYNOPSIS



pax [-cdnv][-f archive][-s replstr]...[pattern...]

pax -r[-cdiknuv][-f archive][-o options]...[-p string]...
[-s replstr]...[pattern...]

pax -w[-dituvX][-b blocksize][[-a][-f archive][-o options]...
[-s replstr]...[-x format][file...]

pax -r -w[-diklntuvX][-p string]...[-s replstr]...[file...]
directory

 DESCRIPTION

The pax utility reads, writes and writes lists of the members of archive files and copy directory hierarchies. A variety of archive formats are supported; see the -x format 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 and copy modes, corresponding respectively to the four forms shown in the SYNOPSIS section.

list
In list mode (when neither -r nor -w are specified), pax writes the names of the members of the archive file read from the standard input, with pathnames matching the specified patterns, to standard output. If a named file is of type directory, the file hierarchy rooted at that file will be written out as well.
read
In read mode (when -r is specified, but -w is not), pax extracts the members of the archive file read from the standard input, with pathnames matching the specified patterns. If an extracted file is of type directory, the file hierarchy rooted at that file will be extracted as well. The extracted files is created relative to the current file hierarchy. The ownership, access and modification times, and file mode of the restored files are discussed under the -p option.
write
In write mode (when -w is specified, but -r is not), pax writes the contents of the file operands to the standard output in an archive format. If no file operands are specified, a list of files to copy, one per line, will be read from the standard input. A file of type directory will include all of the files in the file hierarchy rooted at the file.
copy
In copy mode (when both -r and -w are specified), pax copies the file operands to the destination directory. If no file operands are specified, a list of files to copy, one per line, will be read from the standard input. A file of type directory will include all of the files in the file hierarchy rooted at the file. The effect of the copy is as if the copied files were written to an archive file and then subsequently extracted, except that there may be hard links between the original and the copied files. If the destination directory is a subdirectory of one of the files to be copied, the results are unspecified. If the destination directory is a file of a type not defined by the XSH specification, the results are implementation-dependent; otherwise it is an error for the file named by the directory operand not to exist, not be writable by the user, or not be a file of type directory.

In read or copy modes, if intermediate directories are necessary to extract an archive member, pax will perform actions equivalent to the XSH specification mkdir() function, called with the following arguments:

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

The supported archive formats are automatically detected on input. The default output archive format is implementation-dependent.

A single archive can span multiple files. The pax utility determines, in an implementation-dependent manner, what file to read or write as the next file.

If the selected archive format supports the specification of linked files, it is an error if these files cannot be linked when the archive is extracted. Any of the various names in the archive that represent a file can be used to select the file for extraction.

 OPTIONS

The pax utility supports the XBD specification, Utility Syntax Guidelines  , except that the order of presentation of the -s options is significant.

The following options are 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-dependent which devices on the system support appending. Additional file formats unspecified by this specification 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 may impose restrictions on blocking. Blocking is automatically determined on input. Portable applications must not specify a blocksize value larger than 32256. Default blocking when creating archives depends on the archive format. (See the -x option below.)
-c
Match all file or archive members except those specified by the pattern or file operands.
-d
Cause files of type directory being copied or archived or archive members of type directory being extracted to match only 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 (in list or read modes) or standard output (write mode).
-i
Interactively rename files or archive members. For each archive member matching a pattern operand or file matching a file operand, a prompt will be written to the file /dev/tty. The prompt will contain the name of the file or archive member, but the format is otherwise unspecified. A line will then be read from /dev/tty. If this line is blank, the file or archive member will be skipped. If this line consists of a single period, the file or archive member will be processed with no modification to its name. Otherwise, its name will be replaced with the contents of the line. The pax utility will immediately exit with a non-zero exit status if end-of-file is encountered when reading a response or if /dev/tty cannot be opened for reading and writing.
-k
Prevent the overwriting of existing files.
-l
(The letter ell.) Link files. In copy mode, hard links will be made between the source and destination file hierarchies whenever possible.
-n
Select the first archive member that matches each pattern operand. No more than one archive member will be matched for each pattern (although members of type directory will 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 that is specific to the file format specified by -x. This issue does not specify any such options and a portable application must not use the -o option.
-p string
Specify one or more file characteristic options (privileges). The string option-argument must be a string specifying file characteristics to be retained or discarded on extraction. The string consists of the specification characters a, e, m, o and p. Other, implementation-dependent, characters can be included. Multiple characteristics can be concatenated within the same string and multiple -p options can be specified. The meaning of the specification characters are as follows:
a
Do not preserve file access times.
e
Preserve the user ID, group ID, file mode bits (see file mode bits in the XBD specification, Glossary  ), access time, modification time and any other, implementation-dependent, 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-dependent file-mode attributes may be preserved.

In the preceding list, "preserve" indicates that an attribute stored in the archive will be given to the extracted file, subject to the permissions of the invoking process; otherwise, the attribute will be determined as part of the normal file creation action.

If neither the e nor the o specification character is specified, or the user ID and group ID are not preserved for any reason, pax will 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 will write a diagnostic message to standard error. Failure to preserve these items will affect the final exit status, but will not cause the extracted file to be deleted.

If file-characteristic letters in any of the string option-arguments are duplicated or conflict with each other, the ones given last will take precedence. For example, if -p eme is specified, file modification times will be preserved.

-s replstr
Modify file or archive member names named by pattern or file operands according to the substitution expression replstr, using the syntax of the ed utility. The concepts of "address" and "line" are meaningless in the context of the pax utility, and must not be supplied. The format is:


-s /old/new/[gp]

where as in ed, old is a basic regular expression and new can contain an ampersand, \n (where n is a digit) backreferences, or subexpression matching. The old string also is 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 will be applied in the order specified, terminating with the first successful substitution. The optional trailing g is as defined in the ed utility. The optional trailing p causes successful substitutions to be written to standard error. File or archive member names that substitute to the empty string are ignored when reading and writing archives.

-t
Cause the access times of the archived files to be the same as they were before being read by pax.
-u
Ignore files that are older (having a less recent file modification time) than a pre-existing file or archive member with the same name. In read mode, an archive member with the same name as a file in the file system will be extracted if the archive member is newer than the file. In write mode, an archive file member with the same name as a file in the file system will be superseded if the file is newer than the archive member. It is unspecified if this is accomplished by actual replacement in the archive or by appending to the archive. In copy mode, the file in the destination hierarchy will be replaced by the file in the source hierarchy or by a link to the file in the source hierarchy if the file in the source hierarchy is newer.
-v
In list mode, produce a verbose table of contents (see the STDOUT section). Otherwise, write archive member pathnames to standard error (see the STDERR section).
-x format
Specify the output archive format. The pax utility recognises the following formats:
cpio
The extended cpio interchange format; see the EXTENDED DESCRIPTION section. The default blocksize for this format for character special archive files is 5120. Implementations support all blocksize values less than or equal to 32256 that are multiples of 512.
ustar
The extended tar interchange format; see the EXTENDED DESCRIPTION section. The default blocksize for this format for character special archive files is 10240. Implementations support all blocksize values less than or equal to 32256 that are multiples of 512.

Implementation-dependent formats will specify a default block size as well as any other block sizes supported for character special archive files.

Any attempt to append to an archive file in a format different from the existing archive format will cause pax to exit immediately with a non-zero exit status.

-X
When traversing the file hierarchy specified by a pathname, pax will not descend into directories that have a different device ID (st_dev, see the XSH specification stat()).

The options that operate on the names of files or archive members (-c, -i, -n, -s, -u and -v) interact as follows. In read mode, the archive members are selected based on the user-specified pattern operands as modified by the -c, -n and -u options. Then, any -s and -i options will modify, in that order, the names of the selected files. The -v option will write names resulting from these modifications.

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

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

 OPERANDS

The following operands are supported:
directory
The destination directory pathname for copy 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 the pattern matching notation in Pattern Matching Notation , including the filename expansion rules in Patterns Used for Filename Expansion . The default, if no pattern is specified, is to select all members in the archive.

 STDIN

In write mode, the standard input is used only if no file operands are specified. It must be a text file containing a list of pathnames, one per line, without leading or trailing blank characters.

In list and read modes, the standard input must be an archive file.

Otherwise, the standard input will not be used.

 INPUT FILES

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

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

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of pax:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_COLLATE
Determine the locale for the behaviour of ranges, equivalence classes and multi-character collating elements used in the pattern matching expressions for the pattern operand, the basic regular expression for the -s option, and the extended regular expression defined for the yesexpr locale keyword in the LC_MESSAGES category.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the behaviour of character classes used in the extended regular expression defined for the yesexpr locale keyword in the LC_MESSAGES category, and pattern matching.
LC_MESSAGES
Determine the locale for the processing of affirmative responses that should be used to affect the format and contents of diagnostic messages written to standard error.
LC_TIME
Determine the format and contents of date and time strings when the -v option is specified.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

In write mode, if -f is not specified, the standard output will be the archive formatted according to one of the specifications in the EXTENDED DESCRIPTION section, or some other implementation-dependent format. (See -x format.)

In list mode, the table of contents of the selected archive members will be written to standard output using the following format:

"%s\n", <pathname>

If the -v option is specified in list mode, the table of contents of the selected archive members will be written to standard output using the following formats:

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

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

For all other pathnames:

"%s\n", <ls -l listing>

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

In list mode, standard output will not be buffered more than a line at a time.

 STDERR

If -v is specified in read, write or copy modes, pax will write the pathnames it processes to the standard error output using the following format:

"%s\n", <pathname>

These pathnames will be written as soon as processing is begun on the file or archive member, and will be flushed to standard error. The trailing newline character, which will not be buffered, will be written when the file has been read or written.

If the -s option is specified, and the replacement string has a trailing p, substitutions will be written to standard error in the following format:

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

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

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

 OUTPUT FILES

In read mode, the extracted or copied output files are of the archived file type.

In write mode, the output file named by the -f option-argument is a file formatted according to one of the specifications in the EXTENDED DESCRIPTION section, or some other, implementation-dependent format.

 EXTENDED DESCRIPTION

 Extended cpio Format
The octet-oriented cpio archive format is 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 will be used only to make physical I/O more efficient. The last group of blocks always will be at the full size.

For the octet-oriented cpio archive format, the individual entry information will be in the order indicated and described by the following table:

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
Table: Octet-oriented cpio Archive Entry
 The cpio Header
For each file in the archive, a header as defined previously will be written. The information in the header fields will be written as streams of the ISO/IEC 646:1991 standard characters interpreted as octal numbers. The octal numbers will be extended to the necessary length by appending the ISO/IEC 646:1991 standard IRV zeros at the most-significant-digit end of the number; the result is written to the most-significant-digit of the stream of octets first. The fields are interpreted as follows:
c_magic
Identify the archive as being a transportable archive by containing the identifying value 070707.
c_dev
c_ino
Contains values that uniquely identify the file within the archive (that is, no files will contain the same pair of c_dev and c_ino values unless they are links to the same file). The values will be determined in an unspecified manner.
c_mode
Contains the file type and access permissions as defined in the following table:
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 Set uid.
C_ISGID 002000 Set gid.
C_ISVTX 001000 Reserved.
File Type Name Value Indicates
C_ISDIR 040000 Directory.
C_ISFIFO 010000 FIFO.
C_ISREG 0100000 Regular file.
C_ISBLK 060000 Block special file.
C_ISCHR 020000 Character special file.
C_ISCTG 0110000 Reserved.
C_ISLNK 0120000 Reserved.
C_ISSOCK 0140000 Reserved.
Table: Values for cpio c_mode Field
Directories, FIFOs and regular files are supported on a system conforming to this specification; 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 the number of links referencing the file at the time the archive was created.
c_rdev
Contains implementation-dependent 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 of the file in octets. This will be the length of the data section following the header structure.
 The cpio Filename
The c_name field contains the pathname of the file. The length of this field in octets is the value of c_namesize . If a filename is found on the medium that would create an invalid pathname, it is implementation-dependent if the data from the file is stored on the file hierarchy and under what name it is stored.

All characters are 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 bit zero. 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-dependent encodings of these characters will be provided for interchange purposes. However, the pax utility will never create filenames on the local system that cannot be accessed via the procedures described previously in this specification. If a filename is found on the medium that would create an invalid filename, it is implementation-dependent if the data from the file is stored on the local file system and under what name it is stored. The pax utility may choose to ignore these files as long as it produces an error indicating that the file is being ignored.

 The cpio File Data
Following c_name , there are c_filesize octets of data. Interpretation of such data occurs in a manner dependent on the file. If c_filesize is zero, no data will be contained in c_filedata .

When restoring from an archive:

 The cpio Special Entries
FIFO special files, directories and the trailer are recorded with c_filesize equal to zero. For other special files, c_filesize is unspecified by this specification. The header for the next file entry in the archive will be written directly after the last octet of the file entry preceding it. A header denoting the filename TRAILER!!! indicates the end of the archive; the contents of octets in the last block of the archive following such a header are undefined.
 Extended tar Format
An extended tar archive file contains a series of blocks. Each block will be a fixed-size block of 512 octets (see below). Each file archived is represented by a header block that describes the file, followed by zero or more blocks that give the contents of the file. At the end of the archive file there will be two blocks filled with binary zeros, interpreted as an end-of-archive indicator.

The blocks may be grouped for physical I/O operations. Each group of n blocks (where n is set by the pax -b option) may be written with a single write operation. On magnetic tape, the result of this write will be a single tape record. The last group of blocks always will be at the full size, so blocks after the two zero blocks may contain undefined data.

The header block will be structured as shown in the following table. All lengths and offsets are in decimal.

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
Table: Extended tar Header Block

All characters in the header block are represented in the coded character set of the ISO/IEC 646:1991 standard. For maximum portability between implementations, names should be selected from characters represented by the portable filename character set as octets with the most significant bit zero. 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-dependent encodings of these characters will be provided for interchange purposes. However, the pax utility will never create filenames on the local system that cannot be accessed via the procedures described previously in this specification. If a filename is found on the medium that would create an invalid filename, it is implementation-dependent if the data from the file is stored on the file hierarchy and under what name it is stored. The pax utility may choose to ignore these files as long as it produces an error indicating that the file is being ignored.

Each field within the header block is contiguous; that is, there is no padding used. Each character on the archive medium is stored contiguously.

The fields magic, uname and gname are character strings each terminated by a NUL character. The fields name, linkname and prefix are NUL-terminated character strings except when all characters in the array contain non-NUL characters including the last character. The version field is two octets containing the characters 00 (zero-zero). The typeflag contains a single character. All other fields are leading zero-filled octal numbers using digits from the ISO/IEC 646:1991 standard IRV. Each numeric field is terminated by one or more space or NUL characters.

The name and the prefix fields produce the pathname of the file. The hierarchical relationship of the file can be retained by specifying the pathname as a path prefix, and a slash character and filename as the suffix. A new pathname is formed, if prefix is not an empty string (its first character is not NUL), by concatenating prefix (up to the first NUL character), a slash character and name ; otherwise, name is used alone. In either case, name is terminated at the first NUL character. If prefix begins with a NUL character, it will be ignored. In this manner, pathnames of at most 256 characters can be supported. If a pathname does not fit in the space provided, pax will notify the user of the error, and will not store any part of the file header or data on the medium.

The linkname field, described below, does not use the prefix to produce a pathname. As such, a linkname is limited to 100 characters. If the name does not fit in the space provided, pax will notify the user of the error, and will not attempt to store the link on the medium.

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

04000
Set UID on execution.
02000
Set GID on execution.
01000
Reserved.
00400
Read by owner.
00200
Write by owner.
00100
Execute/search by owner.
00040
Read by group.
00020
Write by group.
00010
Execute/search by group.
00004
Read by other.
00002
Write by other.
00001
Execute/search by other.

When appropriate privilege is required to set one of these mode bits, and the user restoring the files from the archive does not have the appropriate privilege, the mode bits for which the user does not have appropriate privilege will be ignored. Some of the mode bits in the archive format are not mentioned elsewhere in this specification. If the implementation does not support those bits, they may be ignored.

The uid and gid fields are the user and group ID of the owner and group of the file, respectively.

The size field is the size of the file in octets. If the typeflag field is set to specify a file to be of type 1 (a link) or 2 (reserved for symbolic links), the size field will be specified as zero. If the typeflag field is set to specify a file of type 5 (directory), the size field will be interpreted as described under the definition of that record type. No data blocks will be stored for types 1, 2 or 5. If the typeflag field is set to 3 (character special file), 4 (block special file), or 6 (FIFO), the meaning of the size field is unspecified by this specification, and no data blocks will be stored on the medium. Additionally, for 6, the size field is ignored when reading. If the typeflag field is set to any other value, (size +511)/512, the number of blocks written following the header will be ignoring any fraction in the result of the division.

The mtime field is the modification time of the file at the time it was archived. It is the ISO/IEC 646:1991 standard representation of the octal value of the modification time obtained from the XSH specification stat() function.

The chksum field is the ISO/IEC 646:1991 standard IRV representation of the octal value of the simple sum of all octets in the header block. Each octet in the header is treated as an unsigned value. These values will be added to an unsigned integer, initialised to zero, the precision of which will be not less than 17 bits. When calculating the checksum, the chksum field is treated as if it were all spaces.

The typeflag field specifies the type of file archived. If a particular implementation does not recognise the type, or the user does not have appropriate privilege to create that type, the file will be extracted as if it were a regular file if the file type is defined to have a meaning for the size field that could cause data blocks to be written on the medium (see the previous description for size ). If conversion to a regular file occurs, the pax utility will produce an error indicating that the conversion took place. All of the typeflag fields will be coded in the ISO/IEC 646:1991 standard IRV:

'0'
Represents a regular file. For backward compatibility, a typeflag value of binary zero ('\0') should be recognised as meaning a regular file when extracting files from the archive. Archives written with this version of the archive file format create regular files with a typeflag 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 each file having the same device and file serial number. The linked-to name is specified in the linkname field with a NUL-character terminator if it is less than 100 octets in length.
'2'
Reserved to represent a link to another file, of any type, whose device or file serial number differs. This is provided for systems that support linked files whose device or file serial numbers differ, and should be treated as a type 1 file if this extension does not exist.
'3','4'
Represent character special files and block special files respectively. In this case the devmajor and devminor fields contain information defining the device, the format of which is unspecified by this specification. 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, the size field will contain the maximum number of octets (which may be rounded to the nearest disk block allocation unit) that the directory may hold. A size field of zero indicates no such limiting. Systems that do not support limiting in this manner should ignore the size field.
'6'
Specifies a FIFO special file. Note that the archiving of a FIFO file archives the existence of this file and not its contents.
'7'
Reserved to represent a file to which an implementation has associated some high-performance attribute. Implementations without such 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 reserved for specification in future issues.

The magic field is the specification that this archive was output in this archive format. If this field contains ustar (the five characters from the ISO/IEC 646:1991 standard IRV shown followed by NUL), the uname and gname fields will 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 the utility, the password and group files will be scanned for these names. If found, the user and group IDs contained within these files will be used rather than the values contained within the uid and gid fields.

 EXIT STATUS

The following exit values are returned:
0
All files were processed successfully.
>0
An error occurred.

 CONSEQUENCES OF ERRORS

If pax cannot create a file or a link when reading an archive or cannot find a file when writing an archive, or cannot preserve the user ID, group ID or file mode when the -p option is specified, a diagnostic message will be written to standard error and a non-zero exit status will be returned, but processing will continue. In the case where pax cannot create a link to a file, pax will 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 partially extracted the file or (if the -n option was not specified) may have extracted a file of the same name as that specified by the user, but which is not the file the user wanted. Additionally, the file modes of extracted directories may have additional bits from the S_IRWXU mask set as well as incorrect modification and access times.

 APPLICATION USAGE

The -p (privileges) option was invented to reconcile differences between historical tar and cpio implementations. In particular, the two utilities use -m in diametrically opposed ways. The -p option also provides a consistent means of extending the ways in which future file attributes can be addressed, such as for enhanced security systems or high-performance files. Although it may seem complex, there are really two modes that will be most commonly used:
-p e
"Preserve everything". This would be used by the historical superuser, someone with all the appropriate privileges, to preserve all aspects of the files as they are recorded in the archive. The e flag is the sum of o and p, and other implementation-dependent attributes.
-p p
"Preserve" the file mode bits. This would be used by the user with regular privileges who wished to preserve aspects of the file other than the ownership. The file times are preserved by default, but two other flags are offered to disable these and use the time of extraction.

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

It is almost certain that appropriate privileges will be required for pax to accomplish parts of this specification. Specifically, creating files of type block special or character special, restoring file access times unless the files are owned by the user (the -t option) or preserving file owner, group, and mode (the -p option) will all probably require appropriate privileges.

In read 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.

The cpio and tar formats can only support files up to 8 gigabytes in size.

The pax utility is not able to handle arbitrary file sizes. There is currently a proposal in ballot in the IEEE PASC Shell and Utilities Working Group to address this issue.

 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 naming procedures. The historical BSD device name would be /dev/rmt9).

The following commands:


mkdir newdir
pax -rw olddir newdir

copy the olddir directory hierarchy to newdir .


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

reads the archive a.pax, with all files rooted in /usr in the archive extracted relative to the current directory.

 FUTURE DIRECTIONS

It is expected that future versions of the ISO/IEC 9945-2:1993 standard will offer additional file formats and the -o option will be used by future issues to specify such features as international filename and file codeset translations, security, accounting, and so on, related to each additional format.

The pax utility is not able to handle arbitrary file sizes. There is currently a proposal in ballot in the IEEE PASC Shell and Utilities Working Group to address this issue.

 SEE ALSO

None.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]