0

[WIP] Initial commit

This commit is contained in:
eleksir
2023-10-08 11:41:10 -07:00
commit a3e6ef65ed
1522 changed files with 653924 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// Copyright 2023 The LevelDB-Go and Pebble Authors. All rights reserved. Use
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//go:build openbsd
// +build openbsd
package vfs
import "golang.org/x/sys/unix"
func (defaultFS) GetDiskUsage(path string) (DiskUsage, error) {
stat := unix.Statfs_t{}
if err := unix.Statfs(path, &stat); err != nil {
return DiskUsage{}, err
}
freeBytes := uint64(stat.F_bsize) * uint64(stat.F_bfree)
availBytes := uint64(stat.F_bsize) * uint64(stat.F_bavail)
totalBytes := uint64(stat.F_bsize) * uint64(stat.F_blocks)
return DiskUsage{
AvailBytes: availBytes,
TotalBytes: totalBytes,
UsedBytes: totalBytes - freeBytes,
}, nil
}