Documentation ¶
Overview ¶
Package aghos contains utilities for functions requiring system calls and other OS-specific APIs. OS-specific network handling should go to aghnet instead.
Index ¶
- Constants
- Variables
- func ConfigureSyslog(serviceName string) error
- func HaveAdminRights() (bool, error)
- func IsOpenWrt() (ok bool)
- func PIDByCommand(command string, except ...int) (pid int, err error)
- func RootDirFS() (fsys fs.FS)
- func RunCommand(command string, arguments ...string) (code int, output string, err error)
- func SetGroup(groupName string) (err error)
- func SetRlimit(val uint64) (err error)
- func SetUser(userName string) (err error)
- func Unsupported(op string) (err error)
- type FSWatcher
- type FileWalker
- type UnsupportedError
Constants ¶
const MaxCmdOutputSize = 64 * 1024
MaxCmdOutputSize is the maximum length of performed shell command output in bytes.
Variables ¶
var NativeEndian = binary.LittleEndian
NativeEndian is the native endianness of this system.
Functions ¶
func ConfigureSyslog ¶
ConfigureSyslog reroutes standard logger output to syslog.
func HaveAdminRights ¶
HaveAdminRights checks if the current user has root (administrator) rights.
func PIDByCommand ¶ added in v0.107.0
PIDByCommand searches for process named command and returns its PID ignoring the PIDs from except. If no processes found, the error returned.
func RootDirFS ¶ added in v0.107.0
RootDirFS returns the fs.FS rooted at the operating system's root.
func RunCommand ¶
RunCommand runs shell command.
func SetRlimit ¶
SetRlimit sets user-specified limit of how many fd's we can use.
See https://github.com/AdguardTeam/AdGuardHome/internal/issues/659.
func Unsupported ¶ added in v0.107.0
Unsupported is a helper that returns an *UnsupportedError with the Op field set to op and the OS field set to the current OS.
Types ¶
type FSWatcher ¶ added in v0.107.0
type FSWatcher interface { io.Closer // Events should return a read-only channel which notifies about events. Events() (e <-chan event) // Add should check if the file named name is accessible and starts tracking // it. Add(name string) (err error) }
FSWatcher tracks all the fyle system events and notifies about those.
TODO(e.burkov, a.garipov): Move into another package like aghfs.
func NewOSWritesWatcher ¶ added in v0.107.0
NewOSWritesWatcher creates FSWatcher that tracks the real file system of the OS and notifies only about writing events.
type FileWalker ¶ added in v0.107.0
FileWalker is the signature of a function called for files in the file tree. As opposed to filepath.Walk it only walk the files (not directories) matching the provided pattern and those returned by function itself. All patterns should be valid for fs.Glob. If FileWalker returns false for cont then walking terminates. Prefer using bufio.Scanner to read the r since the input is not limited.
TODO(e.burkov, a.garipov): Move into another package like aghfs.
TODO(e.burkov): Think about passing filename or any additional data.
type UnsupportedError ¶ added in v0.107.0
UnsupportedError is returned by functions and methods when a particular operation Op cannot be performed on the current OS.
func (*UnsupportedError) Error ¶ added in v0.107.0
func (err *UnsupportedError) Error() (msg string)
Error implements the error interface for *UnsupportedError.