-
Notifications
You must be signed in to change notification settings - Fork 0
Implement file descriptor management #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a three-tier file descriptor management system: - Process-local FdTable for file descriptors. - Global OpenFileTable for open file entries. - Global FileTable for system-wide file tracking. Integrates with VFS for file I/O operations through VfsStream. Initializes standard streams (stdin, stdout, stderr) for each process, mapping them to the debug terminal. Adds `open`, `close`, `read`, `write` syscalls. Updates process creation and cleanup to manage FdTables.
Replaces VfsStream abstraction with direct VFS calls for simplified architecture. Introduces Owned/NonOwned type markers to TaggedPointer for proper RAII memory management. Adds seek functionality to file descriptors. Updates process lifetime management to use VirtualPtr with proper cleanup. Removes unused standard stream wrapper classes and simplifies constructors. Standard streams now allocate pipes directly in the fd table, reducing indirection and improving memory safety.
Add helper functions to describe page fault error conditions. Enhance panic messages with detailed diagnostics including faulting address, instruction pointer, and categorized error details for unmapped memory, protection faults, and unresolved faults.
Reduces redundant YAML parsing by loading all feature flag metadata once and storing it in memory. This improves script performance by 8x factor. Previously, each function called yq separately to retrieve flag properties. Now, a single load operation provides all metadata, eliminating duplicate queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a comprehensive file descriptor management system for AlkOS, introducing a three-tier hierarchy (FdTable per process, global OpenFileTable, global FileTable) with reference-counted resource management. The syscall infrastructure is modernized to support std::expected for error handling, std::span for safe buffer passing, and includes new file I/O operations. Core type definitions are migrated from types.hpp to types.h for C compatibility, and uACPI is upgraded from 2.1.0 to 3.2.0.
Key Changes
- Three-tier file descriptor system with RefCounted/RefPtr for automatic resource management
- Syscall handler enhanced with
std::expectedreturn types andstd::spanargument support - Type system reorganization: consolidated type definitions into
types.h(C-compatible)
Reviewed changes
Copilot reviewed 167 out of 170 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| userspace/programs/hello_world/main.cpp | Demonstrates new file I/O syscalls with error handling issues |
| userspace/build/linker.ld | Entry point changed from main to _start |
| scripts/utils/feature_flag_lib.bash | Performance optimization via metadata caching |
| scripts/completions/generate.bash | Fixed fish shell completion formatting |
| libs/libcpp/include/types.hpp | Removed (migrated to types.h) |
| libs/libc/src/include/types.h | Consolidated type definitions for C/C++ compatibility |
| libs/libcontainers/include/data_structures/ref_count.hpp | New RefCounted/RefPtr implementation |
| libs/libcontainers/include/data_structures/tagged_pointer.hpp | Added Owned/NonOwned ownership semantics |
| kernel/src/syscalls/handler.hpp | Enhanced with std::expected and std::span support |
| kernel/src/syscalls/dispatch_table.hpp | Added compile-time validation |
| kernel/src/fs/file_descriptor.hpp | Three-tier FD system architecture |
| kernel/src/fs/file_descriptor.cpp | FD system implementation |
| kernel/src/scheduling/process.hpp | Added FD table and stdio pipes |
| kernel/src/mem/virt/page_fault.cpp | Enhanced diagnostics |
| kernel/thirdparty/uacpi/CMakeLists.txt | uACPI upgrade to 3.2.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Establish a complete file descriptor system (FdTable, FileTable, OpenFileTable) and overhaul the syscall handler to support std::expected returns, std::span arguments, and FAST_CALL. New syscalls for file operations (open, close, read, write, seek) are now available. This commit also transitions core type definitions from types.hpp to types.h for C-compatibility, integrates RefCounted and RefPtr for robust resource handling, upgrades uACPI to 3.2.0, and enhances page fault diagnostics. The new file I/O syscalls are connected to libc and demonstrated in userspace programs.
Establish a complete file descriptor system (FdTable, FileTable, OpenFileTable)
and overhaul the syscall handler to support std::expected returns, std::span
arguments, and FAST_CALL. New syscalls for file operations (open, close, read,
write, seek) are now available.
This commit also transitions core type definitions from types.hpp to types.h for
C-compatibility, integrates RefCounted and RefPtr for robust resource handling,
upgrades uACPI to 3.2.0, and enhances page fault diagnostics. The new file I/O
syscalls are connected to libc and demonstrated in userspace programs.