tarfs

package module
v0.0.0-...-3688591 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2018 License: MIT Imports: 15 Imported by: 0

README

tarfs

Tarfs is a library for implementing fuse-based filesystems for tar files. This is currently purely experimental, do not use for real workloads.

Usage

f, _ := os.Open("foo.tar")
db := tarfs.NewBTreeStore(n)
server := tarfs.FromFile(f, db)

See cmd/tarfsd as an example implementation.

TODO(non-exhaustive):

  • Not quite happy with the metadata storage, consider alternatives specifically around how directory entries are stored and fetched.
  • Support writes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFile

func FromFile(f *os.File, db MetadataStore) (pathfs.FileSystem, error)

FromFile takes the passed in tar file and creates a new tarfs server Metadata from the tarfile is stored in the metadata store, which is used as the backing store for the tarfs server. The passed in file must not be acessed or modified while the server is active.

func FromReaderAt

func FromReaderAt(ra io.ReaderAt, size int64, db MetadataStore) (pathfs.FileSystem, error)

FromReaderAt creates a new tarfs server from io.ReaderAt. The size of the tar archive needs to be provided. Metadata from the tarfile is stored in the metadata store, which is used as the backing store for the tarfs server.

func Newserver

func Newserver(db MetadataStore, tarStream io.ReaderAt) pathfs.FileSystem

Newserver creates a new tarfs server from the passed in metadata store. The passed in metadata store should be pre-populated with filesystem metadata. See `FromFile` as an example of this.

Types

type DirIndex

type DirIndex interface {
	Entries() []FileInfo
}

DirIndex is an interface which can be implemented by a FileInfo for the purpose of retreiving directory entries directly from the dir node.

type FileInfo

type FileInfo interface {
	ModTime() time.Time
	AccessTime() time.Time
	ChangeTime() time.Time
	Inode() int64
	Size() int64
	Mode() os.FileMode
	Owner() Owner
	Name() string
}

FileInfo is the metadata stored about a node in a tar file.

type MetadataStore

type MetadataStore interface {
	Get(string) FileInfo
	Add(string, FileInfo) error
	Entries(string) []FileInfo
}

MetadataStore is an abstraction for implementing different storages for filesystem metadata. This is used to insert or delete file metadata based on a key (typically the file path). It is also used to get the entries for a particular directory. TODO: Maybe `Entries()` isn't right here

func NewBTreeStore

func NewBTreeStore(degree int) MetadataStore

NewBTreeStore creates a nw MetadatStore backed by an in-memory b-tree of the passed in degree.

type Owner

type Owner struct {
	UID uint32
	GID uint32
}

Owner is the uid/gid used for a filesystem node

type StatT

type StatT struct {
	Mode  uint32
	Owner Owner
	Atime time.Time
	Mtime time.Time
	Ctime time.Time
	Ino   int64
	Size  int64
}

StatT is an implementation of FileInfo.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL