utils

package
v0.0.0-...-ef8be33 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearBit

func ClearBit(n *uint64, offset uint)

func ClearBits

func ClearBits(n *uint64, mask uint64)

func CopyRegularFileByPath

func CopyRegularFileByPath(src, dst string) error

CopyRegularFileByPath copies a file from src to dst

func CopyRegularFileByRelativePath

func CopyRegularFileByRelativePath(srcName string, dstDir *os.File, dstName string) error

CopyRegularFileByRelativePath copies a file from src to dst, where destination is relative to a given directory. This function needs needed capabilities to be set before it is called.

func CreateAt

func CreateAt(dir *os.File, relativePath string) (*os.File, error)

CreateAt implements the same logic as os.Create using directory FD and relative path.

func Dup

func Dup(file *os.File) (*os.File, error)

Dup is a wrapper function to the `dup` syscall using golang types.

func GenerateRandomDuration

func GenerateRandomDuration(min, max int) time.Duration

GenerateRandomDuration returns a random duration between min and max, inclusive

func HasBit

func HasBit(n uint64, offset uint) bool

func HashTaskID

func HashTaskID(arg1 uint32, arg2 uint64) uint32

func HashU32AndU64

func HashU32AndU64(arg1 uint32, arg2 uint64) uint32

HashU32AndU64 is a wrapper around Murmur32 making sure network byte order is used.

func IsDirEmpty

func IsDirEmpty(pathname string) (bool, error)

IsDirEmpty returns true if directory contains no files

func Max

func Max(x, y uint64) uint64

func Min

func Min(x, y uint64) uint64

func MkdirAt

func MkdirAt(dir *os.File, relativePath string, perm fs.FileMode) error

MkdirAt is a wrapper function to the `mkdirat` syscall using golang types.

func MkdirAtExist

func MkdirAtExist(dir *os.File, relativePath string, perm fs.FileMode) error

MkdirAtExist is a wrapper function to the `mkdirat` syscall using golang types, ignoring EEXIST error.

func Murmur32

func Murmur32(key []byte) uint32

Murmur32 is a Murmur3 32-bit hash function implementation.

func OpenAt

func OpenAt(dir *os.File, relativePath string, flags int, perm fs.FileMode) (*os.File, error)

OpenAt is a wrapper function to the `openat` syscall using golang types.

func OpenExistingDir

func OpenExistingDir(p string) (*os.File, error)

OpenExistingDir open a directory with given path, and return the os.File of it.

func ParseSymbol

func ParseSymbol(address uint64, table *environment.KernelSymbolTable) environment.KernelSymbol

func RemoveAt

func RemoveAt(dir *os.File, relativePath string, flags int) error

RemoveAt is a wrapper function to the `unlinkat` syscall using golang types.

func RenameAt

func RenameAt(olddir *os.File, oldpath string, newdir *os.File, newpath string) error

RenameAt is a wrapper function to the `renameat` syscall using golang types.

func RoundToClosestN

func RoundToClosestN(val int, n int) int

RoundToClosestN rounds a number to the closest multiple of n.

func SetBit

func SetBit(n *uint64, offset uint)

func SymbolToOffset

func SymbolToOffset(path, symbol string) (uint32, error)

SymbolToOffset attempts to resolve a 'symbol' name in the binary found at 'path' to an offset. The offset can be used for attaching a u(ret)probe

Types

type Cloner

type Cloner[T any] interface {
	Clone() T
}

Cloner is a generic interface for objects that can clone themselves.

type Iterator

type Iterator[T any] interface {
	// HasNext returns true if there are more elements to iterate.
	HasNext() bool

	// Next returns the next element in the iteration.
	Next() T
}

Iterator is a generic interface for iterators.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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