An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 5.8% dependent packages on proxy.golang.org
Top 4.7% dependent repos on proxy.golang.org

proxy.golang.org : github.com/dave/diskfs

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. Some examples: 1. Create a disk image of size 10MB with a FAT32 filesystem spanning the entire disk. Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem. import diskfs "github.com/dave/diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" import diskfs "github.com/dave/diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &gpt.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*gpt.Partition{ { LogicalSectorSize: 512, PhysicalSectorSize: 512, ProtectiveMBR: true, }, }, } f, err := os.Open("/root/contents.dat") written, err := disk.WritePartitionContents(1, f) Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem, and create some directories and files in that filesystem. import diskfs "github.com/dave/diskfs" diskSize := 10*1024*1024 // 10 MB diskImg := "/tmp/disk.img" disk := diskfs.Create(diskImg, size, diskfs.Raw) table := &mbr.Table{ LogicalSectorSize: 512, PhysicalSectorSize: 512, Partitions: []*mbr.Partition{ { Bootable: false, Type: Linux, Start: 2048, Size: 20480, }, }, } fs, err := disk.CreateFilesystem(1, diskfs.TypeFat32) err := fs.Mkdir("/FOO/BAR") rw, err := fs.OpenFile("/FOO/BAR/AFILE.EXE", os.O_CREATE|os.O_RDRWR) b := make([]byte, 1024, 1024) rand.Read(b) err := rw.Write(b)

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/dave/diskfs
License: MIT
Latest release: about 5 years ago
First release: about 5 years ago
Namespace: github.com/dave
Dependent packages: 1
Dependent repositories: 1
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 17 hours ago

    Loading...
    Readme
    Loading...