fs

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ext4Fs

type Ext4Fs struct {
	BlockSize uint64
	InodeSize uint64
	// contains filtered or unexported fields
}

Ext4Fs implements the Filesystem interface for ext4.

Ext4Fs makes the following assumptions about the ext4 file system.

  • No journal or GDT table
  • Extent tree (instead of direct/indirect block addressing)
  • Hash tree directories (instead of linear directories)
  • Inline symlinks if < 60 chars, but no inline directories or reg files
  • sparse_super ext4 flags, so superblocks backups are in powers of 3, 5, 7
  • Directory entries take 1 block (even though its not true)
  • All regular files/symlinks <= 128MB

func (*Ext4Fs) CalcAddExAttrSize

func (e *Ext4Fs) CalcAddExAttrSize(fileName string, attr string, data []byte, flags int) error

CalcAddExAttrSize calculates the space taken by extended attributes.

func (*Ext4Fs) CalcBlockDeviceSize

func (e *Ext4Fs) CalcBlockDeviceSize(devName string, major uint64, minor uint64) error

CalcBlockDeviceSize calculates the space taken by a block device.

func (*Ext4Fs) CalcCharDeviceSize

func (e *Ext4Fs) CalcCharDeviceSize(devName string, major uint64, minor uint64) error

CalcCharDeviceSize calculates the space taken by a char device.

func (*Ext4Fs) CalcDirSize

func (e *Ext4Fs) CalcDirSize(dirName string) error

CalcDirSize calculates the space taken by the given directory on a ext4 file system with hash tree directories enabled.

func (*Ext4Fs) CalcFIFOPipeSize

func (e *Ext4Fs) CalcFIFOPipeSize(pipeName string) error

CalcFIFOPipeSize calculates the space taken by a fifo pipe.

func (*Ext4Fs) CalcHardlinkSize

func (e *Ext4Fs) CalcHardlinkSize(srcName string, dstName string) error

CalcHardlinkSize calculates the space taken by a hardlink.

func (*Ext4Fs) CalcRegFileSize

func (e *Ext4Fs) CalcRegFileSize(fileName string, fileSize uint64) error

CalcRegFileSize calculates the space taken by the given regular file on a ext4 file system with extent trees.

func (*Ext4Fs) CalcSocketSize

func (e *Ext4Fs) CalcSocketSize(sockName string) error

CalcSocketSize calculates the space taken by a socket.

func (*Ext4Fs) CalcSymlinkSize

func (e *Ext4Fs) CalcSymlinkSize(srcName string, dstName string) error

CalcSymlinkSize calculates the space taken by a symlink taking account for inline symlinks.

func (*Ext4Fs) CleanupSizeContext

func (e *Ext4Fs) CleanupSizeContext() error

CleanupSizeContext frees any resources needed by the ext4 file system

func (*Ext4Fs) FinalizeSizeContext

func (e *Ext4Fs) FinalizeSizeContext() error

FinalizeSizeContext should be after all of the CalcXSize methods are done. It does some final size adjustments.

func (*Ext4Fs) GetSizeInfo

func (e *Ext4Fs) GetSizeInfo() FilesystemSizeInfo

GetSizeInfo returns the size of the ext4 file system after the size context is finalized.

func (*Ext4Fs) InitSizeContext

func (e *Ext4Fs) InitSizeContext() error

InitSizeContext creates the context for a new ext4 filesystem context Before calling set e.BlockSize and e.InodeSize to the desired values.

func (*Ext4Fs) MakeFileSystem

func (e *Ext4Fs) MakeFileSystem(file *os.File) error

MakeFileSystem writes an ext4 filesystem to the given file after the size context is finalized.

type Filesystem

type Filesystem interface {
	// InitContext() starts a new context to calculate the file system size.
	InitSizeContext() error

	// These functions calculate the size of different Linux file types after
	// the context has been created.
	CalcRegFileSize(fileName string, fileSize uint64) error
	CalcDirSize(dirName string) error
	CalcSymlinkSize(srcName string, dstName string) error
	CalcHardlinkSize(srcName string, dstName string) error
	CalcCharDeviceSize(devName string, major uint64, minor uint64) error
	CalcBlockDeviceSize(devName string, major uint64, minor uint64) error
	CalcFIFOPipeSize(pipeName string) error
	CalcSocketSize(sockName string) error
	CalcAddExAttrSize(fileName string, attr string, data []byte, flags int) error

	// FinalizeContext() finalizes the total size and inodes for the filesystem
	// in the current context.
	FinalizeSizeContext() error

	// GetSizeInfo() can be called before FinalizeContext() to get a intermediate result
	// or after to get the final result.
	GetSizeInfo() FilesystemSizeInfo

	// MakeFileSystem takes the current context and creates a file system on the
	// given device.
	MakeFileSystem(file *os.File) error

	// CleanupContext() clears up system resources to safely begin a new context
	CleanupSizeContext() error
}

Filesystem is an interface that calculates the disk space a filesystem would take up and offers the option to create a file system disk image.

type FilesystemSizeInfo

type FilesystemSizeInfo struct {
	NumInodes uint64
	TotalSize uint64
}

FilesystemSizeInfo contains the number of inodes and the total size.

Jump to

Keyboard shortcuts

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