-
Notifications
You must be signed in to change notification settings - Fork 2
fix: procfs #32
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
base: main
Are you sure you want to change the base?
fix: procfs #32
Conversation
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 pull request enhances the procfs filesystem implementation with new service files (version, filesystems), adds proper error handling for virtio MSI-X vector mapping, updates spinlock memory order semantics for correctness, and fixes several bugs in procfs directory operations.
Changes:
- Added error handling for MSI-X vector mapping failures in virtio-pci initialization
- Implemented new procfs service files (/proc/version, /proc/filesystems) with proper filesystem table exposure
- Updated atomic memory ordering in spinlock operations from deprecated memory_order_consume to memory_order_acquire and added release semantics
- Fixed multiple bugs in procfs readdir implementation (wrong task/offset usage) and converted cache spinlock to recursive mode
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| drivers/virtio/virtio-pci/main.c | Added error handling for MSI-X vector mapping with proper status reporting |
| kernel/ipc/spinlock.c | Updated memory order semantics for atomic operations (acquire/release) |
| kernel/syscalls/257_openat.c | Added 'syscall:' prefix to debug output for consistency |
| libk/utils/cache.c | Changed to recursive spinlock and removed unnecessary key assertions |
| kernel/fs/vfs.c | Refactored filesystem table from static array to exposed global structure |
| kernel/fs/fstable.c.in | Added nodev attribute to filesystem entries |
| include/aplus/vfs.h | Added fstable_t type definition and VFS_MAX_FILESYSTEMS constant |
| kernel/fs/procfs/procfs_service_version.c | New file implementing /proc/version service |
| kernel/fs/procfs/procfs_service_filesystems.c | New file implementing /proc/filesystems service |
| kernel/fs/procfs/procfs_root_getattr.c | New file implementing getattr for procfs root |
| kernel/fs/procfs/procfs_service_pid.c | Fixed finddir to check inode->name instead of unused name parameter |
| kernel/fs/procfs/procfs_root_readdir.c | Fixed task variable usage and d_off field to use index instead of pos |
| kernel/fs/procfs/procfs_root_finddir.c | Uncommented version and filesystems service lookups |
| kernel/fs/procfs/procfs_mount.c | Enabled getattr operation for procfs root |
| kernel/fs/procfs/procfs.h | Added function declarations for new service files |
| kernel/fs/procfs/procfs_service_{uptime,meminfo,cmdline}.c | Removed overly restrictive inode->sb->root assertions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (isdigit(inode->name[0])) { | ||
|
|
||
| long pid = atol(inode->name); | ||
|
|
||
| if (pid > 0) { | ||
| return procfs_service_pid_inode(inode, pid); | ||
| } else { | ||
| return errno = ENOENT, NULL; | ||
| } | ||
|
|
||
| } else if(strcmp(inode->name, "self") == 0) { | ||
| return procfs_service_pid_inode(inode, current_task->tid); | ||
| } else { | ||
| return errno = ENOENT, NULL; | ||
| } |
Copilot
AI
Jan 15, 2026
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.
The function procfs_service_pid_finddir receives a parameter 'name' but checks 'inode->name' instead. This appears to be incorrect - the function should be checking the 'name' parameter to determine which child entry to find within the current inode directory, not the inode's own name. This logic should match the pattern in procfs_root_finddir which correctly uses the 'name' parameter.
| return errno = ENOENT, NULL; | ||
| } | ||
|
|
||
| } else if(strcmp(inode->name, "self") == 0) { |
Copilot
AI
Jan 15, 2026
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.
Missing space after 'if' keyword. Should be 'if (' instead of 'if(' to match the coding style used throughout the rest of the codebase.
| } else if(strcmp(inode->name, "self") == 0) { | |
| } else if (strcmp(inode->name, "self") == 0) { |
|
|
||
| // if(strcmp(name, "version") == 0) | ||
| // return procfs_version_inode(); | ||
| if(strcmp(name, "version") == 0) |
Copilot
AI
Jan 15, 2026
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.
Missing space after 'if' keyword. Should be 'if (' instead of 'if(' to match the coding style used in surrounding code (see lines 61, 67, 70, 79).
|
|
||
| // if(strcmp(name, "filesystems") == 0) | ||
| // return procfs_filesystems_inode(); | ||
| if(strcmp(name, "filesystems") == 0) |
Copilot
AI
Jan 15, 2026
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.
Missing space after 'if' keyword. Should be 'if (' instead of 'if(' to match the coding style used in surrounding code.
|
|
||
| static char buffer[BUFSIZ] = {0}; | ||
|
|
||
| for(size_t i = 0; i < VFS_MAX_FILESYSTEMS; i++) { |
Copilot
AI
Jan 15, 2026
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.
Missing space after 'for' keyword. Should be 'for (' instead of 'for(' to maintain consistent coding style.
| for(size_t i = 0; i < VFS_MAX_FILESYSTEMS; i++) { | |
| for (size_t i = 0; i < VFS_MAX_FILESYSTEMS; i++) { |
| uint16_t i = k % (vector_limit - 1); | ||
|
|
||
| pci_msix_map_irq(driver->device, &msix, (pci_irq_handler_t)virtio_pci_interrupt, (pci_irq_data_t)driver, i); | ||
| if(pci_msix_map_irq(driver->device, &msix, (pci_irq_handler_t)virtio_pci_interrupt, (pci_irq_data_t)driver, i) < 0) { |
Copilot
AI
Jan 15, 2026
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.
Missing space after 'if' keyword. Should be 'if (' instead of 'if(' to maintain consistent coding style.
| if(pci_msix_map_irq(driver->device, &msix, (pci_irq_handler_t)virtio_pci_interrupt, (pci_irq_data_t)driver, i) < 0) { | |
| if (pci_msix_map_irq(driver->device, &msix, (pci_irq_handler_t)virtio_pci_interrupt, (pci_irq_data_t)driver, i) < 0) { |
| } | ||
|
|
||
| pci_msix_map_irq(driver->device, &msix, (pci_irq_handler_t)virtio_pci_interrupt, (pci_irq_data_t)driver, vector_limit - 1); | ||
| if(pci_msix_map_irq(driver->device, &msix, (pci_irq_handler_t)virtio_pci_interrupt, (pci_irq_data_t)driver, vector_limit - 1) < 0) { |
Copilot
AI
Jan 15, 2026
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.
Missing space after 'if' keyword. Should be 'if (' instead of 'if(' to maintain consistent coding style.
…window management
This pull request introduces several improvements and fixes across the drivers and build system, with a particular focus on the virtio GPU driver, PCI MSI-X handling, and debugging support. The most notable changes include a significant refactor of the virtio GPU framebuffer initialization and update logic, improvements to the PCI MSI-X interrupt handling, and the addition of more granular debug logging for PTY and other subsystems.
Virtio GPU driver improvements
virtio-gpu/main.cto use a dynamic resource ID (virtgpu_fb_resid) and removed hardcoded macros and unused code, improving resource management and readability. The framebuffer is now created, attached, and set as the scanout in a more robust sequence, with error handling for display enablement and command failures. ([[1]](https://github.com/kwrx/aplus/pull/32/files#diff-ea594d89bf0752573aa484e356e537c8f0c900f6957d07f27bad22c974c5e594L56-L57),[[2]](https://github.com/kwrx/aplus/pull/32/files#diff-ea594d89bf0752573aa484e356e537c8f0c900f6957d07f27bad22c974c5e594R89-L105),[[3]](https://github.com/kwrx/aplus/pull/32/files#diff-ea594d89bf0752573aa484e356e537c8f0c900f6957d07f27bad22c974c5e594L115-L160),[[4]](https://github.com/kwrx/aplus/pull/32/files#diff-ea594d89bf0752573aa484e356e537c8f0c900f6957d07f27bad22c974c5e594L198-R180))[drivers/virtio/virtio-gpu/main.cL246-R231](https://github.com/kwrx/aplus/pull/32/files#diff-ea594d89bf0752573aa484e356e537c8f0c900f6957d07f27bad22c974c5e594L246-R231))[drivers/virtio/virtio-gpu/main.cL296-L320](https://github.com/kwrx/aplus/pull/32/files#diff-ea594d89bf0752573aa484e356e537c8f0c900f6957d07f27bad22c974c5e594L296-L320))virtgpu_cmd.c, streamlining resource management commands and improving maintainability. ([[1]](https://github.com/kwrx/aplus/pull/32/files#diff-4fd1958662a1c8900ddb55ee008bf7b2fdc0bd6be1f19faa45ac783b84908a96L48-L59),[[2]](https://github.com/kwrx/aplus/pull/32/files#diff-4fd1958662a1c8900ddb55ee008bf7b2fdc0bd6be1f19faa45ac783b84908a96L68-L79),[[3]](https://github.com/kwrx/aplus/pull/32/files#diff-4fd1958662a1c8900ddb55ee008bf7b2fdc0bd6be1f19faa45ac783b84908a96L88-L96),[[4]](https://github.com/kwrx/aplus/pull/32/files#diff-4fd1958662a1c8900ddb55ee008bf7b2fdc0bd6be1f19faa45ac783b84908a96L105-L128),[[5]](https://github.com/kwrx/aplus/pull/32/files#diff-4fd1958662a1c8900ddb55ee008bf7b2fdc0bd6be1f19faa45ac783b84908a96L138-L158))PCI MSI-X interrupt handling
pci_msix.cto ensure a clean state before masking interrupts, improving reliability. ([drivers/dev/pci/pci_msix.cR116-R118](https://github.com/kwrx/aplus/pull/32/files#diff-f93480b8db103254db27bd9cb9be59fc00eac5e87f8c7c48e3092678717dde4cR116-R118))breakstatements, preventing unnecessary iterations and possible bugs. ([[1]](https://github.com/kwrx/aplus/pull/32/files#diff-f93480b8db103254db27bd9cb9be59fc00eac5e87f8c7c48e3092678717dde4cR203),[[2]](https://github.com/kwrx/aplus/pull/32/files#diff-f93480b8db103254db27bd9cb9be59fc00eac5e87f8c7c48e3092678717dde4cR244))Debug logging enhancements
DEBUG_LEVEL_TRACEfor easier troubleshooting. ([[1]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dL67-R69),[[2]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR192-R194),[[3]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR239-R241),[[4]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR255-R258),[[5]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR267-R276),[[6]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR293-R295),[[7]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR309-R311),[[8]](https://github.com/kwrx/aplus/pull/32/files#diff-819e605dd2015540a65582a6f1cdbe9f74f164edf009a8c8b632bc4c11c8329dR320-R348))#ifinstead of#ifdef, ensuring correct compilation. ([drivers/platform/pc/video/bochs-vga/main.cL269-R269](https://github.com/kwrx/aplus/pull/32/files#diff-0d242fb45fe0c16791acda4d0a7fcd7553e6ff5580dac62be83969a2f6dd1a89L269-R269))Input and console driver fixes
[[1]](https://github.com/kwrx/aplus/pull/32/files#diff-c1e61c0fa5b74c1b69b71bae9933ba1f87832f05208503381618b65f46411b3fL271-R274),[[2]](https://github.com/kwrx/aplus/pull/32/files#diff-c1e61c0fa5b74c1b69b71bae9933ba1f87832f05208503381618b65f46411b3fL382))[drivers/virtio/virtio-console/main.cR152-R169](https://github.com/kwrx/aplus/pull/32/files#diff-bf73670fc756b476b8c6b0195b42973c48cbd2bfffd708f08139789063dd83d9R152-R169))Build system updates
Makefilefor thekiloapp, ensuring proper compilation in cross-build environments. ([apps/extra/kilo/MakefileR1-R5](https://github.com/kwrx/aplus/pull/32/files#diff-0130715cda0bcbb04c66dda8ef166a8c7fbf9db8720d7d9dbec6337133e4b628R1-R5))