follow rule about uintptr cast in syscall args only

This commit is contained in:
Ben McClelland
2020-03-15 09:04:08 -07:00
parent e9c5f58f7e
commit c3ae6c31a2
2 changed files with 15 additions and 15 deletions

View File

@@ -102,7 +102,7 @@ func (q *Query) Next() ([]InodesEntry, error) {
Index: q.index, Index: q.index,
} }
n, err := scoutfsctl(q.fsfd.Fd(), IOCQUERYINODES, uintptr(unsafe.Pointer(&query))) n, err := scoutfsctl(q.fsfd, IOCQUERYINODES, unsafe.Pointer(&query))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -151,7 +151,7 @@ func StatMore(path string) (Stat, error) {
func FStatMore(f *os.File) (Stat, error) { func FStatMore(f *os.File) (Stat, error) {
s := Stat{Valid_bytes: uint64(unsafe.Sizeof(Stat{}))} s := Stat{Valid_bytes: uint64(unsafe.Sizeof(Stat{}))}
_, err := scoutfsctl(f.Fd(), IOCSTATMORE, uintptr(unsafe.Pointer(&s))) _, err := scoutfsctl(f, IOCSTATMORE, unsafe.Pointer(&s))
if err != nil { if err != nil {
return Stat{}, err return Stat{}, err
} }
@@ -184,7 +184,7 @@ func FSetAttrMore(f *os.File, version, size, flags uint64, ctime time.Time) erro
Ctime_nsec: uint32(nsec), Ctime_nsec: uint32(nsec),
} }
_, err := scoutfsctl(f.Fd(), IOCSETATTRMORE, uintptr(unsafe.Pointer(&s))) _, err := scoutfsctl(f, IOCSETATTRMORE, unsafe.Pointer(&s))
return err return err
} }
@@ -207,7 +207,7 @@ func InoToPath(dirfd *os.File, ino uint64) (string, error) {
Result_bytes: uint16(unsafe.Sizeof(res)), Result_bytes: uint16(unsafe.Sizeof(res)),
} }
_, err := scoutfsctl(dirfd.Fd(), IOCINOPATH, uintptr(unsafe.Pointer(&ip))) _, err := scoutfsctl(dirfd, IOCINOPATH, unsafe.Pointer(&ip))
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -249,7 +249,7 @@ func FReleaseFile(f *os.File, version uint64) error {
Version: version, Version: version,
} }
_, err := scoutfsctl(f.Fd(), IOCRELEASE, uintptr(unsafe.Pointer(&r))) _, err := scoutfsctl(f, IOCRELEASE, unsafe.Pointer(&r))
return err return err
} }
@@ -273,7 +273,7 @@ func FStageFile(f *os.File, version, offset uint64, b []byte) (int, error) {
Count: int32(len(b)), Count: int32(len(b)),
} }
return scoutfsctl(f.Fd(), IOCSTAGE, uintptr(unsafe.Pointer(&r))) return scoutfsctl(f, IOCSTAGE, unsafe.Pointer(&r))
} }
// Waiters to keep track of data waiters // Waiters to keep track of data waiters
@@ -321,7 +321,7 @@ func (w *Waiters) Next() ([]DataWaitingEntry, error) {
Ents_nr: w.batch, Ents_nr: w.batch,
} }
n, err := scoutfsctl(w.fsfd.Fd(), IOCDATAWAITING, uintptr(unsafe.Pointer(&dataWaiting))) n, err := scoutfsctl(w.fsfd, IOCDATAWAITING, unsafe.Pointer(&dataWaiting))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -412,7 +412,7 @@ func (q *XattrQuery) Next() ([]uint64, error) {
Nr_inodes: uint16(q.batch), Nr_inodes: uint16(q.batch),
} }
n, err := scoutfsctl(q.fsfd.Fd(), IOCFINDXATTRS, uintptr(unsafe.Pointer(&query))) n, err := scoutfsctl(q.fsfd, IOCFINDXATTRS, unsafe.Pointer(&query))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -460,7 +460,7 @@ func (l *ListXattrHidden) Next() ([]string, error) {
buf := make([]byte, 256*1024) buf := make([]byte, 256*1024)
l.lxr.Buf_ptr = uint64(uintptr(unsafe.Pointer(&buf[0]))) l.lxr.Buf_ptr = uint64(uintptr(unsafe.Pointer(&buf[0])))
n, err := scoutfsctl(l.f.Fd(), IOCLISTXATTRHIDDEN, uintptr(unsafe.Pointer(l.lxr))) n, err := scoutfsctl(l.f, IOCLISTXATTRHIDDEN, unsafe.Pointer(l.lxr))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -497,7 +497,7 @@ type FSID struct {
func GetIDs(f *os.File) (FSID, error) { func GetIDs(f *os.File) (FSID, error) {
stfs := statfsMore{Bytes: sizeofstatfsMore} stfs := statfsMore{Bytes: sizeofstatfsMore}
_, err := scoutfsctl(f.Fd(), IOCSTATFSMORE, uintptr(unsafe.Pointer(&stfs))) _, err := scoutfsctl(f, IOCSTATFSMORE, unsafe.Pointer(&stfs))
if err != nil { if err != nil {
return FSID{}, err return FSID{}, err
} }

View File

@@ -34,11 +34,11 @@ func OpenByHandle(dirfd *os.File, ino uint64, flags int) (uintptr, error) {
HandleType: fileIDScoutfs, HandleType: fileIDScoutfs,
FID: fileID{Ino: ino}, FID: fileID{Ino: ino},
} }
return openbyhandleat(dirfd.Fd(), h, flags) return openbyhandleat(dirfd, h, flags)
} }
func openbyhandleat(dirfd uintptr, handle *fileHandle, flags int) (uintptr, error) { func openbyhandleat(dirfd *os.File, handle *fileHandle, flags int) (uintptr, error) {
fd, _, e1 := syscall.Syscall6(sysOpenByHandleAt, dirfd, uintptr(unsafe.Pointer(handle)), uintptr(flags), 0, 0, 0) fd, _, e1 := syscall.Syscall6(sysOpenByHandleAt, uintptr(dirfd.Fd()), uintptr(unsafe.Pointer(handle)), uintptr(flags), 0, 0, 0)
var err error var err error
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
@@ -46,8 +46,8 @@ func openbyhandleat(dirfd uintptr, handle *fileHandle, flags int) (uintptr, erro
return fd, err return fd, err
} }
func scoutfsctl(fd, cmd, ptr uintptr) (int, error) { func scoutfsctl(f *os.File, cmd int, ptr unsafe.Pointer) (int, error) {
count, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) count, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(f.Fd()), uintptr(cmd), uintptr(ptr))
var err error var err error
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)