diff options
Diffstat (limited to 'sftp/server_statvfs_impl.go')
-rw-r--r-- | sftp/server_statvfs_impl.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sftp/server_statvfs_impl.go b/sftp/server_statvfs_impl.go new file mode 100644 index 0000000..94b6d83 --- /dev/null +++ b/sftp/server_statvfs_impl.go @@ -0,0 +1,29 @@ +// +build darwin linux + +// fill in statvfs structure with OS specific values +// Statfs_t is different per-kernel, and only exists on some unixes (not Solaris for instance) + +package sftp + +import ( + "syscall" +) + +func (p *sshFxpExtendedPacketStatVFS) respond(svr *Server) responsePacket { + retPkt, err := getStatVFSForPath(p.Path) + if err != nil { + return statusFromError(p.ID, err) + } + retPkt.ID = p.ID + + return retPkt +} + +func getStatVFSForPath(name string) (*StatVFS, error) { + var stat syscall.Statfs_t + if err := syscall.Statfs(name, &stat); err != nil { + return nil, err + } + + return statvfsFromStatfst(&stat) +} |