Documentation
¶
Index ¶
- Constants
- Variables
- func Extract(rs io.Reader, dest string) error
- type CpioEntry
- type CpioStream
- type Cpio_newc_header
- func (hdr *Cpio_newc_header) Check() int
- func (hdr *Cpio_newc_header) Devmajor() int
- func (hdr *Cpio_newc_header) Devminor() int
- func (hdr *Cpio_newc_header) Filename() string
- func (hdr *Cpio_newc_header) Filesize() int
- func (hdr *Cpio_newc_header) Filesize64() int64
- func (hdr *Cpio_newc_header) Gid() int
- func (hdr *Cpio_newc_header) Index() int
- func (hdr *Cpio_newc_header) Ino() int
- func (hdr *Cpio_newc_header) IsStripped() bool
- func (hdr *Cpio_newc_header) Magic() string
- func (hdr *Cpio_newc_header) Mode() int
- func (hdr *Cpio_newc_header) Mtime() int
- func (hdr *Cpio_newc_header) Namesize() int
- func (hdr *Cpio_newc_header) Nlink() int
- func (hdr *Cpio_newc_header) Rdevmajor() int
- func (hdr *Cpio_newc_header) Rdevminor() int
- func (hdr *Cpio_newc_header) Uid() int
- type Reader
Constants ¶
const ( S_ISUID = 04000 // Set uid S_ISGID = 02000 // Set gid S_ISVTX = 01000 // Save text (sticky bit) S_ISDIR = 040000 // Directory S_ISFIFO = 010000 // FIFO S_ISREG = 0100000 // Regular file S_ISLNK = 0120000 // Symbolic link S_ISBLK = 060000 // Block special file S_ISCHR = 020000 // Character special file S_ISSOCK = 0140000 // Socket )
Standard set of permission bit masks.
const TRAILER = "TRAILER!!!"
TRAILER is the filename found on the last entry of a cpio archive
Variables ¶
var ErrStrippedHeader = errors.New("invalid cpio header: rpm-style stripped cpio requires supplemental size info")
ErrStrippedHeader indicates that a RPM-style archive was read without calling SetFileSizes()
Functions ¶
Types ¶
type CpioEntry ¶
type CpioEntry struct { Header *Cpio_newc_header // contains filtered or unexported fields }
CpioEntry points to a single file within a cpio stream
type CpioStream ¶
type CpioStream struct {
// contains filtered or unexported fields
}
CpioStream reads file metadata and contents from a cpio archive
func NewCpioStream ¶
func NewCpioStream(stream io.Reader) *CpioStream
NewCpioStream starts reading files from a cpio archive
func (*CpioStream) ReadNextEntry ¶
func (cs *CpioStream) ReadNextEntry() (*CpioEntry, error)
ReadNextEntry returns the metadata of the next file in the archive.
The final file in the archive can be detected by checking for a Filename of TRAILER.
func (*CpioStream) SetFileSizes ¶
func (cs *CpioStream) SetFileSizes(sizes []int64)
SetFileSizes provides supplemental file size info so that RPMs with files > 4GiB can be read
type Cpio_newc_header ¶
type Cpio_newc_header struct {
// contains filtered or unexported fields
}
Cpio_newc_header is the raw header of a newc-style cpio archive
func (*Cpio_newc_header) Check ¶
func (hdr *Cpio_newc_header) Check() int
Check returns the checksum of the entry, if present
func (*Cpio_newc_header) Devmajor ¶
func (hdr *Cpio_newc_header) Devmajor() int
Devmajor returns the major device number of a character or block device
func (*Cpio_newc_header) Devminor ¶
func (hdr *Cpio_newc_header) Devminor() int
Devminor returns the minor device number of a character or block device
func (*Cpio_newc_header) Filename ¶
func (hdr *Cpio_newc_header) Filename() string
Filename returns the name of the file entry
func (*Cpio_newc_header) Filesize ¶
func (hdr *Cpio_newc_header) Filesize() int
Filesize returns the size of the file in bytes
func (*Cpio_newc_header) Filesize64 ¶
func (hdr *Cpio_newc_header) Filesize64() int64
Filesize64 contains the file's size as a 64-bit integer, coming from either SetFileSizes() if used or from the regular cpio file entry
func (*Cpio_newc_header) Gid ¶
func (hdr *Cpio_newc_header) Gid() int
Gid returns the file's owner group ID
func (*Cpio_newc_header) Index ¶
func (hdr *Cpio_newc_header) Index() int
Index returns the position in the RPM header file info array corresponding to this file
func (*Cpio_newc_header) Ino ¶
func (hdr *Cpio_newc_header) Ino() int
Ino returns the inode number of the file
func (*Cpio_newc_header) IsStripped ¶
func (hdr *Cpio_newc_header) IsStripped() bool
IsStripped returns true if the file header is missing info that must come from the preceding RPM header
func (*Cpio_newc_header) Magic ¶
func (hdr *Cpio_newc_header) Magic() string
Magic returns the magic number preceding the file entry
func (*Cpio_newc_header) Mode ¶
func (hdr *Cpio_newc_header) Mode() int
Mode returns the file's permissions and file type
func (*Cpio_newc_header) Mtime ¶
func (hdr *Cpio_newc_header) Mtime() int
Mtime returns the file's modification time in seconds since the UNIX epoch
func (*Cpio_newc_header) Namesize ¶
func (hdr *Cpio_newc_header) Namesize() int
Namesize returns the length of the filename
func (*Cpio_newc_header) Nlink ¶
func (hdr *Cpio_newc_header) Nlink() int
Nlink returns the number of hardlinks to the file
func (*Cpio_newc_header) Rdevmajor ¶
func (hdr *Cpio_newc_header) Rdevmajor() int
Rdevmajor returns the major device number of a character or block device
func (*Cpio_newc_header) Rdevminor ¶
func (hdr *Cpio_newc_header) Rdevminor() int
Rdevminor returns the minor device number of a character or block device
func (*Cpio_newc_header) Uid ¶
func (hdr *Cpio_newc_header) Uid() int
Uid returns the file's owner user ID
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader accesses a cpio archive stream using a simple interface similar to the archive/tar package
func NewReaderWithSizes ¶
NewReaderWithSizes starts reading a stripped cpio archive from a RPM payload using the provided file sizes
func (*Reader) Next ¶
func (r *Reader) Next() (*Cpio_newc_header, error)
Next returns the metadata of the next file in the archive, which can then be read with Read().
Returns io.EOF upon encountering the archive trailer.