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

Add file syscalls #242

Merged
merged 26 commits into from
Sep 15, 2021
Merged

Add file syscalls #242

merged 26 commits into from
Sep 15, 2021

Conversation

vinc
Copy link
Owner

@vinc vinc commented Aug 31, 2021

  • Add file handle table to process
  • Add open syscall
  • Add close syscall
  • Add read syscall
  • Add write syscall
  • Add stat syscall
  • Add seek syscall
  • Add delete syscall
  • Add FileIO for dirs, files, and devices
  • Add /dev/random
  • Add /dev/console
  • Read dirs from userspace

@vinc
Copy link
Owner Author

vinc commented Sep 8, 2021

We can now do syscall::write(1, b"Hello, World\n") 🎉

@vinc
Copy link
Owner Author

vinc commented Sep 10, 2021

Reading the RNG from the FS:
random

@vinc
Copy link
Owner Author

vinc commented Sep 11, 2021

A lot of kernel functions called from userspace still remains:

> rg "sys::[^)]*?\(" src/usr -o --no-filename | sort | uniq -c | sort -h
      1 sys::acpi::shutdown(
      1 sys::allocator::memory_size(
      1 sys::allocator::memory_used(
      1 sys::ata::list(
      1 sys::console::cols(
      1 sys::console::drain(
      1 sys::console::rows(
      1 sys::fs::Dir::delete(
      1 sys::fs::disk_size(
      1 sys::fs::disk_used(
      1 sys::fs::format_ata(
      1 sys::fs::format_mem(
      1 sys::fs::is_mounted(
      1 sys::fs::mount_ata(
      1 sys::fs::mount_mem(
      1 sys::keyboard::set_keyboard(
      1 sys::process::env(
      1 sys::process::envs(
      1 sys::process::set_user(
      1 sys::process::user(
      1 sys::random::get_u64(
      1 sys::time::set_pit_frequency_divider(
      1 sys::vga::set_font(
      1 sys::vga::set_palette(
      2 sys::fs::File::delete(
      2 sys::process::set_dir(
      2 sys::process::set_env(
      3 sys::console::disable_echo(
      3 sys::console::enable_echo(
      3 sys::process::dir(
      4 sys::fs::Dir::create(
      4 sys::random::get_u16(
      5 sys::fs::File::create(
      7 sys::console::end_of_text(
      7 sys::fs::Dir::open(
      8 sys::net::IFACE.lock(
     10 sys::fs::File::open(

@vinc
Copy link
Owner Author

vinc commented Sep 15, 2021

Most of the remaining methods will need to be replaced by device files:

   1 sys::acpi::shutdown(
   1 sys::allocator::memory_size(
   1 sys::allocator::memory_used(
   1 sys::ata::list(
   1 sys::console::cols(
   1 sys::console::drain(
   1 sys::console::rows(
   1 sys::fs::Dir::delete(
   1 sys::fs::File::create(
   1 sys::fs::disk_size(
   1 sys::fs::disk_used(
   1 sys::fs::format_ata(
   1 sys::fs::format_mem(
   1 sys::fs::is_mounted(
   1 sys::fs::mount_ata(
   1 sys::fs::mount_mem(
   1 sys::keyboard::set_keyboard(
   1 sys::process::env(
   1 sys::process::envs(
   1 sys::process::set_user(
   1 sys::process::user(
   1 sys::time::set_pit_frequency_divider(
   1 sys::vga::set_font(
   1 sys::vga::set_palette(
   2 sys::fs::File::delete(
   2 sys::process::set_dir(
   2 sys::process::set_env(
   3 sys::console::disable_echo(
   3 sys::console::enable_echo(
   3 sys::fs::Dir::create(
   3 sys::process::dir(
   6 sys::fs::Dir::open(
   7 sys::console::end_of_text(
   8 sys::net::IFACE.lock(

@vinc vinc marked this pull request as ready for review September 15, 2021 20:22
@vinc vinc merged commit 43ac7cd into trunk Sep 15, 2021
@vinc vinc deleted the feature/file-syscalls branch September 15, 2021 20:27
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