Documentation ¶
Overview ¶
Package record defines interfaces for syscall records, executor and encoder/decoder. It also has implementations of all syscall records, gob encoder/decoder, and a common executor and the stdout executor.
Index ¶
- Constants
- func Send(rec Record, records chan<- Record, hf dlhash.Factory) error
- func VerifyChksum(rec Record, hf dlhash.Factory) (bool, error)
- type Chmod
- func (rec *Chmod) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Chmod) Exec(root string) error
- func (rec *Chmod) ExecType() ExecType
- func (rec *Chmod) FromBinary(src io.Reader) error
- func (rec *Chmod) Key() string
- func (rec *Chmod) SafeExec(root string) error
- func (rec *Chmod) String() string
- func (rec *Chmod) ToBinary(target io.Writer) error
- func (rec *Chmod) Type() Type
- type Chown
- func (rec *Chown) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Chown) Exec(root string) error
- func (rec *Chown) ExecType() ExecType
- func (rec *Chown) FromBinary(src io.Reader) error
- func (rec *Chown) Key() string
- func (rec *Chown) SafeExec(root string) error
- func (rec *Chown) String() string
- func (rec *Chown) ToBinary(target io.Writer) error
- func (rec *Chown) Type() Type
- type Create
- func (rec *Create) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Create) Exec(root string) error
- func (rec *Create) ExecType() ExecType
- func (rec *Create) FromBinary(src io.Reader) error
- func (rec *Create) Key() string
- func (rec *Create) SafeExec(root string) error
- func (rec *Create) String() string
- func (rec *Create) ToBinary(target io.Writer) error
- func (rec *Create) Type() Type
- type EOT
- func (rec *EOT) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *EOT) Exec(root string) error
- func (rec *EOT) ExecType() ExecType
- func (rec *EOT) FromBinary(src io.Reader) error
- func (rec *EOT) Key() string
- func (rec *EOT) String() string
- func (rec *EOT) ToBinary(target io.Writer) error
- func (rec *EOT) Type() Type
- type ExecType
- type Hardlink
- func (rec *Hardlink) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Hardlink) Exec(root string) error
- func (rec *Hardlink) ExecType() ExecType
- func (rec *Hardlink) FromBinary(src io.Reader) error
- func (rec *Hardlink) Key() string
- func (rec *Hardlink) String() string
- func (rec *Hardlink) ToBinary(target io.Writer) error
- func (rec *Hardlink) Type() Type
- type Hdr
- type Mkdir
- func (rec *Mkdir) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Mkdir) Exec(root string) error
- func (rec *Mkdir) ExecType() ExecType
- func (rec *Mkdir) FromBinary(src io.Reader) error
- func (rec *Mkdir) Key() string
- func (rec *Mkdir) SafeExec(root string) error
- func (rec *Mkdir) String() string
- func (rec *Mkdir) ToBinary(target io.Writer) error
- func (rec *Mkdir) Type() Type
- type Mknod
- func (rec *Mknod) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Mknod) Exec(root string) error
- func (rec *Mknod) ExecType() ExecType
- func (rec *Mknod) FromBinary(src io.Reader) error
- func (rec *Mknod) Key() string
- func (rec *Mknod) SafeExec(root string) error
- func (rec *Mknod) String() string
- func (rec *Mknod) ToBinary(target io.Writer) error
- func (rec Mknod) Type() Type
- type Pwrite
- func (rec *Pwrite) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Pwrite) Exec(root string) error
- func (rec *Pwrite) ExecType() ExecType
- func (rec *Pwrite) FromBinary(src io.Reader) error
- func (rec *Pwrite) Key() string
- func (rec *Pwrite) String() string
- func (rec *Pwrite) ToBinary(target io.Writer) error
- func (rec *Pwrite) Type() Type
- type Record
- func NewChmod(filepath string, mode os.FileMode) Record
- func NewChown(filepath string, uid int, gid int) Record
- func NewChownByNames(filepath string, uid string, gid string) Record
- func NewCreate(path string, mode os.FileMode) Record
- func NewEOT() Record
- func NewHardlink(oldname string, newname string) Record
- func NewMkdir(path string, mode os.FileMode) Record
- func NewMknod(filepath string, mode uint32, dev int) Record
- func NewPwrite(path string, data []byte, offset uint64) Record
- func NewRemove(path string) Record
- func NewRename(oldpath string, newpath string) Record
- func NewRmXattr(path string, xattr string) Record
- func NewSetMtime(path string, mtime time.Time) Record
- func NewSetXattr(path string, xattr string, val []byte) Record
- func NewSymlink(oldname string, newname string) Record
- func NewTruncate(filepath string, size int64) Record
- type Remove
- func (rec *Remove) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Remove) Exec(root string) error
- func (rec *Remove) ExecType() ExecType
- func (rec *Remove) FromBinary(src io.Reader) error
- func (rec *Remove) Key() string
- func (rec *Remove) String() string
- func (rec *Remove) ToBinary(target io.Writer) error
- func (rec *Remove) Type() Type
- type Rename
- func (rec *Rename) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Rename) Exec(root string) error
- func (rec *Rename) ExecType() ExecType
- func (rec *Rename) FromBinary(src io.Reader) error
- func (rec *Rename) Key() string
- func (rec *Rename) String() string
- func (rec *Rename) ToBinary(target io.Writer) error
- func (rec *Rename) Type() Type
- type Rmxattr
- func (rec *Rmxattr) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Rmxattr) Exec(root string) error
- func (rec *Rmxattr) ExecType() ExecType
- func (rec *Rmxattr) FromBinary(src io.Reader) error
- func (rec *Rmxattr) Key() string
- func (rec *Rmxattr) SafeExec(root string) error
- func (rec *Rmxattr) String() string
- func (rec *Rmxattr) ToBinary(target io.Writer) error
- func (rec *Rmxattr) Type() Type
- type SafeRecord
- type Setmtime
- func (rec *Setmtime) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Setmtime) Exec(root string) error
- func (rec *Setmtime) ExecType() ExecType
- func (rec *Setmtime) FromBinary(src io.Reader) error
- func (rec *Setmtime) Key() string
- func (rec *Setmtime) String() string
- func (rec *Setmtime) ToBinary(target io.Writer) error
- func (rec *Setmtime) Type() Type
- type Setxattr
- func (rec *Setxattr) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Setxattr) Exec(root string) error
- func (rec *Setxattr) ExecType() ExecType
- func (rec *Setxattr) FromBinary(src io.Reader) error
- func (rec *Setxattr) Key() string
- func (rec *Setxattr) SafeExec(root string) error
- func (rec *Setxattr) String() string
- func (rec *Setxattr) ToBinary(target io.Writer) error
- func (rec *Setxattr) Type() Type
- type Symlink
- func (rec *Symlink) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Symlink) Exec(root string) error
- func (rec *Symlink) ExecType() ExecType
- func (rec *Symlink) FromBinary(src io.Reader) error
- func (rec *Symlink) Key() string
- func (rec *Symlink) String() string
- func (rec *Symlink) ToBinary(target io.Writer) error
- func (rec *Symlink) Type() Type
- type Truncate
- func (rec *Truncate) Chksum(hf dlhash.Factory) ([]byte, error)
- func (rec *Truncate) Exec(root string) error
- func (rec *Truncate) ExecType() ExecType
- func (rec *Truncate) FromBinary(src io.Reader) error
- func (rec *Truncate) Key() string
- func (rec *Truncate) String() string
- func (rec *Truncate) ToBinary(target io.Writer) error
- func (rec *Truncate) Type() Type
- type Type
Constants ¶
const ( // DefaultCreateMode - create file with these default permissions DefaultCreateMode os.FileMode = 0777 // XattrPrefix is a prefix that is used for safely storing file attributes and extended attributes // as extended attributes in the user namespace. XattrPrefix string = "user.com.clusterhq.attributes." )
const ( // AsyncExec is executed asynchronously(e.x. pwrie) AsyncExec ExecType = iota // SyncExec is executed synchronously(e.x. create dir) SyncExec // DelayExec is executed at the end of all asynchronous records are executed(e.x. setmtime) DelayExec // TypeMkdir defines the type ID TypeMkdir Type = iota // TypePwrite defines the type ID TypePwrite // TypeHardlink defines the type ID TypeHardlink // TypeSymlink defines the type ID TypeSymlink // TypeTruncate defines the type ID TypeTruncate // TypeChown defines the type ID TypeChown // TypeCreate defines the type ID TypeCreate // TypeRemove defines the type ID TypeRemove // TypeSetxattr defines the type ID TypeSetxattr // TypeRmxattr defines the type ID TypeRmxattr // TypeRename defines the type ID TypeRename // TypeMknod defines the type ID TypeMknod // TypeChmod defines the type ID TypeChmod // TypeSetmtime defines the type ID TypeSetmtime // TypeEOT defines the type ID TypeEOT )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chmod ¶
Chmod represents a record for chmod
func (*Chmod) FromBinary ¶
FromBinary is implementation of Record interface
type Chown ¶
type Chown struct { Hdr Path string UID string // XXX stored as a name, not ID GID string // XXX stored as a name, not ID }
Chown represents a record for doing a chown on a file TODO: might get absorbed into SETATTR record later
func (*Chown) FromBinary ¶
FromBinary is implementation of Record interface
type Create ¶
Create represents a record for create/open/mkfile
func (*Create) Exec ¶
Exec is implementation of Record interface Creates a new file. Corresponds to 'touch' or 'mkfile', etc.
func (*Create) FromBinary ¶
FromBinary is implementation of Record interface
func (*Create) SafeExec ¶
SafeExec is implementation of Record interface Creates a new file. Corresponds to 'touch' or 'mkfile', etc.
type EOT ¶
EOT represents a special record which does nothing to the file system but indicates the end of a transfer
func (*EOT) FromBinary ¶
FromBinary is implementation of Record interface
type Hardlink ¶
Hardlink represents a record for link
func (*Hardlink) FromBinary ¶
FromBinary is implementation of Record interface
type Hdr ¶
type Hdr struct {
Chksum []byte
}
Hdr has common fields for all records. Note: Export Hdr and Chksum because of GOB.
type Mkdir ¶
Mkdir represents a record for mkdir Note: All record type can be unexported, but GOB needs to register them, so they are exported. Note: All fields are exported because gob only encodes exported fields
func (*Mkdir) FromBinary ¶
FromBinary is implementation of Record interface
type Mknod ¶
Mknod represent a record for mknod
func (*Mknod) FromBinary ¶
FromBinary is implementation of Record interface
type Pwrite ¶
type Pwrite struct { Hdr Path string Data []byte Offset uint64 Mode os.FileMode // always zero, kept for compatibility }
Pwrite represents a record for pwrite
func (*Pwrite) FromBinary ¶
FromBinary is implementation of Record interface
type Record ¶
type Record interface { Exec(root string) error String() string // Key returns a string that can be used to group records that belong to the same object(for example, file path) Key() string // ExeType returns the execution type of a record ExecType() ExecType // Type returns the type of a record Type() Type // ToBinary is the binary encoder which writes the record in binary format ToBinary(io.Writer) error // FromBinary reads the record from an encode source and populates the record with the data read from the source FromBinary(io.Reader) error // Chksum returns the checksum of a record. // Note: It doesn't set the record's checksum field, so it can be used to recalculate the checksum for // verification. Chksum(dlhash.Factory) ([]byte, error) // SetChksum sets the record's checksum SetChksum([]byte) // GetChksum returns the record's checksum GetChksum() []byte }
Record defines the function signature for all the common methods implemented for each record type
func NewChownByNames ¶
NewChownByNames returns an record object of type chown from the parameters.
func NewHardlink ¶
NewHardlink returns an record object of type hardlink from the parameters.
func NewRmXattr ¶
NewRmXattr returns an record object of type rmxattr from the parameters.
func NewSetMtime ¶
NewSetMtime returns a record object of type setmtime
func NewSetXattr ¶
NewSetXattr returns an record object of type setxattr from the parameters.
func NewSymlink ¶
NewSymlink returns an record object of type symlink from the parameters.
func NewTruncate ¶
NewTruncate returns an record object of type truncate from the parameters.
type Remove ¶
Remove represents a record for removal of file or directory
func (*Remove) FromBinary ¶
FromBinary is implementation of Record interface
type Rename ¶
Rename represents a record for rename
func (*Rename) FromBinary ¶
FromBinary is implementation of Record interface
type Rmxattr ¶
Rmxattr represents a record for removing extended attribute
func (*Rmxattr) FromBinary ¶
FromBinary is implementation of Record interface
type SafeRecord ¶
SafeRecord is a subtype of Record that has a method for faking security-sensitive operations.
type Setmtime ¶
Setmtime represents a record for modify time
func (*Setmtime) FromBinary ¶
FromBinary is implementation of Record interface
type Setxattr ¶
Setxattr represents a record for setting extended attribute
func (*Setxattr) FromBinary ¶
FromBinary is implementation of Record interface
type Symlink ¶
Symlink represents a record for creation of a symlink
func (*Symlink) Exec ¶
Exec is implementation of Record interface Note: code executing this needs to have appropriate permissions (s.a. be run as superuser)
func (*Symlink) FromBinary ¶
FromBinary is implementation of Record interface
type Truncate ¶
Truncate represents a record for truncation of a file
func (*Truncate) FromBinary ¶
FromBinary is implementation of Record interface