Skip to content

Commit

Permalink
unix: add Illumos statvfs(2) syscall
Browse files Browse the repository at this point in the history
Reference: https://www.illumos.org/man/2/statvfs

Change-Id: If7af43da35b3204f5069a48eb08426a145544008
Reviewed-on: https://go-review.googlesource.com/43490
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
Sean Chittenden authored and bradfitz committed May 14, 2017
1 parent f845067 commit 1e99a4f
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
2 changes: 2 additions & 0 deletions unix/syscall_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ func IoctlGetTermio(fd int, req int) (*Termio, error) {
//sys Fdatasync(fd int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (err error)
//sys Fstatvfs(fd int, vfsstat *Statvfs_t) (err error)
//sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error)
//sysnb Getgid() (gid int)
//sysnb Getpid() (pid int)
Expand Down Expand Up @@ -639,6 +640,7 @@ func IoctlGetTermio(fd int, req int) (*Termio, error) {
//sysnb Setuid(uid int) (err error)
//sys Shutdown(s int, how int) (err error) = libsocket.shutdown
//sys Stat(path string, stat *Stat_t) (err error)
//sys Statvfs(path string, vfsstat *Statvfs_t) (err error)
//sys Symlink(path string, link string) (err error)
//sys Sync() (err error)
//sysnb Times(tms *Tms) (ticks uintptr, err error)
Expand Down
34 changes: 34 additions & 0 deletions unix/syscall_solaris_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build solaris

package unix_test

import (
"os/exec"
"testing"

"golang.org/x/sys/unix"
)

func TestStatvfs(t *testing.T) {
if err := unix.Statvfs("", nil); err == nil {
t.Fatal(`Statvfs("") expected failure`)
}

statvfs := unix.Statvfs_t{}
if err := unix.Statvfs("/", &statvfs); err != nil {
t.Errorf(`Statvfs("/") failed: %v`, err)
}

if t.Failed() {
mount, err := exec.Command("mount").CombinedOutput()
if err != nil {
t.Logf("mount: %v\n%s", err, mount)
} else {
t.Logf("mount: %s", mount)
}
}
}
7 changes: 7 additions & 0 deletions unix/types_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ package unix
#include <sys/signal.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
Expand Down Expand Up @@ -139,6 +140,12 @@ type Flock_t C.struct_flock

type Dirent C.struct_dirent

// Filesystems

type _Fsblkcnt_t C.fsblkcnt_t

type Statvfs_t C.struct_statvfs

// Sockets

type RawSockaddrInet4 C.struct_sockaddr_in
Expand Down
27 changes: 27 additions & 0 deletions unix/zsyscall_solaris_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions unix/ztypes_solaris_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e99a4f

Please sign in to comment.