1 // Copyright 2017 The Prometheus Authors 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 //go:build linux 15 // +build linux 16 17 package sysfs 18 19 import ( 20 "github.com/prometheus/procfs/internal/fs" 21 ) 22 23 // FS represents the pseudo-filesystem sys, which provides an interface to 24 // kernel data structures. 25 type FS struct { 26 sys fs.FS 27 } 28 29 // DefaultMountPoint is the common mount point of the sys filesystem. 30 const DefaultMountPoint = fs.DefaultSysMountPoint 31 32 // NewDefaultFS returns a new FS mounted under the default mountPoint. It will error 33 // if the mount point can't be read. 34 func NewDefaultFS() (FS, error) { 35 return NewFS(DefaultMountPoint) 36 } 37 38 // NewFS returns a new FS mounted under the given mountPoint. It will error 39 // if the mount point can't be read. 40 func NewFS(mountPoint string) (FS, error) { 41 fs, err := fs.NewFS(mountPoint) 42 if err != nil { 43 return FS{}, err 44 } 45 return FS{fs}, nil 46 } 47