github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/disk_use_unix.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 //go:build !windows 13 14 package db 15 16 import ( 17 "syscall" 18 ) 19 20 func (db *DB) getDiskUse(diskPath string) diskUse { 21 fs := syscall.Statfs_t{} 22 23 err := syscall.Statfs(diskPath, &fs) 24 if err != nil { 25 db.logger.WithField("action", "read_disk_use"). 26 WithField("path", diskPath). 27 Errorf("failed to read disk usage: %s", err) 28 } 29 30 return diskUse{ 31 total: fs.Blocks * uint64(fs.Bsize), 32 free: fs.Bfree * uint64(fs.Bsize), 33 avail: fs.Bfree * uint64(fs.Bsize), 34 } 35 }