12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package fs
- import (
- "fmt"
- "os"
- "path/filepath"
- )
- const (
-
- DefaultProcMountPoint = "/proc"
-
- DefaultSysMountPoint = "/sys"
-
- DefaultConfigfsMountPoint = "/sys/kernel/config"
- )
- type FS string
- func NewFS(mountPoint string) (FS, error) {
- info, err := os.Stat(mountPoint)
- if err != nil {
- return "", fmt.Errorf("could not read %s: %s", mountPoint, err)
- }
- if !info.IsDir() {
- return "", fmt.Errorf("mount point %s is not a directory", mountPoint)
- }
- return FS(mountPoint), nil
- }
- func (fs FS) Path(p ...string) string {
- return filepath.Join(append([]string{string(fs)}, p...)...)
- }
|