Skip to content

Commit 9355d78

Browse files
committed
fix(overlayfs): properly initialize init.krun inode ID
- Set init.krun inode ID to a unique value instead of hardcoding to 1 - Clarify documentation for init.krun related fields - Add default value documentation for attr_timeout and proc_sfd_rawfd config options
1 parent af9c5e3 commit 9355d78

File tree

1 file changed

+13
-4
lines changed
  • src/devices/src/virtio/fs/macos/overlayfs

1 file changed

+13
-4
lines changed

src/devices/src/virtio/fs/macos/overlayfs/fs.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ pub struct Config {
145145
/// How long the FUSE client should consider file and directory attributes to be valid.
146146
/// If the attributes of a file or directory can only be modified by the FUSE client,
147147
/// this should be a large value.
148+
///
149+
/// The default value is 5 seconds.
148150
pub attr_timeout: Duration,
149151

150152
/// The caching policy the file system should use.
@@ -160,7 +162,10 @@ pub struct Config {
160162
pub xattr: bool,
161163

162164
/// Optional file descriptor for /proc/self/fd.
163-
/// This is useful for sandboxing scenarios.
165+
/// Callers can obtain a file descriptor and pass it here, so there's no need to open it in
166+
/// OverlayFs::new(). This is specially useful for sandboxing.
167+
///
168+
/// The default is `None`.
164169
pub proc_sfd_rawfd: Option<RawFd>,
165170

166171
/// ID of this filesystem to uniquely identify exports.
@@ -214,7 +219,7 @@ pub struct OverlayFs {
214219
/// Counter for generating the next inode ID
215220
next_inode: AtomicU64,
216221

217-
/// The initial inode ID (typically 1 for the root directory)
222+
/// The `init.krun` inode ID
218223
init_inode: u64,
219224

220225
/// Map of open file handles by ID
@@ -223,7 +228,7 @@ pub struct OverlayFs {
223228
/// Counter for generating the next handle ID
224229
next_handle: AtomicU64,
225230

226-
/// The initial handle ID
231+
/// The `init.krun` handle ID
227232
init_handle: u64,
228233

229234
/// Map of memory-mapped windows
@@ -275,10 +280,14 @@ impl OverlayFs {
275280
// Initialize the root inodes for all layers
276281
let layer_roots = Self::init_root_inodes(&config.layers, &mut inodes, &mut next_inode)?;
277282

283+
// Set the `init.krun` inode
284+
let init_inode = next_inode;
285+
next_inode += 1;
286+
278287
Ok(OverlayFs {
279288
inodes: RwLock::new(inodes),
280289
next_inode: AtomicU64::new(next_inode),
281-
init_inode: 1,
290+
init_inode,
282291
handles: RwLock::new(BTreeMap::new()),
283292
next_handle: AtomicU64::new(1),
284293
init_handle: 0,

0 commit comments

Comments
 (0)