iso9660

package
v0.0.0-...-75b8cda Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package iso9660 provides utilities to interact with, manipulate and create an iso9660 filesystem on a block device or a disk image.

Reference documentation

ISO9660 https://wiki.osdev.org/ISO_9660
ISO9660 / ECMA-119 http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
System Use Sharing Protocol http://cdrtools.sourceforge.net/private/RRIP/susp.ps
Rock Ridge http://cdrtools.sourceforge.net/private/RRIP/rrip.ps
El Torito https://wiki.osdev.org/El-Torito

Index

Constants

View Source
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
)
View Source
const (

	// MaxBlocks maximum number of blocks allowed in an iso9660 filesystem
	MaxBlocks int64 = 4.294967296e+09 // 2^32
)

Variables

View Source
var (
	// ErrSuspNoHandler error to show gracefully that we do not have a handler for this signature. Opposed to processing error
	ErrSuspNoHandler = errors.New("NoHandler")
	// ErrSuspFilenameUnsupported error to show that this extension does not support searching by path
	ErrSuspFilenameUnsupported = errors.New("FilenameUnsupported")
	// ErrSuspRelocatedDirectoryUnsupported error to indicate that this extension does not support relocated directories
	ErrSuspRelocatedDirectoryUnsupported = errors.New("relocatedDirectoryUnsupported")
)

Functions

This section is empty.

Types

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

Directory represents a single directory in a FAT32 filesystem

func (*Directory) IsDir

func (de *Directory) IsDir() bool

IsDir() bool // abbreviation for Mode().IsDir()

func (*Directory) ModTime

func (de *Directory) ModTime() time.Time

ModTime() time.Time // modification time

func (*Directory) Mode

func (de *Directory) Mode() os.FileMode

Mode() FileMode // file mode bits

func (*Directory) Name

func (de *Directory) Name() string

Name() string // base name of the file

func (de *Directory) ReadLink() (string, bool)

Readlink tries to return the target link, only valid for symlinks

func (*Directory) Size

func (de *Directory) Size() int64

Size() int64 // length in bytes for regular files; system-dependent for others

func (*Directory) Sys

func (de *Directory) Sys() interface{}

Sys() interface{} // underlying data source (can return nil)

type ElTorito

type ElTorito struct {
	// BootCatalog path to save the boot catalog in the file structure. Defaults to "/BOOT.CAT" in iso9660 and "/boot.catalog" in Rock Ridge
	BootCatalog string
	// HideBootCatalog if the boot catalog should be hidden in the file system. Defaults to false
	HideBootCatalog bool
	// Entries list of ElToritoEntry boot entires
	Entries []*ElToritoEntry
	// Platform supported platform
	Platform Platform
}

ElTorito boot structure for a disk

type ElToritoEntry

type ElToritoEntry struct {
	Platform     Platform
	Emulation    Emulation
	BootFile     string
	HideBootFile bool
	LoadSegment  uint16
	// BootTable whether to insert a boot table into the entry, equivalent to genisoimage
	// option `-boot-info-table`. Unlike genisoimage, does not modify the file in the
	// filesystem, but inserts it on the fly.
	BootTable bool
	// SystemType type of system the partition is, accordinng to the MBR standard
	SystemType mbr.Type
	// LoadSize how many blocks of BootFile to load, equivalent to genisoimage option `-boot-load-size`
	LoadSize uint16
	// contains filtered or unexported fields
}

ElToritoEntry single entry in an el torito boot catalog

type Emulation

type Emulation uint8

Emulation what emulation should be used for booting, normally none

const (
	// NoEmulation do not do any emulation, the normal mode
	NoEmulation Emulation = 0
	// Floppy12Emulation emulate a 1.2 M floppy
	Floppy12Emulation Emulation = 1
	// Floppy144Emulation emulate a 1.44 M floppy
	Floppy144Emulation Emulation = 2
	// Floppy288Emulation emulate a 2.88 M floppy
	Floppy288Emulation Emulation = 3
	// HardDiskEmulation emulate a hard disk
	HardDiskEmulation Emulation = 4
)

type File

type File struct {
	// contains filtered or unexported fields
}

File represents a single file in an iso9660 filesystem

it is NOT used when working in a workspace, where we just use the underlying OS

func (*File) Close

func (fl *File) Close() error

Close close the file

func (File) IsDir

func (de File) IsDir() bool

IsDir() bool // abbreviation for Mode().IsDir()

func (*File) Location

func (fl *File) Location() uint32

func (File) ModTime

func (de File) ModTime() time.Time

ModTime() time.Time // modification time

func (File) Mode

func (de File) Mode() os.FileMode

Mode() FileMode // file mode bits

func (File) Name

func (de File) Name() string

Name() string // base name of the file

func (*File) Read

func (fl *File) Read(b []byte) (int, error)

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

func (de File) ReadLink() (string, bool)

Readlink tries to return the target link, only valid for symlinks

func (*File) Seek

func (fl *File) Seek(offset int64, whence int) (int64, error)

Seek set the offset to a particular point in the file

func (File) Size

func (de File) Size() int64

Size() int64 // length in bytes for regular files; system-dependent for others

func (File) Sys

func (de File) Sys() interface{}

Sys() interface{} // underlying data source (can return nil)

func (*File) Write

func (fl *File) Write(p []byte) (int, error)

Write writes len(b) bytes to the File.

you cannot write to an iso, so this returns an error

type FileSystem

type FileSystem struct {
	// contains filtered or unexported fields
}

FileSystem implements the FileSystem interface

func Create

func Create(f util.File, size, start, blocksize int64, workspace string) (*FileSystem, error)

Create creates an ISO9660 filesystem in a given directory

requires the util.File 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 util.File to create the filesystem, and blocksize is is the logical blocksize to use for creating the filesystem

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 2 KB.

func Read

func Read(file util.File, size, start, blocksize int64) (*FileSystem, error)

Read reads a filesystem from a given disk.

requires the util.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 util.File the filesystem is expected to begin, and blocksize is is the physical blocksize to use for reading 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 2K bytes

func (*FileSystem) Equal

func (fs *FileSystem) Equal(a *FileSystem) bool

Equal compare if two filesystems are equal

func (*FileSystem) Finalize

func (fs *FileSystem) Finalize(options FinalizeOptions) error

Finalize finalize a read-only filesystem by writing it out to a read-only format

func (*FileSystem) Label

func (fs *FileSystem) Label() string

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

if readonly and not in workspace, will return an error

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) SetLabel

func (fs *FileSystem) SetLabel(string) error

func (*FileSystem) Type

func (fs *FileSystem) Type() filesystem.Type

Type returns the type code for the filesystem. Always returns filesystem.TypeFat32

func (*FileSystem) Workspace

func (fs *FileSystem) Workspace() string

Workspace get the workspace path

type FinalizeOptions

type FinalizeOptions struct {
	// RockRidge enable Rock Ridge extensions
	RockRidge bool
	// DeepDirectories allow directories deeper than 8
	DeepDirectories bool
	// ElTorito slice of el torito entry configs
	ElTorito *ElTorito
	// VolumeIdentifier custom volume name, defaults to "ISOIMAGE"
	VolumeIdentifier string
}

FinalizeOptions options to pass to finalize

type Platform

type Platform uint8

Platform target booting system for a bootable iso

const (
	// BIOS classic PC-BIOS x86
	BIOS Platform = 0x0
	// PPC PowerPC
	PPC Platform = 0x1
	// Mac some Macintosh system,s
	Mac Platform = 0x2
	// EFI newer extensible firmware interface
	EFI Platform = 0xef
)

Jump to

Keyboard shortcuts

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