2020-03-11 07:22:21 +00:00
|
|
|
package stores
|
|
|
|
|
|
|
|
import (
|
2020-03-13 00:23:05 +00:00
|
|
|
"context"
|
2020-03-19 15:10:19 +00:00
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"golang.org/x/xerrors"
|
2020-03-11 07:22:21 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/go-sectorbuilder"
|
2020-03-13 00:23:05 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-03-11 07:22:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Store interface {
|
2020-03-13 16:54:55 +00:00
|
|
|
AcquireSector(ctx context.Context, s abi.SectorID, existing sectorbuilder.SectorFileType, allocate sectorbuilder.SectorFileType, sealing bool) (paths sectorbuilder.SectorPaths, stores sectorbuilder.SectorPaths, done func(), err error)
|
2020-03-11 07:22:21 +00:00
|
|
|
}
|
2020-03-19 15:10:19 +00:00
|
|
|
|
|
|
|
type FsStat struct {
|
|
|
|
Capacity uint64
|
|
|
|
Free uint64 // Free to use for sector storage
|
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
|
|
|
Free: stat.Bavail * uint64(stat.Bsize),
|
|
|
|
}, nil
|
|
|
|
}
|