diskfs

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package diskfs implements methods for creating and manipulating disks and filesystems

methods for creating and manipulating disks and filesystems, whether block devices in /dev or direct disk images. This does **not** mount any disks or filesystems, neither directly locally nor via a VM. Instead, it manipulates the bytes directly.

This is not intended as a replacement for operating system filesystem and disk drivers. Instead, it is intended to make it easy to work with partitions, partition tables and filesystems directly without requiring operating system mounts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(device string, size int64, sectorSize SectorSize) (*disk.Disk, error)

Might be deprecated in future: use <backend>.CreateFromPath + diskfs.OpenBackend Create a Disk from a path to a device Should pass a path to a block device e.g. /dev/sda or a path to a file /tmp/foo.img The provided device must not exist at the time you call Create()

func Open

func Open(device string, opts ...OpenOpt) (*disk.Disk, error)

Might be deprecated in future: use <backend>.New + diskfs.OpenBackend Open a Disk from a path to a device in read-write exclusive mode Should pass a path to a block device e.g. /dev/sda or a path to a file /tmp/foo.img The provided device must exist at the time you call Open(). Use OpenOpt to control options, such as sector size or open mode.

func OpenBackend

func OpenBackend(b backend.Storage, opts ...OpenOpt) (*disk.Disk, error)

Open a Disk using provided fs.File to a device in read-only mode Use OpenOpt to control options, such as sector size or open mode.

Types

type OpenModeOption

type OpenModeOption int

OpenModeOption represents file open modes

const (
	// ReadOnly open file in read only mode
	ReadOnly OpenModeOption = iota
	// ReadWriteExclusive open file in read-write exclusive mode
	ReadWriteExclusive
	// ReadWrite open file in read-write mode
	ReadWrite
)

func (OpenModeOption) String

func (m OpenModeOption) String() string

OpenModeOption.String()

type OpenOpt

type OpenOpt func(o *openOpts) error

OpenOpt func that process Open options

func WithOpenMode

func WithOpenMode(mode OpenModeOption) OpenOpt

WithOpenMode sets the opening mode to the requested mode of type OpenModeOption. Default is ReadWriteExclusive, i.e. os.O_RDWR | os.O_EXCL

func WithSectorSize

func WithSectorSize(sectorSize SectorSize) OpenOpt

WithSectorSize opens the disk file or block device with the provided sector size. Defaults to the physical block size.

type SectorSize

type SectorSize int

SectorSize represents the sector size to use

const (
	// SectorSizeDefault default behavior, defaulting to defaultBlocksize
	SectorSizeDefault SectorSize = 0
	// SectorSize512 override sector size to 512
	SectorSize512 SectorSize = 512
	// SectorSize4k override sector size to 4k
	SectorSize4k SectorSize = 4096
)

Directories

Path Synopsis
Package disk provides utilities for working directly with a disk
Package disk provides utilities for working directly with a disk
Package filesystem provides interfaces and constants required for filesystem implementations.
Package filesystem provides interfaces and constants required for filesystem implementations.
fat12
Package fat12 provides utilities to interact with, manipulate and create a FAT12 filesystem on a block device or disk image.
Package fat12 provides utilities to interact with, manipulate and create a FAT12 filesystem on a block device or disk image.
fat16
Package fat16 provides utilities to interact with, manipulate and create a FAT16 filesystem on a block device or disk image.
Package fat16 provides utilities to interact with, manipulate and create a FAT16 filesystem on a block device or disk image.
fat32
Package fat32 provides utilities to interact with, manipulate and create a FAT32 filesystem on a block device or a disk image.
Package fat32 provides utilities to interact with, manipulate and create a FAT32 filesystem on a block device or a disk image.
iso9660
Package iso9660 provides utilities to interact with, manipulate and create an iso9660 filesystem on a block device or a disk image.
Package iso9660 provides utilities to interact with, manipulate and create an iso9660 filesystem on a block device or a disk image.
squashfs
Package squashfs provides support for reading and creating squashfs filesystems references:
Package squashfs provides support for reading and creating squashfs filesystems references:
Package partition provides ability to work with individual partitions.
Package partition provides ability to work with individual partitions.
gpt
Package gpt provides an interface to GUID Partition Table (GPT) partitioned disks.
Package gpt provides an interface to GUID Partition Table (GPT) partitioned disks.
mbr
Package mbr provides an interface to Master Boot Record (MBR) partitioned disks.
Package mbr provides an interface to Master Boot Record (MBR) partitioned disks.
util
timestamp
Package timestamp provides utilities for handling timestamps
Package timestamp provides utilities for handling timestamps

Jump to

Keyboard shortcuts

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