Compare commits
No commits in common. "27eacac19c79453a8c957a9b7b8e1290403a2974" and "39ba4c9087eda99c44ee4c7163d1ae1a4435bff4" have entirely different histories.
27eacac19c
...
39ba4c9087
@ -261,7 +261,7 @@ static Result<void> load_service(const os::Path& path)
|
|||||||
|
|
||||||
if (service.command.is_empty())
|
if (service.command.is_empty())
|
||||||
{
|
{
|
||||||
do_log("[init] service file is missing 'Command' entry, aborting!\n");
|
do_log("[init] service file is missing 'Command' or 'Script' entry, aborting!\n");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
username = name.view();
|
username = name.view();
|
||||||
}
|
}
|
||||||
|
|
||||||
execl("/usr/bin/su", "login", "-lp", "--", username.chars(), nullptr);
|
execl("/bin/su", "login", "-lp", "--", username.chars(), nullptr);
|
||||||
|
|
||||||
perror("su");
|
perror("su");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -72,9 +72,10 @@ int main()
|
|||||||
// Now, mount the /dev file system on the new root.
|
// Now, mount the /dev file system on the new root.
|
||||||
mount_devfs();
|
mount_devfs();
|
||||||
|
|
||||||
char* argv[] = { "/usr/bin/init", nullptr };
|
setenv("PATH", "/sbin:/usr/bin", 1);
|
||||||
|
char* argv[] = { "init", nullptr };
|
||||||
char* envp[] = { nullptr };
|
char* envp[] = { nullptr };
|
||||||
execve(argv[0], argv, envp);
|
execvpe(argv[0], argv, envp);
|
||||||
|
|
||||||
fail_errno("Failed to execute init");
|
fail_errno("Failed to execute init");
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
chdir(entry->pw_dir);
|
chdir(entry->pw_dir);
|
||||||
clearenv();
|
clearenv();
|
||||||
setenv("PATH", "/usr/bin:/usr/local/bin", 1);
|
setenv("PATH", "/bin:/sbin", 1);
|
||||||
setpgid(0, 0);
|
setpgid(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
root:toor:0:0:Administrator:/:/usr/bin/sh
|
root:toor:0:0:Administrator:/:/bin/sh
|
||||||
selene:moon:1000:1000:User:/home/selene:/usr/bin/sh
|
selene:moon:1000:1000:User:/home/selene:/bin/sh
|
||||||
|
@ -161,11 +161,7 @@ void io_thread()
|
|||||||
static void timer_interrupt(Registers* regs, void*)
|
static void timer_interrupt(Registers* regs, void*)
|
||||||
{
|
{
|
||||||
Timer::tick();
|
Timer::tick();
|
||||||
if (should_invoke_scheduler())
|
if (should_invoke_scheduler()) Scheduler::invoke(regs);
|
||||||
{
|
|
||||||
Scheduler::invoke(regs);
|
|
||||||
TextConsole::tick_cursor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboard_interrupt(Registers*, void*)
|
static void keyboard_interrupt(Registers*, void*)
|
||||||
|
@ -246,9 +246,6 @@ Result<u64> ConsoleDevice::ioctl(int request, void* arg)
|
|||||||
}
|
}
|
||||||
case TTYSETGFX: {
|
case TTYSETGFX: {
|
||||||
s_is_in_graphical_mode = (bool)arg;
|
s_is_in_graphical_mode = (bool)arg;
|
||||||
if (!s_is_in_graphical_mode) TextConsole::enable_cursor();
|
|
||||||
else
|
|
||||||
TextConsole::disable_cursor();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
default: return err(EINVAL);
|
default: return err(EINVAL);
|
||||||
|
@ -59,8 +59,6 @@ Result<u64> sys_execve(Registers* regs, SyscallArgs args)
|
|||||||
Vector<String> envp;
|
Vector<String> envp;
|
||||||
if (args[2]) envp = TRY(copy_string_vector_from_userspace(args[2]));
|
if (args[2]) envp = TRY(copy_string_vector_from_userspace(args[2]));
|
||||||
|
|
||||||
String cmdline = TRY(String::join(argv, " "));
|
|
||||||
|
|
||||||
if ((calculate_userspace_stack_size(argv) + calculate_userspace_stack_size(envp)) > MAX_ARGV_STACK_SIZE)
|
if ((calculate_userspace_stack_size(argv) + calculate_userspace_stack_size(envp)) > MAX_ARGV_STACK_SIZE)
|
||||||
return err(E2BIG);
|
return err(E2BIG);
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ Result<u64> sys_execve(Registers* regs, SyscallArgs args)
|
|||||||
if (is_setuid) current->auth.euid = current->auth.suid = inode->metadata().uid;
|
if (is_setuid) current->auth.euid = current->auth.suid = inode->metadata().uid;
|
||||||
if (is_setgid) current->auth.egid = current->auth.sgid = inode->metadata().gid;
|
if (is_setgid) current->auth.egid = current->auth.sgid = inode->metadata().gid;
|
||||||
|
|
||||||
current->cmdline = cmdline.chars();
|
current->name = path.chars();
|
||||||
|
|
||||||
image->apply(current);
|
image->apply(current);
|
||||||
|
|
||||||
@ -161,7 +159,7 @@ Result<u64> sys_fork(Registers* regs, SyscallArgs)
|
|||||||
thread->state = ThreadState::Runnable;
|
thread->state = ThreadState::Runnable;
|
||||||
thread->is_kernel = false;
|
thread->is_kernel = false;
|
||||||
thread->fp_data.save();
|
thread->fp_data.save();
|
||||||
thread->cmdline = current->cmdline;
|
thread->name = current->name;
|
||||||
thread->auth = current->auth;
|
thread->auth = current->auth;
|
||||||
thread->current_directory = current->current_directory;
|
thread->current_directory = current->current_directory;
|
||||||
thread->current_directory_path = move(current_directory_path);
|
thread->current_directory_path = move(current_directory_path);
|
||||||
|
@ -35,7 +35,7 @@ Result<u64> sys_pstat(Registers*, SyscallArgs args)
|
|||||||
set_timespec(proc.ps_time, thread->user_ticks_self + thread->kernel_ticks_self);
|
set_timespec(proc.ps_time, thread->user_ticks_self + thread->kernel_ticks_self);
|
||||||
set_timespec(proc.ps_ktime, thread->kernel_ticks_self);
|
set_timespec(proc.ps_ktime, thread->kernel_ticks_self);
|
||||||
set_timespec(proc.ps_utime, thread->kernel_ticks_children);
|
set_timespec(proc.ps_utime, thread->kernel_ticks_children);
|
||||||
strlcpy(proc.ps_name, thread->cmdline.chars(), sizeof(proc.ps_name));
|
strlcpy(proc.ps_name, thread->name.chars(), sizeof(proc.ps_name));
|
||||||
strlcpy(proc.ps_cwd, thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars(),
|
strlcpy(proc.ps_cwd, thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars(),
|
||||||
sizeof(proc.ps_cwd));
|
sizeof(proc.ps_cwd));
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace Scheduler
|
|||||||
g_idle.state = ThreadState::Idle;
|
g_idle.state = ThreadState::Idle;
|
||||||
g_idle.is_kernel = true;
|
g_idle.is_kernel = true;
|
||||||
g_idle.parent = nullptr;
|
g_idle.parent = nullptr;
|
||||||
g_idle.cmdline = "[idle]";
|
g_idle.name = "[idle]";
|
||||||
g_idle.active_directory = nullptr;
|
g_idle.active_directory = nullptr;
|
||||||
|
|
||||||
g_idle.ticks_left = 1;
|
g_idle.ticks_left = 1;
|
||||||
@ -96,7 +96,7 @@ namespace Scheduler
|
|||||||
|
|
||||||
thread->stack = thread_stack;
|
thread->stack = thread_stack;
|
||||||
|
|
||||||
thread->cmdline = name;
|
thread->name = name;
|
||||||
|
|
||||||
thread->is_kernel = true;
|
thread->is_kernel = true;
|
||||||
thread->active_directory = MMU::kernel_page_directory();
|
thread->active_directory = MMU::kernel_page_directory();
|
||||||
@ -148,7 +148,7 @@ namespace Scheduler
|
|||||||
thread->is_kernel = false;
|
thread->is_kernel = false;
|
||||||
thread->id = 1;
|
thread->id = 1;
|
||||||
thread->pgid = 1;
|
thread->pgid = 1;
|
||||||
thread->cmdline = name;
|
thread->name = name;
|
||||||
thread->auth = Credentials { .uid = 0, .euid = 0, .suid = 0, .gid = 0, .egid = 0, .sgid = 0 };
|
thread->auth = Credentials { .uid = 0, .euid = 0, .suid = 0, .gid = 0, .egid = 0, .sgid = 0 };
|
||||||
|
|
||||||
Vector<String> args;
|
Vector<String> args;
|
||||||
@ -374,7 +374,7 @@ namespace Scheduler
|
|||||||
{
|
{
|
||||||
kdbgln("%p %c [%-20s] %4d, parent = (%-18p,%d), state = %d, ticks: (k:%04zu,u:%04zu), status = "
|
kdbgln("%p %c [%-20s] %4d, parent = (%-18p,%d), state = %d, ticks: (k:%04zu,u:%04zu), status = "
|
||||||
"%d, cwd = %s",
|
"%d, cwd = %s",
|
||||||
thread, thread->is_kernel ? 'k' : 'u', thread->cmdline.chars(), thread->id, thread->parent,
|
thread, thread->is_kernel ? 'k' : 'u', thread->name.chars(), thread->id, thread->parent,
|
||||||
thread->parent ? thread->parent->id : 0, (int)thread->state, thread->kernel_ticks_self,
|
thread->parent ? thread->parent->id : 0, (int)thread->state, thread->kernel_ticks_self,
|
||||||
thread->user_ticks_self, thread->status,
|
thread->user_ticks_self, thread->status,
|
||||||
thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars());
|
thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars());
|
||||||
|
@ -123,7 +123,7 @@ struct Thread : public LinkedListNode<Thread>
|
|||||||
|
|
||||||
mode_t umask { 0 };
|
mode_t umask { 0 };
|
||||||
|
|
||||||
StaticString<128> cmdline;
|
StaticString<128> name;
|
||||||
|
|
||||||
String current_directory_path = {};
|
String current_directory_path = {};
|
||||||
SharedPtr<VFS::Inode> current_directory = {};
|
SharedPtr<VFS::Inode> current_directory = {};
|
||||||
|
@ -47,11 +47,6 @@ static bool bold = false;
|
|||||||
static u32 g_x_position = 0;
|
static u32 g_x_position = 0;
|
||||||
static u32 g_y_position = 0;
|
static u32 g_y_position = 0;
|
||||||
|
|
||||||
static constexpr int CURSOR_TIMEOUT = 500;
|
|
||||||
static int current_cursor_timeout = CURSOR_TIMEOUT;
|
|
||||||
static bool cursor_activated = true;
|
|
||||||
static bool cursor_enabled = true;
|
|
||||||
|
|
||||||
static Utf8StateDecoder utf8_decoder;
|
static Utf8StateDecoder utf8_decoder;
|
||||||
|
|
||||||
static Option<EscapeSequenceParser> escape_sequence_parser;
|
static Option<EscapeSequenceParser> escape_sequence_parser;
|
||||||
@ -87,7 +82,7 @@ static void scroll()
|
|||||||
|
|
||||||
static bool should_scroll()
|
static bool should_scroll()
|
||||||
{
|
{
|
||||||
return g_y_position >= Framebuffer::height();
|
return (g_y_position + FONT_HEIGHT) >= Framebuffer::height();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void next_line()
|
static void next_line()
|
||||||
@ -111,11 +106,6 @@ static void erase_current_char()
|
|||||||
Framebuffer::rect(g_x_position, g_y_position, FONT_WIDTH, FONT_HEIGHT, BLACK);
|
Framebuffer::rect(g_x_position, g_y_position, FONT_WIDTH, FONT_HEIGHT, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_cursor()
|
|
||||||
{
|
|
||||||
Framebuffer::rect(g_x_position, g_y_position, FONT_WIDTH, FONT_HEIGHT, WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool at_end_of_screen()
|
static bool at_end_of_screen()
|
||||||
{
|
{
|
||||||
return (g_x_position + FONT_WIDTH) > Framebuffer::width();
|
return (g_x_position + FONT_WIDTH) > Framebuffer::width();
|
||||||
@ -333,11 +323,6 @@ namespace TextConsole
|
|||||||
if (handle_escape_sequence(c)) return;
|
if (handle_escape_sequence(c)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erase the current cursor.
|
|
||||||
if (cursor_enabled) erase_current_char();
|
|
||||||
|
|
||||||
bool should_draw_cursor = cursor_enabled;
|
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case L'\n': {
|
case L'\n': {
|
||||||
@ -360,10 +345,7 @@ namespace TextConsole
|
|||||||
case L'\x1b':
|
case L'\x1b':
|
||||||
case L'\x9b':
|
case L'\x9b':
|
||||||
case L'\x90':
|
case L'\x90':
|
||||||
case L'\x9d':
|
case L'\x9d': escape_sequence_parser = EscapeSequenceParser { (u8)c }; break;
|
||||||
escape_sequence_parser = EscapeSequenceParser { (u8)c };
|
|
||||||
should_draw_cursor = false;
|
|
||||||
break;
|
|
||||||
default: {
|
default: {
|
||||||
if (_iscntrl(c)) return;
|
if (_iscntrl(c)) return;
|
||||||
putwchar_at(c, g_x_position, g_y_position);
|
putwchar_at(c, g_x_position, g_y_position);
|
||||||
@ -376,42 +358,6 @@ namespace TextConsole
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_draw_cursor)
|
|
||||||
{
|
|
||||||
current_cursor_timeout = CURSOR_TIMEOUT;
|
|
||||||
cursor_activated = true;
|
|
||||||
draw_cursor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tick_cursor()
|
|
||||||
{
|
|
||||||
if (!cursor_enabled) return;
|
|
||||||
|
|
||||||
current_cursor_timeout--;
|
|
||||||
if (current_cursor_timeout == 0)
|
|
||||||
{
|
|
||||||
current_cursor_timeout = CURSOR_TIMEOUT;
|
|
||||||
cursor_activated = !cursor_activated;
|
|
||||||
|
|
||||||
if (cursor_activated) draw_cursor();
|
|
||||||
else
|
|
||||||
erase_current_char();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void disable_cursor()
|
|
||||||
{
|
|
||||||
cursor_enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void enable_cursor()
|
|
||||||
{
|
|
||||||
cursor_enabled = true;
|
|
||||||
cursor_activated = true;
|
|
||||||
current_cursor_timeout = CURSOR_TIMEOUT;
|
|
||||||
draw_cursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> putchar(char c)
|
Result<void> putchar(char c)
|
||||||
|
@ -19,9 +19,6 @@ namespace TextConsole
|
|||||||
Result<void> println(const char* str);
|
Result<void> println(const char* str);
|
||||||
void wprintln(const wchar_t* str);
|
void wprintln(const wchar_t* str);
|
||||||
Result<usize> printf(const char* format, ...) _format(1, 2);
|
Result<usize> printf(const char* format, ...) _format(1, 2);
|
||||||
void tick_cursor();
|
|
||||||
void disable_cursor();
|
|
||||||
void enable_cursor();
|
|
||||||
|
|
||||||
u16 rows();
|
u16 rows();
|
||||||
u16 cols();
|
u16 cols();
|
||||||
|
@ -23,7 +23,7 @@ static Result<int> try_execvpe(const char* name, char* const* argv, char* const*
|
|||||||
if (strchr(name, '/')) return execve(name, argv, envp);
|
if (strchr(name, '/')) return execve(name, argv, envp);
|
||||||
|
|
||||||
char* path = getenv("PATH");
|
char* path = getenv("PATH");
|
||||||
if (!path) path = const_cast<char*>("/usr/bin:/usr/local/bin");
|
if (!path) path = const_cast<char*>("/bin:/sbin");
|
||||||
|
|
||||||
Vector<String> paths = TRY(StringView { path }.split(":"));
|
Vector<String> paths = TRY(StringView { path }.split(":"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user