Documentation ¶
Overview ¶
Package sysutil is a cross-platform compatibility layer on top of package syscall. It exposes APIs for common operations that require package syscall and re-exports several symbols from package syscall that are known to be safe. Using package syscall directly from other packages is forbidden.
Index ¶
- Constants
- func ExceedsPermissions(objectMode, allowedMode os.FileMode) bool
- func ExitStatus(err *exec.ExitError) int
- func IsCrossDeviceLinkErrno(errno error) bool
- func IsErrConnectionRefused(err error) bool
- func IsErrConnectionReset(err error) bool
- func ProcessIdentity() string
- func RefreshSignaledChan() <-chan os.Signal
- func ResizeLargeFile(path string, bytes int64) error
- type ACLInfo
- type Errno
- type Signal
Constants ¶
const ( ECONNRESET = syscall.ECONNRESET ECONNREFUSED = syscall.ECONNREFUSED )
Exported syscall.Errno constants.
Variables ¶
This section is empty.
Functions ¶
func ExceedsPermissions ¶
ExceedsPermissions returns true if the passed os.FileMode represents a more stringent set of permissions than the ACLInfo's mode.
For example, calling this function with an objectMode of 0640 will return false if the passed allowedMode is 0600.
func ExitStatus ¶
ExitStatus returns the exit status contained within an exec.ExitError.
func IsCrossDeviceLinkErrno ¶
IsCrossDeviceLinkErrno checks whether the given error object (as extracted from an *os.LinkError) is a cross-device link/rename error.
func IsErrConnectionRefused ¶
IsErrConnectionRefused returns true if an error is a "connection refused" error.
func IsErrConnectionReset ¶
IsErrConnectionReset returns true if an error is a "connection reset by peer" error.
func ProcessIdentity ¶
func ProcessIdentity() string
ProcessIdentity returns a string describing the user and group that this process is running as.
func RefreshSignaledChan ¶
RefreshSignaledChan returns a channel that will receive an os.Signal whenever the process receives a "refresh" signal (currently SIGHUP). A refresh signal indicates that the user wants to apply nondisruptive updates, like reloading certificates and flushing log files.
On Windows, the returned channel will never receive any values, as Windows does not support signals. Consider exposing a refresh trigger through other means if Windows support is important.
func ResizeLargeFile ¶
ResizeLargeFile resizes the file at the given path to be the provided length in bytes. If no file exists at path, ResizeLargeFile creates a file. All disk blocks within the new file are allocated, and there are no sparse regions.
On Linux, it uses the fallocate syscall to efficiently allocate disk space. On other platforms, it naively writes the specified number of bytes, which can take a long time.
Types ¶
type ACLInfo ¶
type ACLInfo interface { // UID returns the ID of the user that owns the file in question. UID() uint64 // GID returns the ID of the group that owns the file in question. GID() uint64 // IsOwnedByUID returns true of the passed UID is equal to the UID of the file in question. IsOwnedByUID(uint64) bool // IsOwnedByGID returns true of the passed GID is equal to the GID of the file in question. IsOwnedByGID(uint64) bool // Mode returns the os.FileMode representing the files permissions. Implementers of this // interface should return only the result of the `Perm` function in os.FileMode, to // ensure that only permissions are returned. Mode() os.FileMode }
ACLInfo represents access control information for a file in the filesystem. It can be used to determine if a file has the correct permissions associated with it.
func GetFileACLInfo ¶
GetFileACLInfo returns an ACLInfo that has the UID and GID populated from the system specific file information.