Skip to content

Conversation

@LHHL7
Copy link

@LHHL7 LHHL7 commented Dec 6, 2025

Description

  • add inotify datastructure
  • add inotify syscalls ( sys_inotify_init1(), sys_inotify_add_watch(),sys_inotify_rm_watch() )

Implementation

Additional Context

  • Basic functionality tested with a C test program
  • The complete event notification chain (e.g., event propagation mechanism in filesystem operations) is not yet implemented

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds inotify support to StarryOS, implementing the core inotify data structure and three syscalls (inotify_init1, inotify_add_watch, inotify_rm_watch). The implementation provides the basic infrastructure for filesystem monitoring, though the complete event notification chain from filesystem operations is not yet implemented.

Key Changes

  • Introduced InotifyInstance struct with watch management, event queue, and poll support
  • Implemented three inotify syscalls with proper integration into the syscall handler
  • Added event serialization with Linux-compatible binary format

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
api/src/syscall/mod.rs Added inotify syscall handlers and removed inotify_init1 from dummy fd list
api/src/syscall/fs/mod.rs Added inotify module to fs syscall exports
api/src/syscall/fs/inotify.rs Implemented three inotify syscalls with file descriptor management and validation
api/src/file/mod.rs Exported InotifyInstance and added inotify module
api/src/file/inotify.rs Core inotify implementation with data structures, watch management, and FileLike/Pollable trait support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LHHL7 LHHL7 force-pushed the feat/add-inotify-syscall branch from 756267e to 63cc59c Compare December 9, 2025 03:53
event_queue: Mutex<VecDeque<Vec<u8>>>,

// watches: wd -> (path, event mask)
watches: Mutex<BTreeMap<i32, (String, u32)>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the subjects of inotify are inodes (not pathnames), related data should be stored in Location::user_data instead. You should base your implementation on that API.


// Get file
let file = get_file_like(fd)?;
// let file = match get_file_like(fd) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these comments

pub mod epoll;
pub mod event;
mod fs;
pub mod inotify;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make this public?

pub mask: u32, // Mask describing event
pub cookie: u32, // Unique cookie associating related events
pub len: u32, /* Size of name field (including null terminator)
* attention:The name field is a variable-length array, which does not contain */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* attention:The name field is a variable-length array, which does not contain */
* note: the name field is a variable-length array and is not contained in this struct */

/// Serialized events are in binary format for users to read with char[]
fn serialize_event(event: &InotifyEvent, name: Option<&str>) -> Vec<u8> {
// +1 for null terminator
let name_len = name.map(|s| s.len() + 1).unwrap_or(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .map_or. You should run cargo clippy as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants