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

Open
s3rj1k opened this issue Nov 23, 2019 · 3 comments
Open

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

s3rj1k opened this issue Nov 23, 2019 · 3 comments
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@s3rj1k
Copy link

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 'golang.org/x/sys'.

@ianlancetaylor ianlancetaylor changed the title add support for FAN_REPORT_FID in golang.org/x/sys x/sys/unix: add support for FAN_REPORT_FID Nov 23, 2019
@gopherbot gopherbot added this to the Unreleased milestone Nov 23, 2019
@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Nov 23, 2019
@ianlancetaylor
Copy link
Contributor

Want to send a patch?

@tklauser
Copy link
Member

The const is already there since https://golang.org/cl/175158:

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?

@tklauser tklauser added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed NeedsFix The path to resolution is known, but the work has not been done. labels Nov 24, 2019
@s3rj1k
Copy link
Author

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 https://github.com/ozeidan/gosearch/blob/master/internal/fanotify/fanotify.go

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 :)

@tklauser tklauser added NeedsFix The path to resolution is known, but the work has not been done. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants