subprocfs

package
v0.0.0-...-9f8393d Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOverrideReadOnly = overrideReadOnlyErr(syscall.EACCES)
View Source
var ErrProcPidPathHidden = procPidPathHiddenErr(syscall.ENOENT)

Functions

func GetRelatedPIDs

func GetRelatedPIDs(procPath string, pid uint32, callback func(pid uint32)) error

GetRelatedPIDs calls callback for all the related pids: all parents and children, including pid itself. procPath is typically "/proc"

func GetRelatedPIDsMap

func GetRelatedPIDsMap(procPath string, pid uint32) (map[uint32]struct{}, error)

Types

type FS

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

func New

func New(infos ...ProcInfo) *FS

func (*FS) LimitPIDs

func (f *FS) LimitPIDs(yes bool)

LimitPIDs will limit pids accessible in the subprocfs (i.e. /proc/PID)

func (*FS) Root

func (f *FS) Root() (fs.Node, error)

func (*FS) SetLogger

func (f *FS) SetLogger(logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
})

func (*FS) Statfs

func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error

type ProcInfo

type ProcInfo procInfo

func CPUInfo

func CPUInfo(maxCPUs int) ProcInfo

CPUInfo limits the number of visible CPUs (cores/threads)

func EmptyMountInfo

func EmptyMountInfo() ProcInfo

EmptyMountInfo returns empty contents for /proc/PID/mountinfo files. This can be prudent when employing RestrictMounts.

func EmptyMountStats

func EmptyMountStats() ProcInfo

EmptyMountStats returns empty contents for /proc/PID/mountstats files.

func MemInfo

func MemInfo(memLimit int) ProcInfo

MemInfo limits the memory reported by /proc/meminfo Note that this is a very naive implementation and might not reflect actual free or available memory.

func NewProcInfo

func NewProcInfo(pathPattern string, content string) ProcInfo

func RestrictMounts

func RestrictMounts(path string, reroot string) ProcInfo

RestrictMounts excludes mounts not under path from /proc/PID/mounts (and /proc/mounts) empty string can be used to exclude all mounts. reroot can be used to re-root the mounts under path, or empty string to use actual path. For example: RestrictMounts("/foo/bar", "/qux") will exclude "/hello" and convert "/foo/bar/baz" into "/qux/baz"

Jump to

Keyboard shortcuts

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