Andy-Python-Programmer / aero

Aero is a new modern, experimental, UNIX-like operating system following the monolithic kernel design. Supporting modern PC features such as long mode, 5-level paging, and SMP (multicore), to name a few.

Home Page:https://aero.andypy.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ls returns "error: ENOENT"

xtoto1 opened this issue · comments

image

I don't remember doing anything except rebooting Aero with ls previously working correctly to get the error.

Hmm. I am not able to reproduce it in Qemu. Can you please apply the following diff and try to run the command again and paste the image of what the output after applying this diff.

diff --git a/userland/aero_shell/src/main.rs b/userland/aero_shell/src/main.rs
index 1fdad80cb..80b134b57 100644
--- a/userland/aero_shell/src/main.rs
+++ b/userland/aero_shell/src/main.rs
@@ -149,9 +149,10 @@ fn main() -> Result<(), AeroSyscallError> {
         let mut buffer = [0u8; 256];
         let len = sys_read(0, &mut buffer)?;

-        let mut command_iter = unsafe { core::str::from_utf8_unchecked(&mut buffer) }.trim()
-            [0..len]
-            .split_whitespace();
+        let ins = &unsafe { core::str::from_utf8_unchecked(&mut buffer) }.trim()[0..len];^M
+        let mut command_iter = ins.split_whitespace();^M
+^M
+        println!("{:?}", ins);^M

         let command = command_iter.next();

To apply the diff:

  • Copy the diff into a file (call it b.diff)
  • Run git apply b.diff

This is the output i get after applying the diff. Every command seems to work after returning all the '\u{0}''s except ls which still returns 'error: ENOENT'
image

Hmm. So it looks like the NUL characters are occurring after you have pressed enter. Can you try out printing the StdinBuffer and TtyState on each key press? Quite weird I am not able to reproduce it. Are you using any special flags or smth?

diff --git a/src/aero_kernel/src/drivers/tty.rs b/src/aero_kernel/src/drivers/tty.rs
index b94d0a794..d7ea3db77 100644
--- a/src/aero_kernel/src/drivers/tty.rs
+++ b/src/aero_kernel/src/drivers/tty.rs
@@ -358,7 +358,25 @@ impl KeyboardListener for Tty {
             }

             _ => {}
-        }
+        };
+
+        let stdin = self.stdin.lock_irq();
+        log::debug!(
+            "lshift={}, rshift={}, lctrl={}, rctrl={}, lalt={}, altgr={}, caps={}",
+            state.lshift,
+            state.rshift,
+            state.lctrl,
+            state.rctrl,
+            state.lalt,
+            state.altgr,
+            state.caps,
+        );
+        log::debug!(
+            "back_buffer={:?}, front_buffer={:?}, cursor={:?}",
+            stdin.back_buffer,
+            stdin.front_buffer,
+            stdin.cursor
+        );
     }
 }

After applying the diff there doesnt seem to be much of a difference other than the key presses being printed on the host terminal:
image

but after entering an actual command(ls in this example) i just get this again:
image

i am not using any special flags

Yep can you paste the serial logs in the host terminal here. The prints here are used to debug the actual problem not solve it. It will give more info to the issue.

i piped cargo aero run into log.txt and this is the output:
log.txt

i used the commands clear and ls in order, then shut down

That helped to debug and reproduce the issue! Now it should be fixed by 706421f :^) Turns out that I was not able to reproduce at first since I was not at the latest HEAD 😁. Thanks for reporting the bug!