diff --git a/blockdevice/stats.go b/blockdevice/stats.go index bc6b6a17..1287b166 100644 --- a/blockdevice/stats.go +++ b/blockdevice/stats.go @@ -21,7 +21,8 @@ import ( "os" "strings" - filesystem "github.com/prometheus/procfs/internal/fs" + "github.com/prometheus/procfs" + "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -215,30 +216,30 @@ const ( // FS represents the pseudo-filesystems proc and sys, which provides an // interface to kernel data structures. type FS struct { - proc *filesystem.FS - sys *filesystem.FS + proc *fs.FS + sys *fs.FS } // NewDefaultFS returns a new blockdevice fs using the default mountPoints for proc and sys. // It will error if either of these mount points can't be read. func NewDefaultFS() (FS, error) { - return NewFS(filesystem.DefaultProcMountPoint, filesystem.DefaultSysMountPoint) + return NewFS(fs.DefaultProcMountPoint, fs.DefaultSysMountPoint) } // NewFS returns a new blockdevice fs using the given mountPoints for proc and sys. // It will error if either of these mount points can't be read. func NewFS(procMountPoint string, sysMountPoint string) (FS, error) { if strings.TrimSpace(procMountPoint) == "" { - procMountPoint = filesystem.DefaultProcMountPoint + procMountPoint = fs.DefaultProcMountPoint } - procfs, err := filesystem.NewFS(procMountPoint) + procfs, err := fs.NewFS(procMountPoint) if err != nil { return FS{}, err } if strings.TrimSpace(sysMountPoint) == "" { - sysMountPoint = filesystem.DefaultSysMountPoint + sysMountPoint = fs.DefaultSysMountPoint } - sysfs, err := filesystem.NewFS(sysMountPoint) + sysfs, err := fs.NewFS(sysMountPoint) if err != nil { return FS{}, err } @@ -483,5 +484,5 @@ func (fs FS) SysBlockDeviceSize(device string) (uint64, error) { if err != nil { return 0, err } - return filesystem.SectorSize * size, nil + return procfs.SectorSize * size, nil } diff --git a/btrfs/get.go b/btrfs/get.go index ac9c205c..4fce6212 100644 --- a/btrfs/get.go +++ b/btrfs/get.go @@ -22,6 +22,7 @@ import ( "strconv" "strings" + "github.com/prometheus/procfs" "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) @@ -208,7 +209,7 @@ func (r *reader) readDeviceInfo(d string) map[string]*Device { info := make(map[string]*Device, len(devs)) for _, n := range devs { info[n] = &Device{ - Size: fs.SectorSize * r.readValue("devices/"+n+"/size"), + Size: procfs.SectorSize * r.readValue("devices/"+n+"/size"), } } diff --git a/fs.go b/fs.go index 4980c875..9bdaccc7 100644 --- a/fs.go +++ b/fs.go @@ -24,8 +24,14 @@ type FS struct { isReal bool } -// DefaultMountPoint is the common mount point of the proc filesystem. -const DefaultMountPoint = fs.DefaultProcMountPoint +const ( + // DefaultMountPoint is the common mount point of the proc filesystem. + DefaultMountPoint = fs.DefaultProcMountPoint + + // SectorSize represents the size of a sector in bytes. + // It is specific to Linux block I/O operations. + SectorSize = 512 +) // NewDefaultFS returns a new proc FS mounted under the default proc mountPoint. // It will error if the mount point directory can't be read or is a file. diff --git a/internal/fs/fs.go b/internal/fs/fs.go index a98c700f..3a43e839 100644 --- a/internal/fs/fs.go +++ b/internal/fs/fs.go @@ -31,10 +31,6 @@ const ( // DefaultSelinuxMountPoint is the common mount point of the selinuxfs. DefaultSelinuxMountPoint = "/sys/fs/selinux" - - // SectorSize represents the size of a sector in bytes. - // It is specific to Linux block I/O operations. - SectorSize = 512 ) // FS represents a pseudo-filesystem, normally /proc or /sys, which provides an