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

x/sys/unix: add support for FAN_REPORT_FID #35799

s3rj1k opened this issue Nov 23, 2019 · 3 comments

x/sys/unix: add support for FAN_REPORT_FID #35799

s3rj1k opened this issue Nov 23, 2019 · 3 comments


Copy link

@s3rj1k s3rj1k commented Nov 23, 2019

Linux kernels 5.1+ have added new API (FAN_REPORT_FID) for fanotify. Would be nice to have this in ''.

@ianlancetaylor ianlancetaylor changed the title add support for FAN_REPORT_FID in x/sys/unix: add support for FAN_REPORT_FID Nov 23, 2019
@gopherbot gopherbot added this to the Unreleased milestone Nov 23, 2019
Copy link

@ianlancetaylor ianlancetaylor commented Nov 23, 2019

Want to send a patch?

Copy link

@tklauser tklauser commented Nov 24, 2019

The const is already there since

zerrors_linux_386.go:677:       FAN_REPORT_FID                       = 0x200
zerrors_linux_amd64.go:677:     FAN_REPORT_FID                       = 0x200
zerrors_linux_arm.go:677:       FAN_REPORT_FID                       = 0x200
zerrors_linux_arm64.go:679:     FAN_REPORT_FID                       = 0x200
zerrors_linux_mips.go:677:      FAN_REPORT_FID                       = 0x200
zerrors_linux_mips64.go:677:    FAN_REPORT_FID                       = 0x200
zerrors_linux_mips64le.go:677:  FAN_REPORT_FID                       = 0x200
zerrors_linux_mipsle.go:677:    FAN_REPORT_FID                       = 0x200
zerrors_linux_ppc64.go:677:     FAN_REPORT_FID                       = 0x200
zerrors_linux_ppc64le.go:677:   FAN_REPORT_FID                       = 0x200
zerrors_linux_riscv64.go:677:   FAN_REPORT_FID                       = 0x200
zerrors_linux_s390x.go:677:     FAN_REPORT_FID                       = 0x200
zerrors_linux_sparc64.go:681:   FAN_REPORT_FID                       = 0x200

Is there anything else needed to use this API?

Copy link

@s3rj1k s3rj1k commented Nov 24, 2019

@tklauser @ianlancetaylor Hi all. Yes not all structures are present and there is no helper func to get fanotify events.
I was using code that looks hacky, not written by my, have no idea how to rewrite it.
Code is located here

The structs are needed:

A function that can read this structs from a memory, the unsafe magic and reaf buffers,
Results of that function then can be passed to unix.NewFileHandle and unix.OpenByHandleAt.

Initial unix.FanotifyEventMetadata can be read with binary.Read, for example like this.

The problem lies with extra structs that come after initial unix.FanotifyEventMetadata then fanotify is used with FAN_REPORT_FID flag. This structs can have offset (padding) and part of this struct needs to be passed to unix.OpenByHandleAt to get FD of a opened fanotify file.

All of this looks quite a challenge at least for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants