Add missing Fanotify APIs from the libc crate into Nix. - #2552
carlvoller wants to merge 13 commits into
Conversation
|
I'm not very sure whats going on with the solaris CI failure, but the test that is failing Some guidance would be really appreciated 👍 |
I have seen this one. Seems that this one can fail randomly. I will create PR to disable this test for Solaris. Sorry about that! |
No need to be sorry:)
Thanks, I will create an issue for this. |
This test has been disabled, you can rebase your branch to fix the CI:) |
|
Alright, just rebased 👍 |
|
Hey any chance could this be merged soon? I would like to use these new features in another package I'm making. |
| /// Allows the receipt of events which contain additional information | ||
| /// about the underlying filesystem object correlated to an event. | ||
| /// | ||
| /// This will make `FanotifyEvent::fd` return `FAN_NOFD`. |
There was a problem hiding this comment.
| /// This will make `FanotifyEvent::fd` return `FAN_NOFD`. | |
| /// This will make [`FanotifyEvent::fd()`] return `None`. |
| current_event_offset += header.len as usize; | ||
| } | ||
|
|
||
| // libc::fanotify_event_info_header |
| // Other fanotify_event_info records are not implemented as they don't exist in | ||
| // the libc crate yet. |
There was a problem hiding this comment.
Emm, do we have any other types of information records? All the information record types mentioned in the man page are listed here, though the Linux kernel could add more in the future, which means this enum should be #[non_exhaustive]
| /// Allows the receipt of events which contain additional information | ||
| /// about the underlying filesystem object correlated to an event. | ||
| /// | ||
| /// This will make `FanotifyEvent::fd` return `FAN_NOFD`. |
There was a problem hiding this comment.
Same here:
| /// This will make `FanotifyEvent::fd` return `FAN_NOFD`. | |
| /// This will make [`FanotifyEvent::fd()`] return `None`. |
| /// information record received via [`Fanotify::read_events_with_info_records`]. | ||
| #[derive(Debug, Eq, Hash, PartialEq)] | ||
| #[repr(transparent)] | ||
| #[allow(missing_copy_implementations)] |
| // This isn't found in the fanotify(7) documentation, but the fanotify_init(2) documentation | ||
| // https://man7.org/linux/man-pages/man2/fanotify_init.2.html |
There was a problem hiding this comment.
You mean types FAN_EVENT_INFO_TYPE_NEW_DFID_NAME and FAN_EVENT_INFO_TYPE_OLD_DFID_NAME?
|
|
||
| Some(FanotifyInfoRecord::Fid(FanotifyFidRecord { | ||
| record: LibcFanotifyFidRecord(record), | ||
| handle_bytes: file_handle_ptr, |
There was a problem hiding this comment.
This looks like a dangling pointer as it comes from buffer, which belongs to the current function frame
| .get_struct::<libc::fanotify_event_info_header>( | ||
| &buffer, | ||
| current_event_offset, | ||
| ); |
There was a problem hiding this comment.
If possible, I hope we can inspect the header without doing any copy
| /// The specific info_type for this Fid Record. Fanotify can return an Fid Record | ||
| /// with many different possible info_types. The info_type is not always necessary | ||
| /// but can be useful for connecting similar events together (like a FAN_RENAME) | ||
| pub fn info_type(&self) -> u8 { |
There was a problem hiding this comment.
I think it would be nice to have an enum for the info type:
libc_enum! {
#[repr(u8)]
#[non_exhaustive]
enum FanEventInfoType {
FAN_EVENT_INFO_TYPE_FID,
FAN_EVENT_INFO_TYPE_DFID,
FAN_EVENT_INFO_TYPE_DFID_NAME,
FAN_EVENT_INFO_TYPE_OLD_DFID_NAME,
FAN_EVENT_INFO_TYPE_NEW_DFID_NAME,
}
}
Sorry for the late review, my non-working hours are quite limited due to my current full-time job, so I have been struggling to balance the few things I need to complete during that time. Just did a round of review, I think tomorrow I will take a closer look |
|
Hi Steve, I really appreciate you taking the time to review the code. I've just made a number of changes that should fix all of your concerns and comments above. |
|
Hi Steve, Any chance could you take another look at my changes above? Thanks! |
…now reads instead of copys, file_handle no longer returns pointer but returns [u8; 128]
|
Hi Steve, Bumping this again in case you missed this. I would really appreciate it if you could help me take a look at the latest changes whenever you're next available. |
|
What's the latest? |
|
Hi @SteveLauC, Just bumping the above again. It would really be great if this could be merged soon. |
|
Is there anything the community can do to help get this merged? |
|
Hi @SteveLauC, Giving this another bump. It would be really good to know how we can move forward with getting this merged. Or is there another maintainer we can ping here that could help us with the review process? Thanks! |
|
Having a nice wrapper in nix over |
What does this PR do
Adds support for nix to receive additional Fanotify information records (such as
libc::fanotify_event_info_fid,libc::fanotify_event_info_errorandlibc::fanotify_event_info_pidfd)Adds abstractions over the new fanotify structs.
Adds new
InitFlagsto allow receiving these new information records.This closes #2551
Checklist:
CONTRIBUTING.md