2020-03-23 11:40:02 +00:00
|
|
|
package stores
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Store interface {
|
2020-03-26 02:50:56 +00:00
|
|
|
AcquireSector(ctx context.Context, s abi.SectorID, existing SectorFileType, allocate SectorFileType, sealing bool) (paths SectorPaths, stores SectorPaths, done func(), err error)
|
|
|
|
Remove(ctx context.Context, s abi.SectorID, types SectorFileType) error
|
2020-03-25 18:21:53 +00:00
|
|
|
|
|
|
|
// move sectors into storage
|
2020-03-26 02:50:56 +00:00
|
|
|
MoveStorage(ctx context.Context, s abi.SectorID, types SectorFileType) error
|
2020-03-25 18:21:53 +00:00
|
|
|
|
2020-03-23 22:43:38 +00:00
|
|
|
FsStat(ctx context.Context, id ID) (FsStat, error)
|
2020-03-23 11:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Stat(path string) (FsStat, error) {
|
|
|
|
var stat syscall.Statfs_t
|
|
|
|
if err := syscall.Statfs(path, &stat); err != nil {
|
|
|
|
return FsStat{}, xerrors.Errorf("statfs: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return FsStat{
|
2020-03-23 22:43:38 +00:00
|
|
|
Capacity: stat.Blocks * uint64(stat.Bsize),
|
|
|
|
Available: stat.Bavail * uint64(stat.Bsize),
|
2020-03-23 11:40:02 +00:00
|
|
|
}, nil
|
|
|
|
}
|
2020-03-23 22:43:38 +00:00
|
|
|
|
|
|
|
type FsStat struct {
|
|
|
|
Capacity uint64
|
|
|
|
Available uint64 // Available to use for sector storage
|
|
|
|
Used uint64
|
|
|
|
}
|