* feat(filesystem): Enhance symlink handling and VFS behavior
- Updated tmpfs to require page cache for both regular files and symlinks to ensure proper read/write operations.
- Increased the maximum symlink follow count to 40, aligning with Linux 6.6 standards.
- Improved symlink handling in VFS to correctly follow symlinks based on path conditions and trailing slashes.
- Added validation for conflicting flags in vfs_statx to prevent invalid operations.
- Refined syscall implementations for symlink and lstat to adhere to Linux semantics, ensuring correct behavior for symlink creation and path resolution.
Signed-off-by: longjin <longjin@DragonOS.org>
* fix(vfs): 修正符号链接跟随次数的处理逻辑
- 将 VFS_MAX_FOLLOW_SYMLINK_TIMES 从 40 调整为 41,以保留 0 的禁用语义并实现最多
40 次跟随的 Linux 语义
- 重构路径解析逻辑,明确区分 max_follow_times 为
0(完全禁用跟随)、1(计数耗尽)及 >=2(允许继续跟随)三种情况
- 确保在计数耗尽(max_follow_times == 1)且需要跟随时正确返回 ELOOP 错误
Signed-off-by: longjin <longjin@DragonOS.org>
---------
Signed-off-by: longjin <longjin@DragonOS.org>
- Set default umask to 0022 for new filesystem instances
- Add apply_umask_for_create() and chmod_preserve_type() helper functions
- Implement proper permission checks for file creation and chmod operations
- Fix fchmod syscall to work correctly and reject O_PATH file descriptors
- Add open_create_test to gvisor test suite
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(filesystem): Implement EventFd filesystem and enhance VFS inode capabilities
- Introduced EventFdFs as a new pseudo-filesystem to support eventfd file descriptors, including methods for root inode retrieval and filesystem information.
- Enhanced IndexNode trait with is_stream, supports_seek, supports_pread, and supports_pwrite methods to streamline file operation semantics for stream-like files.
- Updated file handling in VFS to utilize new inode capabilities, ensuring correct behavior for pread, pwrite, and lseek operations.
- Added eventfd_test to the syscall whitelist for testing purposes.
This implementation aligns with Linux semantics for eventfd and improves the overall VFS design by consolidating stream behavior checks.
Signed-off-by: longjin <longjin@DragonOS.org>
* fix(vfs): 修复pread/pwrite中O_PATH和流式对象的错误处理顺序
- 调整O_PATH文件描述符的错误处理顺序,确保优先返回EBADF
- 为流式对象(FMODE_STREAM)添加ESPIPE错误处理,避免权限检查导致的误报
- 分离权限检查逻辑,确保错误码符合Linux语义
Signed-off-by: longjin <longjin@DragonOS.org>
---------
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(vfs): Implement append lock manager for file operations
- Introduced an `AppendLockManager` to ensure atomicity for append operations across filesystems, preventing data corruption in concurrent write scenarios.
- Updated file write methods to utilize the new append lock mechanism, ensuring that appending to files respects the latest end-of-file position.
- Enhanced `write_append` and `pwrite_append` methods to support forced append semantics, aligning with Linux behavior.
- Initialized the append lock manager during VFS initialization to ensure it is ready before any file write operations.
This addition improves the reliability of file operations in a multi-threaded environment, particularly for append scenarios.
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(kernel): 添加jhash库并用于append_lock的哈希计算
Signed-off-by: longjin <longjin@DragonOS.org>
---------
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(procfs): Add /proc/[pid]/mountinfo and /proc/[pid]/maps support
- Introduced new ProcFileType variants for /proc/[pid]/mountinfo and /proc/[pid]/maps.
- Implemented content generation for /proc/[pid]/mountinfo and /proc/[pid]/maps to align with Linux semantics.
- Updated ProcFS inode creation to include these new files for each process.
- Enhanced path handling in the VFS to ensure correct resolution based on process-specific root and current working directory.
This addition improves the process filesystem's functionality and compatibility with Linux behavior.
* feat(filesystem): Enhance page cache management in tmpfs
- Added an unevictable flag to the PageCache structure, allowing pages to be marked as unevictable to prevent reclamation.
- Updated the TmpfsInode structure to integrate page cache management, replacing direct data manipulation with page cache operations for read and write methods.
- Refactored truncate and resize methods to utilize the new page cache functionality, ensuring consistency and improved memory management.
* feat(filesystem): Enhance tmpfs functionality and VFS constraints
- Implemented support for readahead in tmpfs, allowing for optimized data retrieval.
- Added checks for filename length across various VFS operations to prevent errors related to excessively long names.
- Updated the tmpfs implementation to handle read and write operations directly through the page cache, improving memory management.
- Enhanced rename functionality to ensure type compatibility and empty directory checks during operations.
- Increased maximum path length and defined maximum single filename length for better filesystem compliance.
* refactor(fs): 重构tmpfs重命名逻辑并修复MountFSInode的move_to委托
- 将tmpfs跨目录移动逻辑提取为独立函数`tmpfs_move_entry_between_dirs`
- 优化锁顺序以避免死锁,按inode_id顺序锁定目录
- 修复MountFSInode::move_to中目标inode解包问题,确保正确委托给底层文件系统
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(filesystem): Implement zero-page creation for tmpfs and enhance page fault handling
- Added `create_zero_pages` method to `InnerPageCache` for efficient zero-page creation, optimizing memory usage in tmpfs.
- Updated `Tmpfs` to utilize the new zero-page creation during read and write operations, ensuring seamless handling of page faults.
- Enhanced `PageFaultHandler` with `pagecache_fault_zero` to manage page faults specifically for tmpfs, allowing for direct page cache access without disk I/O.
This improves the performance and reliability of memory file systems by reducing unnecessary allocations and ensuring proper page management.
* refactor(syscall): Rename check_and_clone_cstr to vfs_check_and_clone_cstr for clarity
- Updated the user access module to introduce vfs_check_and_clone_cstr, enhancing clarity in its purpose for VFS operations.
- Refactored sys_openat and utimensat to utilize the new vfs_check_and_clone_cstr function, ensuring consistent handling of C string paths across the filesystem.
---------
Signed-off-by: longjin <longjin@DragonOS.org>
- Added `from_slice` method to `CacheBlock` for creating instances directly from slices, avoiding unnecessary allocations.
- Introduced `write_data` method in `CacheBlock` to allow in-place updates of block data.
- Updated `insert_one_block` and `immediate_write` methods in `BlockCache` to accept slices instead of vectors, improving performance and memory usage.
- Implemented error handling for block size validation in multiple locations to ensure data integrity.
- Change `FileMapInfo::page_cache` to `Weak<PageCache>` to fix a memory leak caused by reference cycles.
Signed-off-by: longjin <longjin@DragonOS.org>
* ci: Remove unused COMMIT_SHORT variable from nightly build workflow
- Eliminated the COMMIT_SHORT variable from the nightly build workflow as it was not being utilized, streamlining the script.
* ci: Update nightly build workflow to conditionally run build and publish jobs
- Added conditions to the build and publish jobs in the nightly build workflow to ensure they only execute for specific events or when the repository matches 'DragonOS-Community/DragonOS'. This enhances control over workflow execution.
- Updated the nightly build workflow to include distinct build and publish jobs.
- Added steps to compress build artifacts into a tarball and upload them for later use.
- Modified the Dockerfile to copy the compressed artifacts instead of individual files, enhancing efficiency and organization.
- Added HOME, RUSTUP_DIST_SERVER, and RUSTUP_UPDATE_ROOT environment variables to the nightly build workflow to enhance Rust toolchain management and configuration.
* fix(net): udp getsockname/getpeername
* feat(ci): add test whitelist for new available inet syscall
---------
Co-authored-by: longjin <longjin@DragonOS.org>
* fix(tty): Enhance TTY driver and device management
- Updated the TTY driver to handle both master and slave types more effectively during close operations, ensuring proper cleanup of device entries in /dev/pts.
- Improved the handling of controlling TTY detachment for processes, adding support for the TIOCNOTTY command.
- Refactored the PTY device initialization to ensure correct metadata settings and device registration.
- Added a symlink for /dev/ptmx to point to the internal devpts node, preventing ENOENT errors during early access.
These changes enhance the robustness and compatibility of the TTY subsystem with Linux semantics.
Signed-off-by: longjin <longjin@DragonOS.org>
* refactor(tty): Improve PTY device management and cleanup logic
- Enhanced the `PtyDevPtsLink` structure to manage the lifecycle of PTY devices more effectively, including precise unlinking of directory entries and freeing of indices upon closure.
- Refactored the close operation in the TTY driver to utilize the new management logic, ensuring proper cleanup of master and slave PTY devices.
- Removed redundant code related to device entry removal, streamlining the cleanup process and aligning with Linux semantics.
Signed-off-by: longjin <longjin@DragonOS.org>
---------
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(filesystem): Add tmpfs support and integrate with devfs
- 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>
* feat(filesystem): Implement atomic size management for tmpfs
- 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>
---------
Signed-off-by: longjin <longjin@DragonOS.org>
* feat(filesystem): Add pwritev2 syscall implementation
- Introduced the pwritev2 syscall, allowing vectorized writes with offset and flags, enhancing compatibility with Linux semantics.
- Implemented validation for file descriptors and offsets, ensuring robust error handling.
- Reused core logic from pwritev for the new syscall, maintaining consistency in file writing operations.
This addition improves the VFS layer's functionality and aligns with Linux behavior for vectorized writing operations.
Signed-off-by: longjin <longjin@DragonOS.org>
* fmt
---------
Signed-off-by: longjin <longjin@DragonOS.org>