Documentation
¶
Index ¶
- Constants
- func TEATransform(buf [4]uint32, in []uint32) [4]uint32
- type BlockSize
- type Directory
- type FeatureOpt
- func WithFeatureBTreeDirectory(enable bool) FeatureOpt
- func WithFeatureBigalloc(enable bool) FeatureOpt
- func WithFeatureCompression(enable bool) FeatureOpt
- func WithFeatureDataInDirectoryEntries(enable bool) FeatureOpt
- func WithFeatureDataInInode(enable bool) FeatureOpt
- func WithFeatureDirectoryEntriesRecordFileType(enable bool) FeatureOpt
- func WithFeatureDirectoryIndices(enable bool) FeatureOpt
- func WithFeatureDirectoryPreAllocate(enable bool) FeatureOpt
- func WithFeatureEncryptInodes(enable bool) FeatureOpt
- func WithFeatureExcludeBitmap(enable bool) FeatureOpt
- func WithFeatureExcludeInode(enable bool) FeatureOpt
- func WithFeatureExtendedAttributeInodes(enable bool) FeatureOpt
- func WithFeatureExtendedAttributes(enable bool) FeatureOpt
- func WithFeatureExtents(enable bool) FeatureOpt
- func WithFeatureFS64Bit(enable bool) FeatureOpt
- func WithFeatureFlexBlockGroups(enable bool) FeatureOpt
- func WithFeatureGDTChecksum(enable bool) FeatureOpt
- func WithFeatureHasJournal(enable bool) FeatureOpt
- func WithFeatureHugeFile(enable bool) FeatureOpt
- func WithFeatureImagicInodes(enable bool) FeatureOpt
- func WithFeatureLargeDirectory(enable bool) FeatureOpt
- func WithFeatureLargeFile(enable bool) FeatureOpt
- func WithFeatureLargeInodes(enable bool) FeatureOpt
- func WithFeatureLargeSubdirectoryCount(enable bool) FeatureOpt
- func WithFeatureLazyBlockGroup(enable bool) FeatureOpt
- func WithFeatureMetaBlockGroups(enable bool) FeatureOpt
- func WithFeatureMetadataChecksumSeedInSuperblock(enable bool) FeatureOpt
- func WithFeatureMetadataChecksums(enable bool) FeatureOpt
- func WithFeatureMultipleMountProtection(enable bool) FeatureOpt
- func WithFeatureProjectQuotas(enable bool) FeatureOpt
- func WithFeatureQuota(enable bool) FeatureOpt
- func WithFeatureReadOnly(enable bool) FeatureOpt
- func WithFeatureRecoveryNeeded(enable bool) FeatureOpt
- func WithFeatureReplicas(enable bool) FeatureOpt
- func WithFeatureReservedGDTBlocksForExpansion(enable bool) FeatureOpt
- func WithFeatureSeparateJournalDevice(enable bool) FeatureOpt
- func WithFeatureSnapshot(enable bool) FeatureOpt
- func WithFeatureSparseSuperBlockV2(enable bool) FeatureOpt
- func WithFeatureSparseSuperblock(enable bool) FeatureOpt
- type File
- type FileInfo
- type FileSystem
- func (fs *FileSystem) Chmod(name string, mode os.FileMode) error
- func (fs *FileSystem) Chown(name string, uid, gid int) error
- func (fs *FileSystem) Close() error
- func (fs *FileSystem) Equal(a *FileSystem) bool
- func (fs *FileSystem) Label() string
- func (fs *FileSystem) Link(oldpath, newpath string) error
- func (fs *FileSystem) Mkdir(p string) error
- func (fs *FileSystem) Mknod(pathname string, mode uint32, dev int) error
- func (fs *FileSystem) OpenFile(p string, flag int) (filesystem.File, error)
- func (fs *FileSystem) ReadDir(p string) ([]os.FileInfo, error)
- func (fs *FileSystem) Remove(p string) error
- func (fs *FileSystem) Rename(oldpath, newpath string) error
- func (fs *FileSystem) Rm(p string) errordeprecated
- func (fs *FileSystem) SetLabel(label string) error
- func (fs *FileSystem) Stat(p string) (iofs.FileInfo, error)
- func (fs *FileSystem) Symlink(oldpath, newpath string) error
- func (fs *FileSystem) Truncate(p string, size int64) error
- func (fs *FileSystem) Type() filesystem.Type
- type MountOpt
- func WithDefaultMountOptionBlockValidity(enable bool) MountOpt
- func WithDefaultMountOptionDisableDelayedAllocation(enable bool) MountOpt
- func WithDefaultMountOptionDisableWriteFlushes(enable bool) MountOpt
- func WithDefaultMountOptionDiscardSupport(enable bool) MountOpt
- func WithDefaultMountOptionGIDFromDirectory(enable bool) MountOpt
- func WithDefaultMountOptionJournalModeData(enable bool) MountOpt
- func WithDefaultMountOptionJournalModeOrdered(enable bool) MountOpt
- func WithDefaultMountOptionJournalModeWriteback(enable bool) MountOpt
- func WithDefaultMountOptionPOSIXACLs(enable bool) MountOpt
- func WithDefaultMountOptionPrintDebuggingInfo(enable bool) MountOpt
- func WithDefaultMountOptionUID16Bit(enable bool) MountOpt
- func WithDefaultMountOptionUserspaceXattrs(enable bool) MountOpt
- type Params
- type SectorSize
Constants ¶
const ( HashVersionLegacy = 0 HashVersionHalfMD4 = 1 HashVersionTEA = 2 HashVersionLegacyUnsigned = 3 HashVersionHalfMD4Unsigned = 4 HashVersionTEAUnsigned = 5 HashVersionSIP = 6 )
const ( // SectorSize512 is a sector size of 512 bytes, used as the logical size for all ext4 filesystems SectorSize512 SectorSize = 512 BootSectorSize SectorSize = 2 * SectorSize512 SuperblockSize SectorSize = 2 * SectorSize512 BlockGroupFactor int = 8 DefaultInodeRatio int64 = 8192 DefaultInodeSize int64 = 256 DefaultReservedBlocksPercent uint8 = 5 DefaultVolumeName = "diskfs_ext4" )
const ( // KB represents one KB KB int64 = 1024 // MB represents one MB MB int64 = 1024 * KB // GB represents one GB GB int64 = 1024 * MB // TB represents one TB TB int64 = 1024 * GB // PB represents one TB PB int64 = 1024 * TB // XB represents one Exabyte XB int64 = 1024 * PB // Ext4MinSize is minimum size for an ext4 filesystem // it assumes a single block group with: // blocksize = 2 sectors = 1KB // 1 block for boot code // 1 block for superblock // 1 block for block group descriptors // 1 block for bock and inode bitmaps and inode table // 1 block for data // total = 5 blocks Ext4MinSize int64 = 5 * int64(SectorSize512) )
Variables ¶
This section is empty.
Functions ¶
func TEATransform ¶
Types ¶
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
Directory represents a single directory in an ext4 filesystem
type FeatureOpt ¶
type FeatureOpt func(*featureFlags)
func WithFeatureBTreeDirectory ¶
func WithFeatureBTreeDirectory(enable bool) FeatureOpt
func WithFeatureBigalloc ¶
func WithFeatureBigalloc(enable bool) FeatureOpt
func WithFeatureCompression ¶
func WithFeatureCompression(enable bool) FeatureOpt
func WithFeatureDataInDirectoryEntries ¶
func WithFeatureDataInDirectoryEntries(enable bool) FeatureOpt
func WithFeatureDataInInode ¶
func WithFeatureDataInInode(enable bool) FeatureOpt
func WithFeatureDirectoryEntriesRecordFileType ¶
func WithFeatureDirectoryEntriesRecordFileType(enable bool) FeatureOpt
func WithFeatureDirectoryIndices ¶
func WithFeatureDirectoryIndices(enable bool) FeatureOpt
func WithFeatureDirectoryPreAllocate ¶
func WithFeatureDirectoryPreAllocate(enable bool) FeatureOpt
func WithFeatureEncryptInodes ¶
func WithFeatureEncryptInodes(enable bool) FeatureOpt
func WithFeatureExcludeBitmap ¶
func WithFeatureExcludeBitmap(enable bool) FeatureOpt
func WithFeatureExcludeInode ¶
func WithFeatureExcludeInode(enable bool) FeatureOpt
func WithFeatureExtendedAttributeInodes ¶
func WithFeatureExtendedAttributeInodes(enable bool) FeatureOpt
func WithFeatureExtendedAttributes ¶
func WithFeatureExtendedAttributes(enable bool) FeatureOpt
func WithFeatureExtents ¶
func WithFeatureExtents(enable bool) FeatureOpt
func WithFeatureFS64Bit ¶
func WithFeatureFS64Bit(enable bool) FeatureOpt
func WithFeatureFlexBlockGroups ¶
func WithFeatureFlexBlockGroups(enable bool) FeatureOpt
func WithFeatureGDTChecksum ¶
func WithFeatureGDTChecksum(enable bool) FeatureOpt
func WithFeatureHasJournal ¶
func WithFeatureHasJournal(enable bool) FeatureOpt
func WithFeatureHugeFile ¶
func WithFeatureHugeFile(enable bool) FeatureOpt
func WithFeatureImagicInodes ¶
func WithFeatureImagicInodes(enable bool) FeatureOpt
func WithFeatureLargeDirectory ¶
func WithFeatureLargeDirectory(enable bool) FeatureOpt
func WithFeatureLargeFile ¶
func WithFeatureLargeFile(enable bool) FeatureOpt
func WithFeatureLargeInodes ¶
func WithFeatureLargeInodes(enable bool) FeatureOpt
func WithFeatureLargeSubdirectoryCount ¶
func WithFeatureLargeSubdirectoryCount(enable bool) FeatureOpt
func WithFeatureLazyBlockGroup ¶
func WithFeatureLazyBlockGroup(enable bool) FeatureOpt
func WithFeatureMetaBlockGroups ¶
func WithFeatureMetaBlockGroups(enable bool) FeatureOpt
func WithFeatureMetadataChecksumSeedInSuperblock ¶
func WithFeatureMetadataChecksumSeedInSuperblock(enable bool) FeatureOpt
func WithFeatureMetadataChecksums ¶
func WithFeatureMetadataChecksums(enable bool) FeatureOpt
func WithFeatureMultipleMountProtection ¶
func WithFeatureMultipleMountProtection(enable bool) FeatureOpt
func WithFeatureProjectQuotas ¶
func WithFeatureProjectQuotas(enable bool) FeatureOpt
func WithFeatureQuota ¶
func WithFeatureQuota(enable bool) FeatureOpt
func WithFeatureReadOnly ¶
func WithFeatureReadOnly(enable bool) FeatureOpt
func WithFeatureRecoveryNeeded ¶
func WithFeatureRecoveryNeeded(enable bool) FeatureOpt
func WithFeatureReplicas ¶
func WithFeatureReplicas(enable bool) FeatureOpt
func WithFeatureReservedGDTBlocksForExpansion ¶
func WithFeatureReservedGDTBlocksForExpansion(enable bool) FeatureOpt
func WithFeatureSeparateJournalDevice ¶
func WithFeatureSeparateJournalDevice(enable bool) FeatureOpt
func WithFeatureSnapshot ¶
func WithFeatureSnapshot(enable bool) FeatureOpt
func WithFeatureSparseSuperBlockV2 ¶
func WithFeatureSparseSuperBlockV2(enable bool) FeatureOpt
func WithFeatureSparseSuperblock ¶
func WithFeatureSparseSuperblock(enable bool) FeatureOpt
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a single file in an ext4 filesystem
func (*File) Read ¶
Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF reads from the last known offset in the file from last read or write use Seek() to set at a particular point
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo represents the information for an individual file it fulfills os.FileInfo interface
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem implememnts the FileSystem interface
func Create ¶
Create creates an ext4 filesystem in a given file or device
requires the backend.Storage where to create the filesystem, size is the size of the filesystem in bytes, start is how far in bytes from the beginning of the backend.Storage to create the filesystem, and sectorsize is is the logical sector size to use for creating the filesystem
blocksize is the size of the ext4 blocks, and is calculated as sectorsPerBlock * sectorsize. By ext4 specification, it must be between 512 and 4096 bytes, where sectorsize is the provided parameter, and sectorsPerBlock is part of `p *Params`. If either sectorsize or p.SectorsPerBlock is 0, it will calculate the optimal size for both.
note that you are *not* required to create the filesystem on the entire disk. You could have a disk of size 20GB, and create a small filesystem of size 50MB that begins 2GB into the disk. This is extremely useful for creating filesystems on disk partitions.
Note, however, that it is much easier to do this using the higher-level APIs at github.com/diskfs/go-diskfs which allow you to work directly with partitions, rather than having to calculate (and hopefully not make any errors) where a partition starts and ends.
If the provided blocksize is 0, it will use the default of 512 bytes. If it is any number other than 0 or 512, it will return an error.
func Read ¶
func Read(b backend.Storage, size, start, sectorsize int64) (*FileSystem, error)
Read reads a filesystem from a given disk.
requires the backend.File where to read the filesystem, size is the size of the filesystem in bytes, start is how far in bytes from the beginning of the backend.File the filesystem is expected to begin, and blocksize is is the logical blocksize to use for creating the filesystem
note that you are *not* required to read a filesystem on the entire disk. You could have a disk of size 20GB, and a small filesystem of size 50MB that begins 2GB into the disk. This is extremely useful for working with filesystems on disk partitions.
Note, however, that it is much easier to do this using the higher-level APIs at github.com/diskfs/go-diskfs which allow you to work directly with partitions, rather than having to calculate (and hopefully not make any errors) where a partition starts and ends.
If the provided blocksize is 0, it will use the default of 512 bytes. If it is any number other than 0 or 512, it will return an error.
func (*FileSystem) Chmod ¶ added in v1.5.0
func (fs *FileSystem) Chmod(name string, mode os.FileMode) error
Chmod changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target.
func (*FileSystem) Chown ¶ added in v1.5.0
func (fs *FileSystem) Chown(name string, uid, gid int) error
Chown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link's target. A uid or gid of -1 means to not change that value
func (*FileSystem) Close ¶ added in v1.5.2
func (fs *FileSystem) Close() error
Do cleaning job for ext4. Note that ext4 does not have side-effects so we do not do anything.
func (*FileSystem) Equal ¶
func (fs *FileSystem) Equal(a *FileSystem) bool
Equal compare if two filesystems are equal
func (*FileSystem) Link ¶ added in v1.5.0
func (fs *FileSystem) Link(oldpath, newpath string) error
creates a new link (also known as a hard link) to an existing file.
func (*FileSystem) Mkdir ¶
func (fs *FileSystem) Mkdir(p string) error
Mkdir make a directory at the given path. It is equivalent to `mkdir -p`, i.e. idempotent, in that:
* It will make the entire tree path if it does not exist * It will not return an error if the path already exists
func (*FileSystem) Mknod ¶ added in v1.5.0
func (fs *FileSystem) Mknod(pathname string, mode uint32, dev int) error
creates a filesystem node (file, device special file, or named pipe) named pathname, with attributes specified by mode and dev
func (*FileSystem) OpenFile ¶
func (fs *FileSystem) OpenFile(p string, flag int) (filesystem.File, error)
OpenFile returns an io.ReadWriter from which you can read the contents of a file or write contents to the file
accepts normal os.OpenFile flags
returns an error if the file does not exist
func (*FileSystem) ReadDir ¶
func (fs *FileSystem) ReadDir(p string) ([]os.FileInfo, error)
ReadDir return the contents of a given directory in a given filesystem.
Returns a slice of os.FileInfo with all of the entries in the directory.
Will return an error if the directory does not exist or is a regular file and not a directory
func (*FileSystem) Remove ¶ added in v1.5.0
func (fs *FileSystem) Remove(p string) error
Removes file or directory at path. If path is directory, it only will remove if it is empty. If path is a file, it will remove the file. Will not remove any parents. Error if the file does not exist or is not an empty directory
func (*FileSystem) Rename ¶ added in v1.5.0
func (fs *FileSystem) Rename(oldpath, newpath string) error
Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it.
func (*FileSystem) Rm
deprecated
func (fs *FileSystem) Rm(p string) error
Deprecated: use filesystem.Remove(p string) instead
func (*FileSystem) SetLabel ¶
func (fs *FileSystem) SetLabel(label string) error
SetLabel changes the label on the writable filesystem. Different file system may hav different length constraints.
func (*FileSystem) Stat ¶
func (fs *FileSystem) Stat(p string) (iofs.FileInfo, error)
Stat return fs.FileInfo about a specific file path.
func (*FileSystem) Symlink ¶ added in v1.5.0
func (fs *FileSystem) Symlink(oldpath, newpath string) error
creates a symbolic link named linkpath which contains the string target.
func (*FileSystem) Type ¶
func (fs *FileSystem) Type() filesystem.Type
Type returns the type code for the filesystem. Always returns filesystem.TypeExt4
type MountOpt ¶
type MountOpt func(*mountOptions)
type Params ¶
type Params struct { UUID *uuid.UUID SectorsPerBlock uint8 BlocksPerGroup uint32 InodeRatio int64 InodeCount uint32 SparseSuperVersion uint8 Checksum bool ClusterSize int64 ReservedBlocksPercent uint8 VolumeName string // JournalDevice external journal device, only checked if WithFeatureSeparateJournalDevice(true) is set JournalDevice string LogFlexBlockGroups int Features []FeatureOpt DefaultMountOpts []MountOpt }