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

The sys/unix FIDEDUPERANGE ioctl wrapper is implemented wrong and unusable #43679

Closed
viric opened this issue Jan 13, 2021 · 1 comment
Closed

Comments

@viric
Copy link

viric commented Jan 13, 2021

What version of Go are you using (go version)?

I use this version below, but I want to talk about code in master (that came from x/sys/unix).

$ go version
go version go1.15.2 linux/amd64

Does this issue reproduce with the latest release?

Yes, a ioctl implementation doesn't match the linux manual.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/viric/.cache/go-build"
GOENV="/home/viric/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/viric/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/viric/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/dz12rdqlp94rqinvcmk6knia6cw5s8ra-go-1.15.2/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/dz12rdqlp94rqinvcmk6knia6cw5s8ra-go-1.15.2/share/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build423744141=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I want to use the (x/)sys/unix IoctlFileDedupeRange function

What did you expect to see?

It should ressemble the ioctl described in the linux manual:

int ioctl(int src_fd, FIDEDUPERANGE, struct file_dedupe_range *arg);

           struct file_dedupe_range {
               __u64 src_offset;
               __u64 src_length;
               __u16 dest_count;
               __u16 reserved1;
               __u32 reserved2;
               struct file_dedupe_range_info info[0];
           };

           struct file_dedupe_range_info {
               __s64 dest_fd;
               __u64 dest_offset;
               __u64 bytes_deduped;
               __s32 status;
               __u32 reserved;
           };

What did you see instead?

This is the ioctl in sys/unix (golang master or x/sys/unix) is like this: https://pkg.go.dev/golang.org/x/sys/unix#IoctlFileDedupeRange

destFd should be srcFd, and the 'info' member is not there, making the call unusable.

func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error

type FileDedupeRange struct {
    Src_offset uint64
    Src_length uint64
    Dest_count uint16
    Reserved1  uint16
    Reserved2  uint32
}
@seankhliao
Copy link
Member

closing double/duplicate issue #43678

@golang golang locked and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants