Compare commits

..

No commits in common. "15f4f7c72fbc4428b0ad7986dafcf75b447e8e2f" and "27eacac19c79453a8c957a9b7b8e1290403a2974" have entirely different histories.

5 changed files with 26 additions and 6 deletions

View File

@ -35,6 +35,7 @@ luna_app(time.cpp time)
luna_app(ln.cpp ln) luna_app(ln.cpp ln)
luna_app(mktemp.cpp mktemp) luna_app(mktemp.cpp mktemp)
luna_app(sysfuzz.cpp sysfuzz) luna_app(sysfuzz.cpp sysfuzz)
luna_app(pivot_root.cpp pivot_root)
luna_app(cp.cpp cp) luna_app(cp.cpp cp)
luna_app(kill.cpp kill) luna_app(kill.cpp kill)
luna_app(gol.cpp gol) luna_app(gol.cpp gol)

19
apps/pivot_root.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <os/ArgumentParser.h>
#include <sys/syscall.h>
#include <unistd.h>
Result<int> luna_main(int argc, char** argv)
{
StringView new_root;
StringView put_old;
os::ArgumentParser parser;
parser.add_description("Move the current root directory to another directory and replace it with another mount.");
parser.add_system_program_info("pivot_root"_sv);
parser.add_positional_argument(new_root, "new_root", true);
parser.add_positional_argument(put_old, "put_old", true);
parser.parse(argc, argv);
long rc = syscall(SYS_pivot_root, new_root.chars(), put_old.chars());
return Result<int>::from_syscall(rc);
}

View File

@ -19,20 +19,21 @@ constexpr u8 RIGHT_SHIFT = 0x36;
constexpr u8 CAPS_LOCK = 0x3a; constexpr u8 CAPS_LOCK = 0x3a;
constexpr u8 LEFT_CONTROL = 0x1D; constexpr u8 LEFT_CONTROL = 0x1D;
constexpr u8 TAB = 0x0F;
constexpr u8 LEFT_ALT = 0x38; constexpr u8 LEFT_ALT = 0x38;
constexpr u8 F11 = 0x57; constexpr u8 F11 = 0x57;
constexpr u8 F12 = 0x58; constexpr u8 F12 = 0x58;
static bool should_ignore_key(u8 scancode) static bool should_ignore_key(u8 scancode)
{ {
return (scancode > 0x3A && scancode < 0x47) || scancode == F11 || scancode == F12; return (scancode > 0x3A && scancode < 0x47) || scancode == TAB || scancode == F11 || scancode == F12;
} }
constexpr char key_table[] = { constexpr char key_table[] = {
'\0', '\0',
'\1', // escape '\1', // escape
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b',
'\t', // tab '\0', // tab
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
'\0', // left ctrl '\0', // left ctrl
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
@ -74,7 +75,7 @@ constexpr char shifted_key_table[] = {
'\0', '\0',
'\1', // escape '\1', // escape
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b',
'\t', // tab '\0', // tab
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n',
'\0', // left ctrl '\0', // left ctrl
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~',

View File

@ -106,7 +106,6 @@ void ConsoleDevice::process_key_event(u8 scancode)
{ {
TextConsole::putwchar(L'\b'); TextConsole::putwchar(L'\b');
if (_iscntrl(maybe_char.value())) TextConsole::putwchar(L'\b'); if (_iscntrl(maybe_char.value())) TextConsole::putwchar(L'\b');
if (maybe_char.value() == '\t') TextConsole::wprint(L"\b\b");
} }
return; return;
} }
@ -180,7 +179,7 @@ void ConsoleDevice::process_key_event(u8 scancode)
if (m_settings.c_lflag & ECHOCTL) if (m_settings.c_lflag & ECHOCTL)
{ {
bool should_echo = true; bool should_echo = true;
if (key == '\n' || key == '\t' || key == '\0' || key == m_settings.c_cc[VEOF]) should_echo = false; if (key == '\n' || key == '\0' || key == m_settings.c_cc[VEOF]) should_echo = false;
if (should_echo) if (should_echo)
{ {