Skip to content

Conversation

@F1r3d3v
Copy link
Collaborator

@F1r3d3v F1r3d3v commented Jan 2, 2026

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.

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.
Copilot AI review requested due to automatic review settings January 2, 2026 11:10
Copy link
Contributor

Copilot AI left a 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::expected return types and std::span argument 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.

@F1r3d3v F1r3d3v merged commit bf749bd into dev Jan 2, 2026
3 of 4 checks passed
@F1r3d3v F1r3d3v deleted the f1r3d3v/fd branch January 4, 2026 03:06
Jlisowskyy pushed a commit that referenced this pull request Jan 7, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants