sysfs

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sysfs provides a file system implementation that ensures safe file operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsafeFilePathOutsideDirectory indicates the file path is outside the allowed directory.
	ErrUnsafeFilePathOutsideDirectory = errors.New("unsafe file path: outside allowed directory")
	// ErrUnsafeFilePathSymlink indicates the file path is a symlink which is not allowed.
	ErrUnsafeFilePathSymlink = errors.New("unsafe file path: symlink detected")
	// ErrConfigFileTooLarge indicates the config file exceeds the maximum allowed size.
	ErrConfigFileTooLarge = errors.New("config file too large")
)

Functions

func SafeOpen

func SafeOpen(filePath string) (*os.File, error)

SafeOpen ensures the file path is safe and opens the file.

Types

type SysFS

type SysFS struct{}

SysFS implements the fs.FS interface and provides safe file system operations.

func NewSysFS

func NewSysFS() *SysFS

NewSysFS creates and returns a new instance of SysFS.

func (SysFS) Open

func (s SysFS) Open(name string) (fs.File, error)

Open safely opens the file at the given name using path validation. It implements the fs.FS interface Open method.

Jump to

Keyboard shortcuts

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