lotus/stores/interface.go

57 lines
1.4 KiB
Go
Raw Normal View History

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 PathType bool
2020-05-26 08:25:29 +00:00
const (
PathStorage = false
PathSealing = true
)
type AcquireMode string
2020-05-26 08:25:29 +00:00
const (
AcquireMove = "move"
AcquireCopy = "copy"
)
2020-03-23 11:40:02 +00:00
type Store interface {
2020-06-04 19:00:16 +00:00
AcquireSector(ctx context.Context, s abi.SectorID, spt abi.RegisteredProof, existing SectorFileType, allocate SectorFileType, sealing PathType, op AcquireMode) (paths SectorPaths, stores SectorPaths, err error)
2020-05-13 18:45:14 +00:00
Remove(ctx context.Context, s abi.SectorID, types SectorFileType, force bool) error
// like remove, but doesn't remove the primary sector copy, nor the last
// non-primary copy if there no primary copies
RemoveCopies(ctx context.Context, s abi.SectorID, types SectorFileType) error
// move sectors into storage
MoveStorage(ctx context.Context, s abi.SectorID, spt abi.RegisteredProof, types SectorFileType) error
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{
Capacity: stat.Blocks * uint64(stat.Bsize),
Available: stat.Bavail * uint64(stat.Bsize),
2020-03-23 11:40:02 +00:00
}, nil
}
type FsStat struct {
Capacity uint64
Available uint64 // Available to use for sector storage
Used uint64
}