udf

package module
v0.0.0-...-6c18325 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: BSD-3-Clause Imports: 9 Imported by: 1

README

Udf filesystem golang library

  • Non-optimized
  • Some features may be broken
  • recovery() style error handling interface
  • Tested only with certain ISOs (e.g. Windows ISOs)

It's all because I has reached required functionality for me.

Example

package main

import (
	"fmt"
	"os"
	"github.com/Xmister/udf"
)

func main() {
	rdr, _ := os.Open("example.iso")
	u, _ := udf.NewUdfFromReader(r)
	for _, f := range u.ReadDir(nil) {
		fmt.Printf("%s %-10d %-20s %v\n", f.Mode().String(), f.Size(), f.Name(), f.ModTime())
	}
}

Output:

-r-xr-xr-x 57         system.cnf           2006-02-11 00:00:00 +0000 UTC
-r-xr-xr-x 1911580    SCUS_973.99          2006-03-15 00:00:00 +0000 UTC
-r-xr-xr-x 278305     ioprp300.img         2005-11-14 00:00:00 +0000 UTC
-r-xr-xr-x 6641       sio2man.irx          2005-10-18 00:00:00 +0000 UTC
-r-xr-xr-x 15653      dbcman.irx           2005-10-18 00:00:00 +0000 UTC

See isoinfo.go for complete example.

Specification

Documentation

Index

Constants

View Source
const (
	DESCRIPTOR_PRIMARY_VOLUME            = 0x1
	DESCRIPTOR_ANCHOR_VOLUME_POINTER     = 0x2
	DESCRIPTOR_VOLUME_POINTER            = 0x3
	DESCRIPTOR_IMPLEMENTATION_USE_VOLUME = 0x4
	DESCRIPTOR_PARTITION                 = 0x5
	DESCRIPTOR_LOGICAL_VOLUME            = 0x6
	DESCRIPTOR_UNALLOCATED               = 0x7
	DESCRIPTOR_TERMINATING               = 0x8
	DESCRIPTOR_FILE_SET                  = 0x100
	DESCRIPTOR_IDENTIFIER                = 0x101
	DESCRIPTOR_ALLOCATION_EXTENT         = 0x102
	DESCRIPTOR_INDIRECT_ENTRY            = 0x103
	DESCRIPTOR_TERMINAL_ENTRY            = 0x104
	DESCRIPTOR_FILE_ENTRY                = 0x105
	UDF_EXTENT_FLAG_MASK                 = 0xC0000000
	EXT_NOT_RECORDED_ALLOCATED           = 0x40000000
	EXT_NOT_RECORDED_NOT_ALLOCATED       = 0x80000000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AED

type AED struct {
	Descriptor                       Descriptor
	PreviousAllocationExtentLocation uint32
	LengthOfAllocationDescriptors    uint32
}

func (*AED) FromBytes

func (a *AED) FromBytes(b []byte) AED

type AllocationType

type AllocationType int
const (
	ShortDescriptors AllocationType = iota
	LongDescriptors
	ExtendedDescriptors
	Embedded
)

type AnchorVolumeDescriptorPointer

type AnchorVolumeDescriptorPointer struct {
	Descriptor                 Descriptor
	MainVolumeDescriptorSeq    Extent
	ReserveVolumeDescriptorSeq Extent
}

func NewAnchorVolumeDescriptorPointer

func NewAnchorVolumeDescriptorPointer(b []byte) *AnchorVolumeDescriptorPointer

func (*AnchorVolumeDescriptorPointer) FromBytes

type Descriptor

type Descriptor struct {
	TagIdentifier       uint16
	DescriptorVersion   uint16
	TagChecksum         uint8
	TagSerialNumber     uint16
	DescriptorCRC       uint16
	DescriptorCRCLength uint16
	TagLocation         uint32
	// contains filtered or unexported fields
}

func NewDescriptor

func NewDescriptor(b []byte) *Descriptor

func (*Descriptor) AnchorVolumeDescriptorPointer

func (d *Descriptor) AnchorVolumeDescriptorPointer() *AnchorVolumeDescriptorPointer

func (*Descriptor) Checksum

func (d *Descriptor) Checksum() (checksum uint8)

func (*Descriptor) Data

func (d *Descriptor) Data() []byte

func (*Descriptor) FileEntry

func (d *Descriptor) FileEntry() FileEntryInterface

func (*Descriptor) FileIdentifierDescriptor

func (d *Descriptor) FileIdentifierDescriptor() *FileIdentifierDescriptor

func (*Descriptor) FileSetDescriptor

func (d *Descriptor) FileSetDescriptor() *FileSetDescriptor

func (*Descriptor) FromBytes

func (d *Descriptor) FromBytes(b []byte) *Descriptor

func (*Descriptor) LogicalVolumeDescriptor

func (d *Descriptor) LogicalVolumeDescriptor() *LogicalVolumeDescriptor

func (*Descriptor) PartitionDescriptor

func (d *Descriptor) PartitionDescriptor() *PartitionDescriptor

func (*Descriptor) PrimaryVolumeDescriptor

func (d *Descriptor) PrimaryVolumeDescriptor() *PrimaryVolumeDescriptor

type EntityID

type EntityID struct {
	Flags            uint8
	Identifier       [23]byte
	IdentifierSuffix [8]byte
}

func NewEntityID

func NewEntityID(b []byte) EntityID

type ExtendedFileEntry

type ExtendedFileEntry struct {
	FileEntry
	CreationTime       time.Time
	ObjectSize         uint64
	StreamDirectoryIcb ExtentLong
}

func (*ExtendedFileEntry) FromBytes

func (fe *ExtendedFileEntry) FromBytes(b []byte) *ExtendedFileEntry

type Extent

type Extent struct {
	Length   uint32
	Location uint32
}

func NewExtent

func NewExtent(b []byte) Extent

func (Extent) GetLength

func (e Extent) GetLength() uint32

func (Extent) GetLocation

func (e Extent) GetLocation() uint64

func (Extent) GetPartition

func (e Extent) GetPartition() uint16

func (Extent) HasExtended

func (e Extent) HasExtended() bool

func (Extent) IsNotRecorded

func (e Extent) IsNotRecorded() bool

func (Extent) SetLength

func (e Extent) SetLength(length uint32)

type ExtentExtended

type ExtentExtended struct {
	ExtentLength   uint32
	RecordedLength uint32
	InfoLength     uint32
	Location       LbAddr
}

func NewExtentExtended

func NewExtentExtended(b []byte) ExtentExtended

func (ExtentExtended) GetLength

func (e ExtentExtended) GetLength() uint32

func (ExtentExtended) GetLocation

func (e ExtentExtended) GetLocation() uint64

func (ExtentExtended) GetPartition

func (e ExtentExtended) GetPartition() uint16

func (ExtentExtended) HasExtended

func (e ExtentExtended) HasExtended() bool

func (ExtentExtended) IsNotRecorded

func (e ExtentExtended) IsNotRecorded() bool

func (ExtentExtended) SetLength

func (e ExtentExtended) SetLength(length uint32)

type ExtentInterface

type ExtentInterface interface {
	GetLocation() uint64
	GetLength() uint32
	SetLength(uint32)
	GetPartition() uint16
	IsNotRecorded() bool
	HasExtended() bool
}

func GetAllocationDescriptor

func GetAllocationDescriptor(t AllocationType, b []byte) ExtentInterface

func GetAllocationDescriptors

func GetAllocationDescriptors(t AllocationType, b []byte, len uint32) (list []ExtentInterface)

type ExtentLong

type ExtentLong struct {
	Length   uint32
	Location LbAddr
}

func NewExtentLong

func NewExtentLong(b []byte) ExtentLong

func (ExtentLong) GetLength

func (e ExtentLong) GetLength() uint32

func (ExtentLong) GetLocation

func (e ExtentLong) GetLocation() uint64

func (ExtentLong) GetPartition

func (e ExtentLong) GetPartition() uint16

func (ExtentLong) HasExtended

func (e ExtentLong) HasExtended() bool

func (ExtentLong) IsNotRecorded

func (e ExtentLong) IsNotRecorded() bool

func (ExtentLong) SetLength

func (e ExtentLong) SetLength(length uint32)

type ExtentSmall

type ExtentSmall struct {
	Length   uint16
	Location uint64
}

func NewExtentSmall

func NewExtentSmall(b []byte) ExtentSmall

func (ExtentSmall) GetLength

func (e ExtentSmall) GetLength() uint32

func (ExtentSmall) GetLocation

func (e ExtentSmall) GetLocation() uint64

func (ExtentSmall) GetPartition

func (e ExtentSmall) GetPartition() uint16

func (ExtentSmall) HasExtended

func (e ExtentSmall) HasExtended() bool

func (ExtentSmall) IsNotRecorded

func (e ExtentSmall) IsNotRecorded() bool

func (ExtentSmall) SetLength

func (e ExtentSmall) SetLength(length uint32)

type File

type File struct {
	Udf *Udf
	Fid *FileIdentifierDescriptor
	// contains filtered or unexported fields
}

File is a os.FileInfo-compatible wrapper around an ISO-13346 "UDF" directory entry

func (*File) FileEntry

func (f *File) FileEntry() FileEntryInterface

func (*File) GetFileEntryPosition

func (f *File) GetFileEntryPosition() int64

func (*File) IsDir

func (f *File) IsDir() bool

IsDir returns true if the entry is a directory or false otherwise

func (*File) ModTime

func (f *File) ModTime() time.Time

ModTime returns the entry's recording time

func (*File) Mode

func (f *File) Mode() os.FileMode

Mode returns os.FileMode flag set with the os.ModeDir flag enabled in case of directories

func (*File) Name

func (f *File) Name() string

Name returns the base name of the given entry

func (*File) NewReader

func (f *File) NewReader() *MultiSectionReader

func (*File) ReadDir

func (f *File) ReadDir() []File

ReadDir returns the children entries in case of a directory

func (*File) Size

func (f *File) Size() int64

Size returns the size in bytes of the extent occupied by the file or directory

func (*File) Sys

func (f *File) Sys() interface{}

type FileEntry

type FileEntry struct {
	Descriptor                    Descriptor
	ICBTag                        *ICBTag
	Uid                           uint32
	Gid                           uint32
	Permissions                   uint32
	FileLinkCount                 uint16
	RecordFormat                  uint8
	RecordDisplayAttributes       uint8
	RecordLength                  uint32
	InformationLength             uint64
	LogicalBlocksRecorded         uint64
	AccessTime                    time.Time
	ModificationTime              time.Time
	AttributeTime                 time.Time
	Checkpoint                    uint32
	ExtendedAttributeICB          ExtentLong
	ImplementationIdentifier      EntityID
	UniqueId                      uint64
	LengthOfExtendedAttributes    uint32
	LengthOfAllocationDescriptors uint32
	ExtendedAttributes            []byte
	AllocationDescriptors         []byte
	// Manual field
	Partition uint16
}

func (*FileEntry) FromBytes

func (fe *FileEntry) FromBytes(b []byte) *FileEntry

func (*FileEntry) GetAllocationDescriptors

func (fe *FileEntry) GetAllocationDescriptors() (list []ExtentInterface)

func (*FileEntry) GetICBTag

func (fe *FileEntry) GetICBTag() *ICBTag

func (*FileEntry) GetInformationLength

func (fe *FileEntry) GetInformationLength() uint64

func (*FileEntry) GetModificationTime

func (fe *FileEntry) GetModificationTime() time.Time

func (*FileEntry) GetPartition

func (fe *FileEntry) GetPartition() uint16

func (*FileEntry) GetPermissions

func (fe *FileEntry) GetPermissions() uint32

type FileEntryInterface

type FileEntryInterface interface {
	GetAllocationDescriptors() []ExtentInterface
	GetPermissions() uint32
	GetInformationLength() uint64
	GetModificationTime() time.Time
	GetICBTag() *ICBTag
	GetPartition() uint16
}

func NewFileEntry

func NewFileEntry(partition uint16, b []byte) (fe FileEntryInterface)

type FileIdentifierDescriptor

type FileIdentifierDescriptor struct {
	Descriptor                Descriptor
	FileVersionNumber         uint16
	FileCharacteristics       uint8
	LengthOfFileIdentifier    uint8
	ICB                       ExtentLong
	LengthOfImplementationUse uint16
	ImplementationUse         EntityID
	FileIdentifier            string
}

func NewFileIdentifierDescriptor

func NewFileIdentifierDescriptor(b []byte) *FileIdentifierDescriptor

func (*FileIdentifierDescriptor) FromBytes

func (*FileIdentifierDescriptor) Len

func (fid *FileIdentifierDescriptor) Len() uint64

type FileSetDescriptor

type FileSetDescriptor struct {
	Descriptor              Descriptor
	RecordingDateTime       time.Time
	InterchangeLevel        uint16
	MaximumInterchangeLevel uint16
	CharacterSetList        uint32
	MaximumCharacterSetList uint32
	FileSetNumber           uint32
	FileSetDescriptorNumber uint32
	LogicalVolumeIdentifier string
	FileSetIdentifier       string
	CopyrightFileIdentifier string
	AbstractFileIdentifier  string
	RootDirectoryICB        ExtentLong
	DomainIdentifier        EntityID
	NexExtent               ExtentLong
}

func NewFileSetDescriptor

func NewFileSetDescriptor(b []byte) *FileSetDescriptor

func (*FileSetDescriptor) FromBytes

func (fsd *FileSetDescriptor) FromBytes(b []byte) *FileSetDescriptor

type ICBTag

type ICBTag struct {
	PriorRecordedNumberOfDirectEntries uint32
	StrategyType                       uint16
	StrategyParameter                  uint16
	MaximumNumberOfEntries             uint16
	FileType                           uint8
	ParentICBLocation                  uint64
	Flags                              uint16
	AllocationType                     AllocationType
}

func NewICBTag

func NewICBTag(b []byte) *ICBTag

func (*ICBTag) FromBytes

func (itag *ICBTag) FromBytes(b []byte) *ICBTag

type LbAddr

type LbAddr struct {
	LogicalBlockNumber       uint32
	PartitionReferenceNumber uint16
}

func (*LbAddr) FromBytes

func (l *LbAddr) FromBytes(data []byte) LbAddr

type LogicalVolumeDescriptor

type LogicalVolumeDescriptor struct {
	Descriptor                     Descriptor
	VolumeDescriptorSequenceNumber uint32
	LogicalVolumeIdentifier        string
	LogicalBlockSize               uint32
	DomainIdentifier               EntityID
	LogicalVolumeContentsUse       ExtentLong
	MapTableLength                 uint32
	NumberOfPartitionMaps          uint32
	ImplementationIdentifier       EntityID
	ImplementationUse              []byte
	IntegritySequenceExtent        Extent
	PartitionMaps                  []PartitionMap
}

func NewLogicalVolumeDescriptor

func NewLogicalVolumeDescriptor(b []byte) *LogicalVolumeDescriptor

func (*LogicalVolumeDescriptor) FromBytes

type MultiSectionReader

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

func (*MultiSectionReader) Read

func (r *MultiSectionReader) Read(p []byte) (n int, err error)

func (*MultiSectionReader) ReadAt

func (r *MultiSectionReader) ReadAt(p []byte, off int64) (n int, err error)

func (*MultiSectionReader) Seek

func (r *MultiSectionReader) Seek(offset int64, whence int) (n int64, err error)

func (*MultiSectionReader) Size

func (r *MultiSectionReader) Size() int64

type PartitionDescriptor

type PartitionDescriptor struct {
	Descriptor                     Descriptor
	VolumeDescriptorSequenceNumber uint32
	PartitionFlags                 uint16
	PartitionNumber                uint16
	PartitionContents              EntityID
	PartitionContentsUse           []byte
	AccessType                     uint32
	PartitionStartingLocation      uint32
	PartitionLength                uint32
	ImplementationIdentifier       EntityID
	ImplementationUse              []byte
}

func NewPartitionDescriptor

func NewPartitionDescriptor(b []byte) *PartitionDescriptor

func (*PartitionDescriptor) FromBytes

func (pd *PartitionDescriptor) FromBytes(b []byte) *PartitionDescriptor

type PartitionMap

type PartitionMap struct {
	PartitionMapType     uint8
	PartitionMapLength   uint8
	VolumeSequenceNumber uint16
	PartitionNumber      uint16
	PartitionStart       uint32
}

func (*PartitionMap) FromBytes

func (pm *PartitionMap) FromBytes(b []byte) *PartitionMap

type PrimaryVolumeDescriptor

type PrimaryVolumeDescriptor struct {
	Descriptor                                  Descriptor
	VolumeDescriptorSequenceNumber              uint32
	PrimaryVolumeDescriptorNumber               uint32
	VolumeIdentifier                            string
	VolumeSequenceNumber                        uint16
	MaximumVolumeSequenceNumber                 uint16
	InterchangeLevel                            uint16
	MaximumInterchangeLevel                     uint16
	CharacterSetList                            uint32
	MaximumCharacterSetList                     uint32
	VolumeSetIdentifier                         string
	VolumeAbstract                              Extent
	VolumeCopyrightNoticeExtent                 Extent
	ApplicationIdentifier                       EntityID
	RecordingDateTime                           time.Time
	ImplementationIdentifier                    EntityID
	ImplementationUse                           []byte
	PredecessorVolumeDescriptorSequenceLocation uint32
	Flags                                       uint16
}

func NewPrimaryVolumeDescriptor

func NewPrimaryVolumeDescriptor(b []byte) *PrimaryVolumeDescriptor

func (*PrimaryVolumeDescriptor) FromBytes

type Udf

type Udf struct {
	SECTOR_SIZE uint64
	// contains filtered or unexported fields
}

Udf is a wrapper around an .iso file that allows reading its ISO-13346 "UDF" data

func NewUdfFromReader

func NewUdfFromReader(r io.ReaderAt) (*Udf, error)

NewUdfFromReader returns an Udf reader reading from a given file

func (*Udf) GetReader

func (udf *Udf) GetReader() io.ReaderAt

func (*Udf) LogicalPartitionStart

func (udf *Udf) LogicalPartitionStart(partition uint16) (logical uint64)

func (*Udf) PhysicalPartitionStart

func (udf *Udf) PhysicalPartitionStart(partition uint16) (physical uint64)

XXX - unused

func (*Udf) ReadDir

func (udf *Udf) ReadDir(fe FileEntryInterface) []File

func (*Udf) ReadSector

func (udf *Udf) ReadSector(sectorNumber uint64) []byte

func (*Udf) ReadSectors

func (udf *Udf) ReadSectors(sectorNumber uint64, sectorsCount uint64) []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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