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
- Variables
- type Directory
- type ElTorito
- type ElToritoEntry
- type Emulation
- type File
- func (fl *File) Close() error
- func (de File) IsDir() bool
- func (fl *File) Location() uint32
- func (de File) ModTime() time.Time
- func (de File) Mode() os.FileMode
- func (de File) Name() string
- func (fl *File) Read(b []byte) (int, error)
- func (de File) ReadLink() (string, bool)
- func (fl *File) Seek(offset int64, whence int) (int64, error)
- func (de File) Size() int64
- func (de File) Sys() interface{}
- func (fl *File) Write(p []byte) (int, error)
- type FileSystem
- func (fs *FileSystem) Equal(a *FileSystem) bool
- func (fs *FileSystem) Finalize(options FinalizeOptions) error
- func (fs *FileSystem) Label() string
- func (fs *FileSystem) Mkdir(p string) error
- func (fs *FileSystem) OpenFile(p string, flag int) (filesystem.File, error)
- func (fs *FileSystem) ReadDir(p string) ([]os.FileInfo, error)
- func (fs *FileSystem) SetLabel(string) error
- func (fs *FileSystem) Type() filesystem.Type
- func (fs *FileSystem) Workspace() string
- type FinalizeOptions
- type Platform
Constants ¶
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 )
const ( // MaxBlocks maximum number of blocks allowed in an iso9660 filesystem MaxBlocks int64 = 4.294967296e+09 // 2^32 )
Variables ¶
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()
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) 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
func (File) Size ¶
func (de File) Size() int64
Size() int64 // length in bytes for regular files; system-dependent for others
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem implements the FileSystem interface
func Create ¶
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