Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dsoprea/go-ext4
A pure Go implementation of an ext4 reader with journaling support that does not require the kernel nor privileged access.
https://github.com/dsoprea/go-ext4
ext4 ext4-filesystem go golang
Last synced: 1 day ago
JSON representation
A pure Go implementation of an ext4 reader with journaling support that does not require the kernel nor privileged access.
- Host: GitHub
- URL: https://github.com/dsoprea/go-ext4
- Owner: dsoprea
- License: mit
- Created: 2018-09-17T08:48:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-06T22:41:58.000Z (8 months ago)
- Last Synced: 2024-06-18T18:44:18.742Z (4 months ago)
- Topics: ext4, ext4-filesystem, go, golang
- Language: Go
- Homepage: https://godoc.org/github.com/dsoprea/go-ext4
- Size: 1010 KB
- Stars: 43
- Watchers: 4
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/dsoprea/go-ext4.svg?branch=master)](https://travis-ci.org/dsoprea/go-ext4)
[![Coverage Status](https://coveralls.io/repos/github/dsoprea/go-ext4/badge.svg?branch=master)](https://coveralls.io/github/dsoprea/go-ext4?branch=master)
[![GoDoc](https://godoc.org/github.com/dsoprea/go-ext4?status.svg)](https://godoc.org/github.com/dsoprea/go-ext4)## 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 := InodeRootDirectoryfilepath := 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
// directory1/fortune2: DirectoryEntry
// directory1/fortune5: DirectoryEntry
// directory1/fortune6: DirectoryEntry
// directory1/subdirectory1/fortune3: DirectoryEntry
// directory1/subdirectory1/fortune4: DirectoryEntry
// directory1/subdirectory1: DirectoryEntry
// directory1/subdirectory2/fortune7: DirectoryEntry
// directory1/subdirectory2/fortune8: DirectoryEntry
// directory1/subdirectory2: DirectoryEntry
// directory1: DirectoryEntry
// directory2/fortune10: DirectoryEntry
// directory2/fortune9: DirectoryEntry
// directory2: DirectoryEntry
// lost+found: DirectoryEntry
// thejungle.txt: DirectoryEntry
```This example and others are documented [here](https://godoc.org/github.com/dsoprea/go-ext4#pkg-examples).
## Notes
- Modern filesystems are supported, including both 32-bit and 64-bit addressing. Obscure filesystem options may not be compatible. See the [compatibility assertions](https://github.com/dsoprea/go-ext4/blob/master/superblock.go) 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.