Skip to content
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

Refactor and Bug Fixes for both Libc and Kernel #114

Merged
merged 26 commits into from
Nov 20, 2024

Conversation

Galfurian
Copy link
Member

Refactor and Bug Fixes for both Libc and Kernel

Changes

Libc

  • Replaced _syscallN macros with explicit function implementations, ensuring clear naming and direct use of __inline_syscall_N.
  • Standardized function styles with consistent __syscall_return handling.
  • Updated syscall wrappers across unistd, sys, and other libc modules for easier maintenance and extensibility.
  • Fixed formatting issues and streamlined error handling for a cleaner implementation.
  • Disabled mmap and munmap functionalities.

Kernel

  • Improved parameter descriptions and return value documentation for better clarity across files.
  • Simplified and standardized debug logging by removing redundant function names.
  • Added a fget utility in process.c for easier file descriptor retrieval.
  • Enhanced sys_mmap in paging.c to validate file sizes and fetch stats before mapping.
  • Refactored syscall_handler for streamlined argument handling, removing unused 6-argument support.
  • Tweaked VFS and pipe operations with better naming conventions and structural improvements.

Logging

  • Refactored the logging system to include paths relative to CMAKE_SOURCE_DIR for improved clarity and debugging.
  • Fixed noisy debug messages across multiple modules (e.g., timer).
  • Updated assert.c to use pr_emerg for assertion messages, improving debugging formats.

Pipes

  • Introduced pipe system call and pipe_inode_info_t structure for pipe management in VFS.
  • Fixed blocking behavior in pipes.
  • Improved pipe_read, pipe_write, and pipe_close reliability, handling edge cases like absent writers and waiting readers.
  • Refined operations in pipe_read_wake_function to ensure proper behavior for readers when writers are absent.
  • Added new tests for pipes, including t_pipe_child.c and t_pipe_single.c.

Error Handling

  • Enhanced error handling in slab.c with additional input validation, improved logging, and resource cleanup.
  • Fixed a voluntary invalid pointer write in ext2_dealloc_cache to ensure stability and safety.
  • Added error checks to the __RELATIVE_PATH__ macro and resolved Clang warnings for robust path handling.
  • Fixed behavior of sys_nanosleep to return 0 instead of -1.

Testing

  • Updated and extended tests, fixing and cleaning up existing test cases.
  • New pipe tests were added to cover edge cases and enhance reliability.

Bug Fixes

  • Fixed the behavior of nanosleep to prevent incorrect snoozing.
  • Addressed blocking behavior of pipes to ensure proper operation in edge cases.
  • Removed unnecessary error messages in signal.c to clean up log outputs.
  • Cleaned up code in several modules, including redundant functions (e.g., get_current_interrupt_stack_frame).
  • Fixed issues with test cases and ensured compatibility with Clang.

Miscellaneous

  • Removed default QEMU devices in CMake to prevent errors during ATA initialization.
  • Created vfs_dump_superblocks function for easier inspection of superblocks.
  • Moved several files to appropriate locations to improve project organization.
  • Updated slab allocation logic, renaming size to aligned_object_size for clarity.
  • Improved mathematical calculations for converting interval and value to microseconds, ensuring accuracy.
  • Added the init process to the runqueue before initialization for improved startup behavior.
  • Fixed ext2 caching issues to prevent invalid memory access.
  • Removed syslog and debug outputs in several areas to streamline code.

… pipe management in VFS.

- Enhanced `sys/types.h` with `nlink_t`, `blksize_t`, and `blkcnt_t` types for file metadata.
- Modified `vfs_close` and `procfs_close` for error handling and memory management with pipe references.
- Updated `assert.c` to use `pr_emerg` for assertion messages and enhanced debugging format.
- Extended `tests` to include pipe tests, `t_pipe_child.c` and `t_pipe_single.c`.
…hey are either full or empty... that is not fixed, yet.
- No more shouting about empty or full pipes.
- In `pipe_read_wake_function`, we check for absent writers and still wake the sleeping lads.
- `pipe_close` now gives a friendly nudge to waiting readers when all writers decide to close-up shop.
- Before diving into the fray of read and write operations, we now check if there’s data or space, making our code cleaner than an Ork's battle axe after a good fight.
- Introduced a workaround for blocking calls—it's not pretty, but it gets the job done like a 'eavy metal squig!

Waaagh! Pipes are now more reliable than a grot with a slingshot!
…t have been issues with using `outportb` to QEMU serial in user-space, so it was replaced with the more standard syslog method. Turns out, in the future `syslog` is gona be da boss!
…ile initializing ATA.

- Created vfs_dump_superblocks function, a sneaky dumper ta show off dem superblocks for easy inspectin'.
- Fixed some debug messages in ATA.
… microsecond counts, ensuring no ticks get left behind.
- Add new data structures.
- Rename size to aligned_object_size in slab.
…t2_dealloc_cache`. Stopped scribblin' on dodgy pointers-da cache be safe now!
…mproved logging, and resource cleanup. Added checks for NULL pointers, underflows, and inconsistent states. Updated slab allocation, refill, and destruction logic to ensure robustness; no more dodgy inputs sneakin' by.
…IR. Improved log clarity by showing full source paths, making it easier to differentiate between files with identical names across libc and kernel code; no more guessin' where da problem's comin' from.
…ng, ensured robust path handling. Da path be clear now, boss.
- Replaced _syscallN macros with explicit function implementations, ensuring clear naming and direct use of __inline_syscall_N.
- Standardized function styles with consistent __syscall_return handling.
- Updated syscall wrappers across unistd, sys, and other libc modules for easier maintenance and extensibility.
- Fixed formatting issues and streamlined error handling for a cleaner implementation.
- Disable `mmap` and  `munmap`.

On `kernel` side:

- Improved parameter descriptions and return value docs for better clarity across files.
- Simplified and standardized debug logging by removing redundant function names.
- Added a fget utility in process.c for easier file descriptor retrieval.
- Enhanced sys_mmap in paging.c to validate file sizes and fetch stats before mapping.
- Refactored syscall_handler for streamlined argument handling, removing unused 6-argument support.
- Tweaked VFS and pipe operations with better naming and structural improvements, da pipes are flowin’ proppa now.
@Galfurian Galfurian changed the title Develop Refactor and Bug Fixes for both Libc and Kernel Nov 20, 2024
@Galfurian Galfurian merged commit 92caacf into mentos-team:develop Nov 20, 2024
18 checks passed
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.

1 participant