feat(filesystem): Add tmpfs support and integrate with devfs#1459
feat(filesystem): Add tmpfs support and integrate with devfs#1459fslongjin merged 2 commits intoDragonOS-Community:masterfrom
Conversation
fslongjin
commented
Dec 11, 2025
- Introduced a new tmpfs module for temporary file storage in memory.
- Updated devfs to mount /dev/shm as tmpfs, aligning with Linux semantics.
- Enhanced vfs module to include TMPFS_MAGIC for tmpfs identification.
- Added necessary methods and structures for tmpfs functionality, including inode management and file operations.
- Introduced a new tmpfs module for temporary file storage in memory. - Updated devfs to mount /dev/shm as tmpfs, aligning with Linux semantics. - Enhanced vfs module to include TMPFS_MAGIC for tmpfs identification. - Added necessary methods and structures for tmpfs functionality, including inode management and file operations. Signed-off-by: longjin <longjin@DragonOS.org>
|
@claude review this pr in Chinese |
|
Claude finished @fslongjin's task in 4m 3s —— View job PR审查:添加tmpfs支持并与devfs集成用户@fslongjin 要求用中文审查此PR。我将分析更改并提供代码审查反馈。 待办事项列表:
代码审查反馈总体评价这个PR实现了tmpfs内存文件系统,并将其与devfs集成,在 主要问题1. tmpfs模块中的缓冲区长度检查逻辑问题在 if buf.len() < len {
return Err(SystemError::EINVAL);
}这里的检查可能意图是确保缓冲区足够大,但 if buf.len() < (end - start) {
return Err(SystemError::ENOBUFS);
}这导致了重复检查。建议统一逻辑:要么在方法入口检查 2. 未实现的设备节点类型在 } else if mode.contains(InodeMode::S_IFBLK) {
nod.0.lock().metadata.file_type = FileType::BlockDevice;
unimplemented!()
} else if mode.contains(InodeMode::S_IFCHR) {
nod.0.lock().metadata.file_type = FileType::CharDevice;
unimplemented!()
}这会导致运行时panic。tmpfs可能不需要支持这些设备类型,但应该返回适当的错误码(如 3. 潜在的panic风险在 _ => panic!(
"Tmpfs get_entry_name: key.len()={key_len}>1, current inode_id={inode_id:?}, to find={to_find:?}",
key_len = key.len(),
inode_id = inode.metadata.inode_id,
to_find = ino
),虽然这种情况理论上不应发生,但在文件系统错误或并发问题下可能触发。考虑改为返回错误(如 4. mount.rs中的更改可能影响其他文件系统在 fn super_block(&self) -> SuperBlock {
let mut sb = self.inner_filesystem.super_block();
sb.flags = self.mount_flags.bits() as u64;
sb
}这个修改用mount标志覆盖了内部文件系统的super_block flags。这可能会影响依赖原始flags的其他代码。需要确认这是有意行为,且不会破坏现有功能。 5. 缺少内存限制检查tmpfs实现支持通过 次要问题和建议1. 错误消息的一致性在devfs的挂载tmpfs代码中( warn!("Mount /dev/shm failed: {:?}", e);而项目中其他地方多使用中文注释。建议统一。 2. 硬编码的魔数tmpfs魔数 3. whitelist.txt更新
4. 代码重复tmpfs的inode创建逻辑在多个地方重复( 安全问题未发现明显安全漏洞。但需要注意:
测试建议
总结这是一个质量较高的PR,实现了核心功能并与现有系统良好集成。建议在合并前修复上述主要问题,特别是 待办事项列表:
审查完成 - 请作者查看上述反馈,特别是主要问题部分。 |
- Added atomic operations to manage the current size of the tmpfs filesystem, including methods to increase and decrease size based on file operations. - Integrated size management into inode operations, ensuring that size updates are thread-safe and adhere to specified limits. - Enhanced the resize and truncate methods to adjust the filesystem size accordingly during file modifications. Signed-off-by: longjin <longjin@DragonOS.org>
|
@claude 上述pr审查我已经在5f2bb9b 里面修改。并且 “4. mount.rs中的更改可能影响其他文件系统” 这个地方本来就应该这么改,是你审查不对 |
|
Claude finished @fslongjin's task in 4m 33s —— View job Claude开始处理@fslongjin的请求 —— 查看任务运行 用户@fslongjin指出已经在5f2bb9b提交中修改了之前审查中提到的问题,并指出第4点关于mount.rs的更改本来就应该那么改,是我审查不对。 待办事项列表:
更新后的审查反馈感谢@fslongjin的澄清和修复。我已经检查了5f2bb9b提交,确认之前审查中提到的大部分问题已经得到修复,并且第4点关于mount.rs的更改确实是正确的。 问题修复状态验证
新增功能:原子大小管理5f2bb9b提交引入了完整的原子大小管理机制:
代码质量改进
总结这个PR现在提供了一个完整、健壮的tmpfs实现:
建议合并此PR。 审查完成 - 所有问题已得到妥善解决,tmpfs实现符合预期质量标准。 |
