Documentation
¶
Index ¶
- Constants
- Variables
- func DumpBytes(data []byte)
- func GetJournalInode(filepath string) (f *os.File, inode *ext4.Inode, err error)
- func ReadExactly(r io.Reader, buffer []byte) (err error)
- type JournalBlock
- type JournalBlockTag32NoCsumV3
- type JournalCommitBlock
- type JournalCommitBlockData
- type JournalCommonBlockType
- type JournalDescriptorBlock
- type JournalHeader
- type JournalRevokeBlock
- type JournalRevokeBlock32Data
- type JournalSuperblock
- func (jsb *JournalSuperblock) Data() *JournalSuperblockData
- func (jsb *JournalSuperblock) Dump()
- func (jsb *JournalSuperblock) DumpFeatures(includeFalses bool)
- func (jsb *JournalSuperblock) HasCompatibleFeature(mask uint32) bool
- func (jsb *JournalSuperblock) HasIncompatibleFeature(mask uint32) bool
- func (jsb *JournalSuperblock) NextBlock(r io.Reader) (jb JournalBlock, err error)
- type JournalSuperblockData
Constants ¶
const ( JbtfDataMatchesMagicBytes = uint16(0x1) // On-disk block is escaped. The first four bytes of the data block just happened to match the jbd2 magic number. JbtfSameUuidAsPrevious = uint16(0x2) // This block has the same UUID as previous, therefore the UUID field is omitted. JbtfDeleted = uint16(0x4) // The data block was deleted by the transaction. (Not used?) JbtfLastTag = uint16(0x8) // This is the last tag in this descriptor block. )
Descriptor block tag record flags.
const ( JournalBlockHeaderMagicBytes = uint32(0xc03b3998) JournalHeaderSize = 12 )
const ( BtDescriptor = uint32(1) // Descriptor. This block precedes a series of data blocks that were written through the journal during a transaction. BtBlockCommitRecord = uint32(2) // Block commit record. This block signifies the completion of a transaction. BtJournalSuperblockV1 = uint32(3) // Journal superblock, v1. BtJournalSuperblockV2 = uint32(4) // Journal superblock, v2. BtBlockRevocationRecord = uint32(5) // Block revocation records. This speeds up recovery by enabling the journal to skip writing blocks that were subsequently rewritten. )
Block types
const ( // JBD2_FEATURE_INCOMPAT_REVOKE JsbFeatureIncompatRevoke = uint32(0x1) // Journal has block revocation records. // JBD2_FEATURE_INCOMPAT_64BIT JsbFeatureIncompat64bit = uint32(0x2) // Journal can deal with 64-bit block numbers. // JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT JsbFeatureIncompatAsyncCommit = uint32(0x4) // Journal commits asynchronously. // JBD2_FEATURE_INCOMPAT_CSUM_V2 JsbFeatureIncompatCsumV2 = uint32(0x8) // This journal uses v2 of the checksum on-disk format. Each journal metadata block gets its own checksum, and the block tags in the descriptor table contain checksums for each of the data blocks in the journal. // JBD2_FEATURE_INCOMPAT_CSUM_V3 JsbFeatureIncompatCsumV3 = uint32(0x10) // This journal uses v3 of the checksum on-disk format. This is the same as v2, but the journal block tag size is fixed regardless of the size of block numbers. )
Journal superblock "incomp" features.
const ( JccCrc32 = uint8(1) JccMd5 = uint8(2) JccSha1 = uint8(3) JccCrc32c = uint8(4) )
Journal checksum codes
const (
// JBD2_CHECKSUM_BYTES
Jbd2ChecksumBytes = 8
)
const ( // JBD2_FEATURE_COMPAT_CHECKSUM JsbFeatureCompatChecksum = uint32(0x1) )
Journal superblock "compat" features.
Variables ¶
var ( BlocktypeLookup = map[uint32]string{ BtDescriptor: "descriptor", BtBlockCommitRecord: "block commit record", BtJournalSuperblockV1: "journal superblock v1", BtJournalSuperblockV2: "journal superblock v2", BtBlockRevocationRecord: "block revocation record", } )
var ( JsbFeatureCompatLookup = map[uint32]string{ JsbFeatureCompatChecksum: "checksum", } )
var ( JsbFeatureIncompatLookup = map[uint32]string{ JsbFeatureIncompatRevoke: "revoke", JsbFeatureIncompat64bit: "64bit", JsbFeatureIncompatAsyncCommit: "asynccommit", JsbFeatureIncompatCsumV2: "csumv2", JsbFeatureIncompatCsumV3: "csumv3", } )
Functions ¶
func GetJournalInode ¶
GetJournalInode returns inode and file structs. It's the responsibility of the caller to close it.
Types ¶
type JournalBlock ¶
type JournalBlock interface {
Type() uint32
String() string
Header() *JournalHeader
}
type JournalBlockTag32NoCsumV3 ¶
type JournalBlockTag32NoCsumV3 struct {
// 0x0
TBlocknr uint32 // Lower 32-bits of the location of where the corresponding data block should end up on disk.
// 0x4
TChecksum uint16 // Checksum of the journal UUID, the sequence number, and the data block. Note that only the lower 16 bits are stored.
// 0x6
TFlags uint16 // Flags that go with the descriptor. See the table jbd2_tag_flags for more info.
// 0x8 or 0xC
// This field appears to be open coded. It always comes at the end of the tag, after t_flags or t_blocknr_high. This field is not present if the “same UUID” flag is set.
Uuid [16]byte // A UUID to go with this tag. This field appears to be copied from the j_uuid field in struct journal_s, but only tune2fs touches that field.
}
JournalBlockTag32NoCsumV3 (journal_block_tag_s struct) is a subelement of the descriptor block.
func (*JournalBlockTag32NoCsumV3) String ¶
func (jbtnc3 *JournalBlockTag32NoCsumV3) String() string
type JournalCommitBlock ¶
type JournalCommitBlock struct {
JournalCommonBlockType
// contains filtered or unexported fields
}
func (*JournalCommitBlock) CommitTime ¶
func (jcb *JournalCommitBlock) CommitTime() time.Time
func (*JournalCommitBlock) Data ¶
func (jcb *JournalCommitBlock) Data() *JournalCommitBlockData
func (*JournalCommitBlock) String ¶
func (jcb *JournalCommitBlock) String() string
func (*JournalCommitBlock) Type ¶
func (*JournalCommitBlock) Type() uint32
type JournalCommitBlockData ¶
type JournalCommitBlockData struct {
// 0xC
HChksumType uint8 // The type of checksum to use to verify the integrity of the data blocks in the transaction. See jbd2_checksum_type for more info.
// 0xD
HChksumSize uint8 // The number of bytes used by the checksum. Most likely 4.
// 0xE
HPadding [2]byte
// 0x10
HChksum [Jbd2ChecksumBytes]uint32 // 32 bytes of space to store checksums. If JBD2_FEATURE_INCOMPAT_CSUM_V2 or JBD2_FEATURE_INCOMPAT_CSUM_V3 are set, the first __be32 is the checksum of the journal UUID and the entire commit block, with this field zeroed. If JBD2_FEATURE_COMPAT_CHECKSUM is set, the first __be32 is the crc32 of all the blocks already written to the transaction.
// 0x30
HCommitSec uint64 // The time that the transaction was committed, in seconds since the epoch.
// 0x38
HCommitNsec uint32 // Nanoseconds component of the above timestamp.
}
JournalCommitBlock (commit_header struct) indicates that a transaction has been completely written to the journal.
type JournalCommonBlockType ¶
type JournalCommonBlockType struct {
// contains filtered or unexported fields
}
func (*JournalCommonBlockType) Header ¶
func (jcbt *JournalCommonBlockType) Header() *JournalHeader
func (*JournalCommonBlockType) SetHeader ¶
func (jcbt *JournalCommonBlockType) SetHeader(jh *JournalHeader)
type JournalDescriptorBlock ¶
type JournalDescriptorBlock struct {
Tags []JournalBlockTag32NoCsumV3
JournalCommonBlockType
// contains filtered or unexported fields
}
JournalDescriptorBlock is a top-level journal block-type that describes where the data is supposed to go on disk.
func (*JournalDescriptorBlock) Dump ¶
func (jdb *JournalDescriptorBlock) Dump()
func (*JournalDescriptorBlock) SetTransactionData ¶
func (jdb *JournalDescriptorBlock) SetTransactionData(transactionData []byte)
func (*JournalDescriptorBlock) String ¶
func (jdb *JournalDescriptorBlock) String() string
func (*JournalDescriptorBlock) Type ¶
func (*JournalDescriptorBlock) Type() uint32
type JournalHeader ¶
JournalHeader (journal_header_s) is at the beginning of every block.
func (*JournalHeader) Dump ¶
func (jh *JournalHeader) Dump()
func (JournalHeader) String ¶
func (jh JournalHeader) String() string
type JournalRevokeBlock ¶
type JournalRevokeBlock struct {
JournalCommonBlockType
// contains filtered or unexported fields
}
func (*JournalRevokeBlock) Data ¶
func (jrb *JournalRevokeBlock) Data() *JournalRevokeBlock32Data
func (*JournalRevokeBlock) String ¶
func (jrb *JournalRevokeBlock) String() string
func (*JournalRevokeBlock) Type ¶
func (*JournalRevokeBlock) Type() uint32
type JournalRevokeBlock32Data ¶
type JournalRevokeBlock32Data struct {
// 0xC
RCount uint32 // Number of bytes used in this block.
// 0x10
Blocks []uint32 // Blocks to revoke.
}
JournalRevokeBlock32Data (jbd2_journal_revoke_header_s struct) is top-level journal block-type.
type JournalSuperblock ¶
type JournalSuperblock struct {
// contains filtered or unexported fields
}
func NewJournalSuperblock ¶
func NewJournalSuperblock(r io.Reader) (jsb *JournalSuperblock, err error)
func (*JournalSuperblock) Data ¶
func (jsb *JournalSuperblock) Data() *JournalSuperblockData
func (*JournalSuperblock) Dump ¶
func (jsb *JournalSuperblock) Dump()
func (*JournalSuperblock) DumpFeatures ¶
func (jsb *JournalSuperblock) DumpFeatures(includeFalses bool)
func (*JournalSuperblock) HasCompatibleFeature ¶
func (jsb *JournalSuperblock) HasCompatibleFeature(mask uint32) bool
func (*JournalSuperblock) HasIncompatibleFeature ¶
func (jsb *JournalSuperblock) HasIncompatibleFeature(mask uint32) bool
func (*JournalSuperblock) NextBlock ¶
func (jsb *JournalSuperblock) NextBlock(r io.Reader) (jb JournalBlock, err error)
type JournalSuperblockData ¶
type JournalSuperblockData struct {
/* 0x0000 */
SHeader JournalHeader
/* 0x000C */
/* Static information describing the journal */
SBlocksize uint32 /* journal device blocksize */
SMaxlen uint32 /* total blocks in journal file */
SFirst uint32 /* first block of log information */
/* 0x0018 */
/* Dynamic information describing the current state of the log */
SSequence uint32 /* first commit ID expected in log */
SStart uint32 /* blocknr of start of log */
/* 0x0020 */
/* Error value, as set by jbd2_journal_abort(). */
SErrno uint32
/* 0x0024 */
/* Remaining fields are only valid in a version-2 superblock */
SFeatureCompat uint32 /* compatible feature set */
SFeatureIncompat uint32 /* incompatible feature set */
SFeatureRoCompat uint32 /* readonly-compatible feature set */
/* 0x0030 */
SUuid [16]uint8 /* 128-bit uuid for journal */
/* 0x0040 */
SNrUsers uint32 /* Nr of filesystems sharing log */
SDynsuper uint32 /* Blocknr of dynamic superblock copy*/
/* 0x0048 */
SMaxTransaction uint32 /* Limit of journal blocks per trans.*/
SMaxTransData uint32 /* Limit of data blocks per trans. */
/* 0x0050 */
SChecksumType uint8 /* checksum type */
SPadding2 [3]uint8
SPadding [42]uint32
SChecksum uint32 /* crc32c(superblock) */
/* 0x0100 */
SUsers [16 * 48]uint8 /* ids of all fs'es sharing the log */
}