statvfs (cgo)
package main | |
// build +cgo | |
import ( | |
"fmt" | |
"os" | |
"unsafe" | |
) | |
/* | |
#include <stdlib.h> | |
#include <sys/statvfs.h> | |
*/ | |
import "C" | |
func main() { | |
fmt.Println() | |
fmt.Println("statvfs") | |
vbuf := new(C.struct_statvfs) | |
path := C.CString(os.Args[1]) | |
defer C.free(unsafe.Pointer(path)) | |
ret := C.statvfs(path, vbuf) | |
fmt.Println("Error:", ret) | |
fmt.Println("Block Size:", vbuf.f_bsize) | |
fmt.Println("Fragment Size:", vbuf.f_frsize) | |
fmt.Println("Total Blocks:", vbuf.f_blocks) | |
fmt.Println("Free Blocks:", vbuf.f_bfree) | |
fmt.Println("Free Blocks (non-root):", vbuf.f_bavail) | |
fmt.Println("Total Files:", vbuf.f_files) | |
fmt.Println("Free Files:", vbuf.f_ffree) | |
fmt.Println("Free Files (non-root):", vbuf.f_favail) | |
fmt.Println("Fsid:", vbuf.f_fsid) | |
fmt.Println("Flags:", vbuf.f_flag) | |
fmt.Println("Namelen:", vbuf.f_namemax) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment