mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-27 02:37:10 +01:00
Currently the user is not informed of issues that are due to low disk space (such as block processing failures and resulting orphaning blocks). Instead, check for available disk space before starting a write transaction to preventively fail and inform the user of the problem.
26 lines
504 B
Go
26 lines
504 B
Go
// +build !windows
|
|
|
|
// Copyright (c) 2013-2018 The btcsuite developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ffldb
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// getAvailableDiskSpace returns the number of bytes of available disk space.
|
|
func getAvailableDiskSpace() (uint64, error) {
|
|
var stat syscall.Statfs_t
|
|
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
syscall.Statfs(wd, &stat)
|
|
|
|
return stat.Bavail * uint64(stat.Bsize), nil
|
|
}
|