Categorygithub.com/dsoprea/go-ext4
modulepackage
0.0.0-20190528173430-c13b09fc0ff8
Repository: https://github.com/dsoprea/go-ext4.git
Documentation: pkg.go.dev

# README

Build Status Coverage Status GoDoc

Overview

This package allows you to browse an ext4 filesystem directly. It does not use FUSE or touch the kernel, so no privileges are required.

This package also exposes the data in the journal (if one is available).

Example

Recursively walk all of the files in the filesystem:

inodeNumber := InodeRootDirectory

filepath := path.Join(assetsPath, "hierarchy_32.ext4")

f, err := os.Open(filepath)
log.PanicIf(err)

defer f.Close()

_, err = f.Seek(Superblock0Offset, io.SeekStart)
log.PanicIf(err)

sb, err := NewSuperblockWithReader(f)
log.PanicIf(err)

bgdl, err := NewBlockGroupDescriptorListWithReadSeeker(f, sb)
log.PanicIf(err)

bgd, err := bgdl.GetWithAbsoluteInode(inodeNumber)
log.PanicIf(err)

dw, err := NewDirectoryWalk(f, bgd, inodeNumber)
log.PanicIf(err)

allEntries := make([]string, 0)

for {
	fullPath, de, err := dw.Next()
	if err == io.EOF {
		break
	} else if err != nil {
		log.Panic(err)
	}

	description := fmt.Sprintf("%s: %s", fullPath, de.String())
	allEntries = append(allEntries, description)
}

sort.Strings(allEntries)

for _, entryDescription := range allEntries {
	fmt.Println(entryDescription)
}

// Output:
//
// directory1/fortune1: DirectoryEntry<NAME=[fortune1] INODE=(15) TYPE=[regular]-(1)>
// directory1/fortune2: DirectoryEntry<NAME=[fortune2] INODE=(14) TYPE=[regular]-(1)>
// directory1/fortune5: DirectoryEntry<NAME=[fortune5] INODE=(20) TYPE=[regular]-(1)>
// directory1/fortune6: DirectoryEntry<NAME=[fortune6] INODE=(21) TYPE=[regular]-(1)>
// directory1/subdirectory1/fortune3: DirectoryEntry<NAME=[fortune3] INODE=(17) TYPE=[regular]-(1)>
// directory1/subdirectory1/fortune4: DirectoryEntry<NAME=[fortune4] INODE=(18) TYPE=[regular]-(1)>
// directory1/subdirectory1: DirectoryEntry<NAME=[subdirectory1] INODE=(16) TYPE=[directory]-(2)>
// directory1/subdirectory2/fortune7: DirectoryEntry<NAME=[fortune7] INODE=(22) TYPE=[regular]-(1)>
// directory1/subdirectory2/fortune8: DirectoryEntry<NAME=[fortune8] INODE=(23) TYPE=[regular]-(1)>
// directory1/subdirectory2: DirectoryEntry<NAME=[subdirectory2] INODE=(19) TYPE=[directory]-(2)>
// directory1: DirectoryEntry<NAME=[directory1] INODE=(13) TYPE=[directory]-(2)>
// directory2/fortune10: DirectoryEntry<NAME=[fortune10] INODE=(26) TYPE=[regular]-(1)>
// directory2/fortune9: DirectoryEntry<NAME=[fortune9] INODE=(25) TYPE=[regular]-(1)>
// directory2: DirectoryEntry<NAME=[directory2] INODE=(24) TYPE=[directory]-(2)>
// lost+found: DirectoryEntry<NAME=[lost+found] INODE=(11) TYPE=[directory]-(2)>
// thejungle.txt: DirectoryEntry<NAME=[thejungle.txt] INODE=(12) TYPE=[regular]-(1)>

This example and others are documented here.

Notes

  • Modern filesystems are supported, including both 32-bit and 64-bit addressing. Obscure filesystem options may not be compatible. See the compatibility assertions in NewSuperblockWithReader.
    • 64-bit addressing should be fine, as the high addressing should likely be zero when 64-bit addressing is turned-off (which is primarily what our unit-tests test with). However, the available documentation is limited on the subject. It's specifically not clear which of the various high/low addresses are affected by the 64-bit mode.

To Do

  • Finish implementing checksum calculation and validation. Currently all checksums are readable but with no additional functionality.

# Packages

No description provided by the author

# Functions

No description provided by the author
GetTestInode returns a test inode struct and `os.File` for the file.
NewBlockGroupDescriptorListWithReadSeeker returns a `BlockGroupDescriptorsList`, which has all block-group-descriptors in a big slice.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
File types.
File types.
File types.
File types.
File types.
File types.
File types.
File types.
Reserved inodes.
Reserved inodes.
Reserved inodes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Reserved inodes.
Reserved inodes.
Reserved inodes.
Reserved inodes.
Reserved inodes.
Reserved inodes.
Reserved inodes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
COMPAT_DIR_INDEX.
COMPAT_DIR_PREALLOC.
COMPAT_EXCLUDE_BITMAP.
COMPAT_EXCLUDE_INODE.
COMPAT_EXT_ATTR.
COMPAT_HAS_JOURNAL.
COMPAT_IMAGIC_INODES.
COMPAT_LAZY_BG.
COMPAT_RESIZE_INODE.
COMPAT_SPARSE_SUPER2.
INCOMPAT_64BIT.
INCOMPAT_COMPRESSION.
INCOMPAT_CSUM_SEED.
INCOMPAT_DIRDATA.
INCOMPAT_ENCRYPT.
extents support */.
INCOMPAT_FILETYPE.
INCOMPAT_FLEX_BG.
INCOMPAT_INLINE_DATA.
Journal device */.
INCOMPAT_LARGEDIR.
INCOMPAT_EA_INODE.
INCOMPAT_META_BG.
INCOMPAT_MMP.
Needs recovery */.
RO_COMPAT_BIGALLOC.
RO_COMPAT_BTREE_DIR.
RO_COMPAT_DIR_NLINK.
RO_COMPAT_EXTRA_ISIZE.
RO_COMPAT_GDT_CSUM.
RO_COMPAT_HAS_SNAPSHOT.
RO_COMPAT_HUGE_FILE.
RO_COMPAT_LARGE_FILE.
RO_COMPAT_METADATA_CSUM.
RO_COMPAT_PROJECT.
RO_COMPAT_QUOTA.
RO_COMPAT_READONLY.
RO_COMPAT_REPLICA.
RO_COMPAT_SPARSE_SUPER.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The first superblock is after the bootloader code.
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SbFeatureCompatNames is an ordered list of names.
No description provided by the author
SbFeatureIncompatNames is an ordered list of names.
No description provided by the author
SbFeatureRoCompatNames is an ordered list of names.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
DirectoryBrowser provides high-level directory navigation.
DirectoryEntry wraps the raw directory entry and provides higher-level functionality.
DirectoryWalk provides full directory-structure recursion.
Ext4DirEntry2 is one of potentially many sequential entries stored in a directory inode.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
InodeReader fulfills the `io.Reader` interface to read arbitrary amounts of data.
No description provided by the author
No description provided by the author