Skip to content

Instantly share code, notes, and snippets.

Last active August 5, 2017 20:18
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
statvfs (cgo)
package main
// build +cgo
import (
#include <stdlib.h>
#include <sys/statvfs.h>
import "C"
func main() {
vbuf := new(C.struct_statvfs)
path := C.CString(os.Args[1])
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