ldcache

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 10 Imported by: 0

README

GoDoc

ldcache

Library to read/write ld.so.cache files.

Opening a ld.so.cache file

ldso, err := ldcache.Open("/etc/ld.so.cache")
if err != nil {
    // ...
}

After loading a ld.so.cache file, it is possible to manipulate its Entries, such as adding or removing entries, then generate a new file that will match the updated data.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Flags      Flags
	Key, Value string
	OSVersion  uint32
	HWCap      uint64
	// contains filtered or unexported fields
}

Entry represents an entry in a ld.so.cache file

func (*Entry) Bytes

func (e *Entry) Bytes(order binary.ByteOrder) []byte

Bytes return the entry as it would appear in a file, as binary format

func (*Entry) String

func (e *Entry) String() string

type EntryList added in v0.1.2

type EntryList []*Entry

EntryList implements the required methods to make Entries sortable

func (EntryList) Len added in v0.1.2

func (e EntryList) Len() int

func (EntryList) Less added in v0.1.2

func (e EntryList) Less(i, j int) bool

func (EntryList) Swap added in v0.1.2

func (e EntryList) Swap(i, j int)

type File

type File struct {
	Header  *Header
	Entries EntryList
	Order   binary.ByteOrder
}

File represents a ld.so.cache file data

func New

func New() *File

New returns a new empty ld.so.cache file, to which entries can be added

func Open

func Open(filename string) (*File, error)

Open opens the provided filename and will read it as a ld.so.cache file, returning an instance of File on successful read.

func Read

func Read(in io.Reader) (*File, error)

Read reads a ld.so.cache file from a given reader, and returns an instance of File on successful read. Byte order of the read file will be detected automatically

func ReadWithOrder

func ReadWithOrder(in io.Reader, order binary.ByteOrder) (*File, error)

ReadWithOrder reads data from a given ld.so.cache file using the specified byte order note that if the byte order is wrong, this may result in attempts to allocate large amounts of memory

func (*File) ReadFrom

func (f *File) ReadFrom(in io.Reader) error

ReadFrom will read data from a given reader, assuming the header has already been read

func (*File) SaveAs

func (f *File) SaveAs(filename string) error

SaveAs creates a file with the given filename and writes the ld.so.cache data to it

func (*File) Unique

func (f *File) Unique()

Unique checks for any duplicate vlaues in Entries and ensures there is only one entry for each filename + Flags

func (*File) WriteTo

func (f *File) WriteTo(w io.Writer) error

WriteTo updates information found in Header and writes the file to the given io.Writer.

type Flags

type Flags int32

func (Flags) String

func (f Flags) String() string

String will return flags as a string as closely as to what ldconfig -p shows

type Header struct {
	Magic     [len(magicPrefix)]byte
	Version   [3]byte
	NLibs     uint32
	TableSize uint32
	// contains filtered or unexported fields
}

func (*Header) Bytes

func (h *Header) Bytes(order binary.ByteOrder) []byte

func (*Header) String

func (h *Header) String() string

Jump to

Keyboard shortcuts

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