Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compiling failures on this lib #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions gfapi/fd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package gfapi
// #include <stdlib.h>
// #include <sys/stat.h>
import "C"

import (
"os"
"syscall"
Expand Down Expand Up @@ -41,8 +42,8 @@ func (fd *Fd) Fchown(uid, gid uint32) error {
// Futimens changes the atime and mtime of the Fd
//
// Returns error on failure
func (fd *Fd) Futimens(times [2]C.timespec) error {
_, err := C.glfs_futimens(fd.fd, times)
func (fd *Fd) Futimens(times [2]C.struct_timespec) error {
_, err := C.glfs_futimens(fd.fd, &times[0])

return err
}
Expand All @@ -51,7 +52,6 @@ func (fd *Fd) Futimens(times [2]C.timespec) error {
//
// Returns error on failure
func (fd *Fd) Fstat(stat *syscall.Stat_t) error {

ret, err := C.glfs_fstat(fd.fd, (*C.struct_stat)(unsafe.Pointer(stat)))
if int(ret) < 0 {
return err
Expand Down Expand Up @@ -230,12 +230,13 @@ func direntName(dirent *syscall.Dirent) string {
// then all the items will be returned.
func (fd *Fd) Readdir(n int) ([]os.FileInfo, error) {
var (
stat syscall.Stat_t
files []os.FileInfo
statP = (*C.struct_stat)(unsafe.Pointer(&stat))
)

for i := 0; n == 0 || i < n; i++ {
var stat syscall.Stat_t
var statP = (*C.struct_stat)(unsafe.Pointer(&stat))

d, err := C.glfs_readdirplus(fd.fd, statP)
if err != nil {
return nil, err
Expand Down
7 changes: 4 additions & 3 deletions gfapi/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package gfapi
// #include <stdlib.h>
// #include <sys/stat.h>
import "C"

import (
"errors"
"io"
Expand Down Expand Up @@ -60,9 +61,9 @@ func (f *File) Chown(uid, gid int) error {
}

func (f *File) Futimens(atime, mtime time.Time) error {
var times [2]C.timespec
times[1].tv_sec = mtime.Unix()
times[1].tv_nsec = mtime.Nanosecond()
var times [2]C.struct_timespec
times[0] = C.struct_timespec{tv_sec: C.long(atime.Unix()), tv_nsec: C.long(atime.Nanosecond())}
times[1] = C.struct_timespec{tv_sec: C.long(mtime.Unix()), tv_nsec: C.long(mtime.Nanosecond())}
return f.Fd.Futimens(times)
}

Expand Down
12 changes: 6 additions & 6 deletions gfapi/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package gfapi
// for more information please 'api/src/glfs.h' in the glusterfs source.

//go:generate sh -c "go tool cgo -godefs types_unix.go | gofmt > ztypes_${GOOS}_${GOARCH}.go"
//TODO: Need to run `go generate` on different platforms to generate relevant ztypes file for each
// TODO: Need to run `go generate` on different platforms to generate relevant ztypes file for each
// - *BSD
// - Mac OS X

Expand All @@ -14,6 +14,7 @@ package gfapi
// #include <time.h>
// #include <sys/stat.h>
import "C"

import (
"errors"
"fmt"
Expand Down Expand Up @@ -172,7 +173,7 @@ func (v *Volume) Chown(name string, uid, gid int) error {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))

_, err := C.glfs_chmod(v.fs, cname, C.uid_t(uid), C.gid_t(gid))
_, err := C.glfs_chown(v.fs, cname, C.uid_t(uid), C.gid_t(gid))

return err
}
Expand All @@ -184,10 +185,9 @@ func (v *Volume) Chtimes(name string, mtime time.Time) error {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))

var amtime [2]C.timespec
amtime[1].tv_sec = mtime.Unix()
amtime[1].tv_nsec = mtime.Nanosecond()
_, err := C.glfs_utimens(v.fs, cname, amtime)
var amtime [2]C.struct_timespec
amtime[1] = C.struct_timespec{tv_sec: C.long(mtime.Unix()), tv_nsec: C.long(mtime.Nanosecond())}
_, err := C.glfs_utimens(v.fs, cname, &amtime[0])

return err
}
Expand Down