utils

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

* Copyright (c) 2025 System233 * * This software is released under the MIT License. * https://opensource.org/licenses/MIT

* Copyright (c) 2025 System233 * * This software is released under the MIT License. * https://opensource.org/licenses/MIT

* Copyright (c) 2025 System233 * * This software is released under the MIT License. * https://opensource.org/licenses/MIT

Index

Constants

This section is empty.

Variables

View Source
var GlobalFlag struct {
	Debug             bool
	FuseOverlayFS     string
	FuseOverlayFSArgs string
}
View Source
var MountFlagMap = map[string]int{
	"active":      syscall.MS_ACTIVE,
	"async":       syscall.MS_ASYNC,
	"bind":        syscall.MS_BIND,
	"rbind":       syscall.MS_BIND | syscall.MS_REC,
	"dirsync":     syscall.MS_DIRSYNC,
	"invalidate":  syscall.MS_INVALIDATE,
	"i_version":   syscall.MS_I_VERSION,
	"kernmount":   syscall.MS_KERNMOUNT,
	"mandlock":    syscall.MS_MANDLOCK,
	"move":        syscall.MS_MOVE,
	"noatime":     syscall.MS_NOATIME,
	"nodev":       syscall.MS_NODEV,
	"nodiratime":  syscall.MS_NODIRATIME,
	"noexec":      syscall.MS_NOEXEC,
	"nosuid":      syscall.MS_NOSUID,
	"nouser":      syscall.MS_NOUSER,
	"posixacl":    syscall.MS_POSIXACL,
	"private":     syscall.MS_PRIVATE,
	"rdonly":      syscall.MS_RDONLY,
	"rec":         syscall.MS_REC,
	"relatime":    syscall.MS_RELATIME,
	"remount":     syscall.MS_REMOUNT,
	"shared":      syscall.MS_SHARED,
	"silent":      syscall.MS_SILENT,
	"slave":       syscall.MS_SLAVE,
	"strictatime": syscall.MS_STRICTATIME,
	"sync":        syscall.MS_SYNC,
	"synchronous": syscall.MS_SYNCHRONOUS,
	"unbindable":  syscall.MS_UNBINDABLE,
}
View Source
var OverlayFlag struct {
	Self  string
	Shell string
	Args  []string
}

Functions

func BuildHelpMessage

func BuildHelpMessage(help string) string

func CopyFile

func CopyFile(destPath string, src io.Reader, perm os.FileMode, force bool) error

func CopyFileIO

func CopyFileIO(src, dst string) error
func CopySymlink(destPath string, src string, force bool) error

func CreateCommand

func CreateCommand(name string) *exec.Cmd

func Debug

func Debug(v ...any)

func DefaultShell

func DefaultShell() string

func DumpJsonData added in v1.4.6

func DumpJsonData(v interface{}) ([]byte, error)

func DumpJsonFile added in v1.4.6

func DumpJsonFile(file string, v interface{}) error

func DumpYamlData added in v1.4.6

func DumpYamlData(v interface{}) ([]byte, error)

func DumpYamlFile added in v1.4.6

func DumpYamlFile(file string, v interface{}) error

func Exec

func Exec(args ...string)

func ExecFuseOvlMain

func ExecFuseOvlMain(args []string) error

func ExecRaw

func ExecRaw(args ...string) error

func ExitWith

func ExitWith(err error, v ...any)

func FuseOvlMain

func FuseOvlMain(args []string) error

func FuseOvlMount

func FuseOvlMount(opt FuseOvlMountFlag) error

func GetKillerExec added in v1.4.14

func GetKillerExec() (string, error)

func IsExist

func IsExist(name string) bool

func IsSameFile

func IsSameFile(file1 string, file2 string) (bool, error)

func LoadJsonData added in v1.4.6

func LoadJsonData(data []byte, v interface{}) error

func LoadJsonFile added in v1.4.6

func LoadJsonFile(file string, v interface{}) error

func LoadYamlData added in v1.4.6

func LoadYamlData(data []byte, v interface{}) error

func LoadYamlFile added in v1.4.6

func LoadYamlFile(file string, v interface{}) error

func MkdirAlls

func MkdirAlls(dirs []string, mode os.FileMode) error

func Mount

func Mount(opt *MountOption) error

func MountAll

func MountAll(opts []MountOption) error

func MountBind

func MountBind(source string, target string, flags int) error

func Must

func Must(err error, v ...any)

func NewCommand

func NewCommand(name string, args ...string) *exec.Cmd

func OpenFile

func OpenFile(destPath string, perm os.FileMode, force bool) (*os.File, error)

func ParseMountFlag

func ParseMountFlag(flag string) int

func RunCommand

func RunCommand(name string, args ...string) error

func SetupEnvVar

func SetupEnvVar() error

func SwitchTo

func SwitchTo(next string, flags *SwitchFlags) error

func WriteFile

func WriteFile(destPath string, data []byte, perm os.FileMode, force bool) error

Types

type ExitStatus

type ExitStatus struct {
	ExitCode int
}

func (*ExitStatus) Error

func (s *ExitStatus) Error() string

type FuseOvlMountFlag

type FuseOvlMountFlag struct {
	RedirectDir      string   // redirect_dir=%s
	Context          string   // context=%s
	LowerDir         []string // lowerdir=%s
	UpperDir         string   // upperdir=%s
	WorkDir          string   // workdir=%s
	UIDMapping       string   // uidmapping=%s
	GIDMapping       string   // gidmapping=%s
	Timeout          string   // timeout=%s
	Threaded         string   // threaded=%d,
	Fsync            string   // fsync=%d,
	FastIno          string   // fast_ino=%d
	Writeback        string   // writeback=%d,
	NoXattrs         string   // noxattrs=%d,出
	Plugins          string   // plugins=%s
	XattrPermissions string   // xattr_permissions=%d
	SquashToRoot     bool     // squash_to_root
	SquashToUID      string   // squash_to_uid=%d,
	SquashToGID      string   // squash_to_gid=%d,
	StaticNlink      bool     // static_nlink
	Volatile         bool     // volatile
	NoACL            bool     // noacl

	Target string   // 挂载目标
	Flags  []string // 额外的标志选项
	Args   []string // 附加参数
}

type MountOption

type MountOption struct {
	Source string
	Target string
	FSType string
	Flags  int
	Data   string
}

func ParseMountOption

func ParseMountOption(item string) MountOption

func (*MountOption) Mount

func (opt *MountOption) Mount() error

type SwitchFlags

type SwitchFlags struct {
	UID           int
	GID           int
	Cloneflags    uintptr
	Args          []string
	NoDefaultArgs bool
	UidMappings   []string
	GidMappings   []string
}

Jump to

Keyboard shortcuts

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