[comp.std.unix] cpio

std-unix@uunet.UU.NET (Moderator, John Quarterman) (08/14/87)

From: attunix!kevra (Lorraine Kevra)

[ This is the current cpio proposal for 1003.1  -mod ]



FOR COMPUTER ENVIRONMENTS		Std 1003.1-Draft 11



Editor's Note: The following section has been proposed as a   b
replacement for, or an addition to, the previous section.     b
The small group that considered the issue at the June 1987    b
meeting determined that indications were needed on how to     b
extend this subsection to account for at least the following  b
items:							      b

	 o+ symbolic links					b

	 o+ contiguous files					b

	 o+ file name length					b

	 o+ i-node number size					b

There is a possibility that these concerns may be addressed   b
by text in the Rationale, rather than in the body of the      b
standard.						      b


10.3.1	cpio Archive Format				       b
The byte-oriented cpio archive format is a series of	      b
entries, each comprised of a header that describes the file,  b
the name of the file, and then the contents of the file.      b

An archive may be recorded as a series of fixed size blocks   b
of bytes.  This blocking shall be used only to make physical  b
I/O more efficient.  The last group of blocks is always at    b
the full size.						      b

For the byte-oriented cpio archive format, the individual     b
entry information must be in the order indicated and is	      b
described by:						      b
















      UNAPPROVED DRAFT.	 All Rights Reserved by IEEE.
   Do not specify or claim conformance to this document.







Std 1003.1-Draft 11		   PORTABLE OPERATING SYSTEM



	     Byte-Oriented cpio Archive Entry		      b
			  Header			      b
	 Field Name	Length	   Interpreted as	      b
	 __________   __________   _______________	      b
	 c_magic       6 bytes	    octal number	      b
	 c_dev	       6 bytes	    octal number	      b
	 c_ino	       6 bytes	    octal number	      b
	 c_mode	       6 bytes	    octal number	      b
	 c_uid	       6 bytes	    octal number	      b
	 c_gid	       6 bytes	    octal number	      b
	 c_nlink       6 bytes	    octal number	      b
	 c_rdev	       6 bytes	    octal number	      b
	 c_mtime       11 bytes	    octal number	      b
	 c_namesize    6 bytes	    octal number	      b
	 c_filesize    11 bytes	    octal number	      b

			 File Name			      b
	 Field Name	Length	   Interpreted as	      b
	 __________   __________   _______________	      b
	 c_name	      c_namesize   pathname string	      b

			 File Data			      b
	 Field Name	Length	   Interpreted as	      b
	 __________   __________   _______________	      b
	 c_filedata   c_filesize	data		      b

 22 10.3.1.1  Header						  b
 23 For each file in the archive, a header as defined above	 b
 24 shall be written.  The information in the header fields	 b
 25 shall be written as streams of bytes interpreted as octal	 b
 26 numbers and shall be right-justified and zero filled.  The	 b
 27 fields shall be interpreted as follows:			 b

 28    o+ c_magic shall identify the archive as being a	   b
 29	 transportable archive by containing the magic bytes as	 b
 30	 defined by MAGIC ("070707").				 b

 31    o+ c_dev and c_ino shall contain values which uniquely	   b
 32	 identify the file within the archive (i.e., no files	 b
 33	 shall contain the same pair of c_dev and c_ino values	 b
 34	 unless they are links to the same file).  The values	 b
 35	 shall be determined in an implementation defined	 b
 36	 manner.						 b

 37    o+ c_mode shall contain the file type and access	   b
 38	 permissions as defined in the tables below.		 b



      UNAPPROVED DRAFT.	 All Rights Reserved by IEEE.
   Do not specify or claim conformance to this document.







