Expand description
Where a new file’s POSIX mode / uid / gid actually come from.
Every Unix filesystem we can edit — ext, UFS, XFS, EFS, Minix, and SquashFS
once its edit path lands — already honours CreateFileOptions’s mode,
uid and gid. Until now nothing set them: rb-cli put left all three at
None, so each driver fell back to its own unwrap_or and every added file
silently became root:root 0644.
That is defensible as a last resort and wrong as a default. Replacing
/etc/shadow should not turn it world-readable; dropping a script into
/usr/local/bin should not make it non-executable; and replacing a
capability-bearing binary should not quietly strip its ownership.
This module is the one place that decides, so the CLI, GUI and TUI cannot drift. The rule, highest priority first:
| Attribute | Precedence |
|---|---|
mode | explicit flag -> file being replaced -> host file’s own bits -> fallback |
uid | explicit flag -> file being replaced -> parent directory -> 0 |
gid | explicit flag -> file being replaced -> parent directory -> 0 |
Replacing an existing file inherits from it, because that is the common
edit — swap a config, replace a binary — and the file already carries the
answer. A genuinely new file takes ownership from its parent directory,
which is how the surrounding tree is almost always laid out. The host file’s
permission bits are consulted for mode only: macOS carries those faithfully,
but its uid/gid (typically 501:20) are meaningless inside a Linux image.
Each resolved value records where it came from so the operation can say so
rather than guessing silently — see ResolvedAttrs::describe.
Structs§
- Attr
Overrides - Caller-supplied overrides.
Nonemeans “decide for me”. - Preserved
Meta - Everything worth carrying from a file that is about to be replaced.
- Resolved
Attrs - The decision, with provenance per field.
Enums§
- Attr
Source - Which input supplied a resolved attribute.
Functions§
- add_
execute_ where_ read - Add execute wherever read is already granted — exactly
chmod a+X. - inherited_
xattrs - The extended attributes a replacement file should inherit from the file it displaces.
- preserved_
meta - Capture the metadata of a file about to be replaced.
- resolve_
attrs - Resolve the POSIX attributes for a file about to be created.
- resolve_
dir_ attrs - Resolve the POSIX attributes for a directory about to be created.