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(_ []byte) (int, error)
- type FileSystem
- func (fsm *FileSystem) Chmod(name string, mode os.FileMode) error
- func (fsm *FileSystem) Chown(name string, uid, gid int) error
- func (fsm *FileSystem) Equal(a *FileSystem) bool
- func (fsm *FileSystem) Finalize(options FinalizeOptions) error
- func (fsm *FileSystem) Label() string
- func (fsm *FileSystem) Link(_, _ string) error
- func (fsm *FileSystem) Mkdir(p string) error
- func (fsm *FileSystem) Mknod(pathname string, mode uint32, dev int) error
- func (fsm *FileSystem) OpenFile(p string, flag int) (filesystem.File, error)
- func (fsm *FileSystem) ReadDir(p string) ([]os.FileInfo, error)
- func (fsm *FileSystem) Remove(p string) error
- func (fsm *FileSystem) Rename(oldpath, newpath string) error
- func (fsm *FileSystem) SetLabel(string) error
- func (fsm *FileSystem) Symlink(oldpath, newpath string) error
- func (fsm *FileSystem) Type() filesystem.Type
- func (fsm *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()
func (*Directory) ReadLink ¶ added in v1.4.1
Readlink tries to return the target link, only valid for symlinks
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 entries 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, according 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 that 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) ReadLink ¶ added in v1.4.1
Readlink tries to return the target link, only valid for symlinks
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 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 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(b backend.Storage, size, start, blocksize 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 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) Chmod ¶ added in v1.5.0
func (fsm *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 (fsm *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) Equal ¶
func (fsm *FileSystem) Equal(a *FileSystem) bool
Equal compare if two filesystems are equal
func (*FileSystem) Finalize ¶
func (fsm *FileSystem) Finalize(options FinalizeOptions) error
Finalize finalize a read-only filesystem by writing it out to a read-only format
func (*FileSystem) Label ¶ added in v1.1.0
func (fsm *FileSystem) Label() string
func (*FileSystem) Link ¶ added in v1.5.0
func (fsm *FileSystem) Link(_, _ string) error
creates a new link (also known as a hard link) to an existing file.
func (*FileSystem) Mkdir ¶
func (fsm *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) Mknod ¶ added in v1.5.0
func (fsm *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 (fsm *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 (fsm *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 (fsm *FileSystem) Remove(p string) error
func (*FileSystem) Rename ¶ added in v1.5.0
func (fsm *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) SetLabel ¶ added in v1.3.0
func (fsm *FileSystem) SetLabel(string) error
func (*FileSystem) Symlink ¶ added in v1.5.0
func (fsm *FileSystem) Symlink(oldpath, newpath string) error
creates a symbolic link named linkpath which contains the string target.
func (*FileSystem) Type ¶
func (fsm *FileSystem) Type() filesystem.Type
Type returns the type code for the filesystem. Always returns filesystem.TypeFat32
func (*FileSystem) Workspace ¶
func (fsm *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