FOR COMPUTER ENVIRONMENTS		Std 1003.1-Draft 11



 39    o+ c_uid shall contain the user id of the owner.	   b

 40    o+ c_gid shall contain the group id of the group.	   b

 41    o+ c_nlink shall contain the number of links referencing   b
 42	 the file at the time the archive was created.		 b

 43    o+ c_rdev shall contain implementation defined information b
 44	 for character or block special files.			 b

 45    o+ c_mtime shall contain the latest time of modification   b
 46	 of the file.						 b

 47    o+ c_namesize shall contain the length of the path name,   b
 48	 including the terminating null byte.			 b

 49    o+ c_filesize shall contain the length of the file.  This  b
 50	 is the length of the data section following the header	 b
 51	 structure.						 b

 52 10.3.1.2  File Name						  b
 53 c_name shall contain the path name of the file. The length	 b
 54 of the name is determined by c_namesize; the maximum length	 b
 55 of this string is 256 bytes.				 b

 56 10.3.1.3  File Data						  b
 57 Following c_name, there shall be c_filesize bytes of data.	 b
 58 Interpretation of such data shall occur in a manner		 b
 59 dependent on the file.  If c_filesize is zero, no data shall b
 60 be contained in c_filedata.					 b

 61 10.3.1.4  Special Entries					  b
 62 Special files, directories, and the trailer are recorded	 b
 63 with c_filesize equal to zero.  The header for the next file b
 64 entry in the archive shall be written directly after the	 b
 65 last byte of the file entry preceding it.  A header denoting b
 66 the file name ``TRAILER!!!'' shall indicate the end of the	 b
 67 archive; the contents of bytes in the last block of the	 b
 68 archive following such a header are undefined.		 b

 69 10.3.1.5  cpio Values					  b
 70 Values needed by the cpio archive format are described as	 b
 71 follows:							 b






      UNAPPROVED DRAFT.	 All Rights Reserved by IEEE.
   Do not specify or claim conformance to this document.







Std 1003.1-Draft 11		   PORTABLE OPERATING SYSTEM



		  Values for c_mode field		      b
		     File permissions			      b
	    Name     Value	  Indicates		      b
	   _______   ______   __________________	      b
	   C_IRUSR   000400   read by owner		      b
	   C_IWUSR   000200   write by owner		      b
	   C_IXUSR   000100   execute by owner		      b
	   C_IRGRP   000040   read by group		      b
	   C_IWGRP   000020   write by group		      b
	   C_IXGRP   000010   execute by group		      b
	   C_IROTH   000004   read by others		      b
	   C_IWOTH   000002   write by others		      b
	   C_IXOTH   000001   execute by others		      b
	   C_ISUID   004000   set uid			      b
	   C_ISGID   002000   set gid			      b
	   C_ISVTX   001000   reserved			      b



		  Values for c_mode field		      b
			 File type			      b
	     Name     Value	   Indicates		      b
	   ________   ______   _________________	      b
	   C_ISDIR    040000   directory		      b
	   C_ISFIFO   010000   FIFO			      b
	   C_ISREG    100000   regular file		      b
	   C_ISBLK    060000   block special		      b
	   C_ISCHR    020000   character special	      b
		      110000   reserved			      b
		      120000   reserved			      b
		      140000   reserved			      b

101 C_ISDIR, C_ISFIFO, and C_ISREG shall be supported on a POSIX b
102 conforming system; additional values defined above are	 b
103 reserved for compatibility with existing systems.		 b
104 Additional file types may be supported; however, such files	 b
105 should not be written on archives intended for transport to	 b
106 portable systems.						 b

107 10.3.1.6  References					  b
108 <grp.h> sS9.2.1, <pwd.h> sS9.2.2, <sys/stat.h> sS5.6.1, chmod() b
109 sS5.6.4, link() sS5.3.4, mkdir() sS5.4.1, read() sS6.4.1, stat() b
110 sS5.6.2.
111





      UNAPPROVED DRAFT.	 All Rights Reserved by IEEE.
   Do not specify or claim conformance to this document.







Volume-Number: Volume 12, Number 12