cloudfox-coreshift-core 2.33.0

Low-level Linux and Android systems primitives for CoreShift (CloudFox)
Documentation
# Inotify

`inotify` is a flat, stateless wrapper over the Linux inotify API: watch setup,
teardown, and event decode. No internal watch bookkeeping — the caller tracks
watch descriptors (`wd`) itself.

## API

- `init()``inotify_init1(IN_CLOEXEC | IN_NONBLOCK)` → owned `Fd`.
- `add_watch(fd, path, mask)` → the kernel watch descriptor (`i32`). Embedded
  NUL in `path``EINVAL`. Errors: `EACCES`, `EBADF`, `EINVAL`, `ENOENT`,
  `ENOSPC`, `ENOMEM`.
- `remove_watch(fd, wd)` — on Android the `wd` is coerced to `u32` (bionic
  signature); a negative/non-representable `wd``EINVAL`.
- `read_events(fd)` — drains the fd until `EAGAIN` (edge-triggered contract),
  returns decoded events; safe to call with an empty buffer.
- `decode_events(buf)` — pure decode of a raw inotify buffer (testable).
  Strict: truncated headers/bodies or trailing garbage → `EINVAL`.

## Event type

`InotifyEvent { wd: i32, mask: u32, name: Option<Vec<u8>> }` — `name` is raw
bytes truncated at the first NUL; `None` when the event carries no name
(`len == 0`). Note `Some(vec![])` is possible if a name starts with NUL.

## Watch masks

- `MODIFY_MASK``IN_MODIFY`.
- `PACKAGE_FILE_MASK``IN_MODIFY | IN_DELETE_SELF | IN_MOVE_SELF`.
- `PARENT_WATCH_MASK``IN_CREATE | IN_MOVED_TO | IN_CLOSE_WRITE | IN_MODIFY |
  IN_DELETE_SELF | IN_MOVE_SELF` (parent-dir watching).
- `QUEUE_OVERFLOW_MASK``IN_Q_OVERFLOW`.
- `IGNORED_MASK``IN_IGNORED`.
- `UNMOUNT_MASK``IN_UNMOUNT`.
- `DELETE_SELF_MASK``IN_DELETE_SELF`.
- `MOVE_SELF_MASK``IN_MOVE_SELF`.

Callers pass any `u32` mask; these constants package the common combinations.