mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:47:34 +00:00
Kernel+SystemServer: Mount filesystems and start TTYServer in userspace
This commit is contained in:
parent
f95c264f17
commit
6778abb999
3 changed files with 36 additions and 44 deletions
4
Base/etc/fstab
Normal file
4
Base/etc/fstab
Normal file
|
@ -0,0 +1,4 @@
|
|||
/dev/hda / ext2
|
||||
proc /proc proc
|
||||
devpts /dev/pts devpts
|
||||
tmp /tmp tmp
|
|
@ -118,20 +118,6 @@ VFS* vfs;
|
|||
load_ksyms();
|
||||
dbgprintf("Loaded ksyms\n");
|
||||
|
||||
// TODO: we should mount these from SystemServer
|
||||
auto procfs = ProcFS::create();
|
||||
procfs->initialize();
|
||||
vfs->mount(procfs, "/proc");
|
||||
|
||||
auto devptsfs = DevPtsFS::create();
|
||||
devptsfs->initialize();
|
||||
vfs->mount(devptsfs, "/dev/pts");
|
||||
|
||||
auto tmpfs = TmpFS::create();
|
||||
if (!tmpfs->initialize())
|
||||
ASSERT_NOT_REACHED();
|
||||
vfs->mount(move(tmpfs), "/tmp");
|
||||
|
||||
// Now, detect whether or not there are actually any floppy disks attached to the system
|
||||
u8 detect = CMOS::read(0x10);
|
||||
RefPtr<FloppyDiskDevice> fd0;
|
||||
|
@ -152,34 +138,13 @@ VFS* vfs;
|
|||
|
||||
int error;
|
||||
|
||||
auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)100, (gid_t)100, (pid_t)0, error, {}, {}, tty0);
|
||||
auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)0, (gid_t)0, (pid_t)0, error, {}, {}, tty0);
|
||||
if (error != 0) {
|
||||
kprintf("init_stage2: error spawning SystemServer: %d\n", error);
|
||||
hang();
|
||||
}
|
||||
system_server_process->set_priority(Process::HighPriority);
|
||||
|
||||
auto* tty1_process = Process::create_user_process("/bin/TTYServer", (uid_t)0, (gid_t)0, (pid_t)0, error, { "/bin/TTYServer", "tty1" }, {}, tty1);
|
||||
if (error != 0) {
|
||||
kprintf("init_stage2: error spawning TTYServer for tty1: %d\n", error);
|
||||
hang();
|
||||
}
|
||||
tty1_process->set_priority(Process::HighPriority);
|
||||
|
||||
auto* tty2_process = Process::create_user_process("/bin/TTYServer", (uid_t)0, (gid_t)0, (pid_t)0, error, { "/bin/TTYServer", "tty2" }, {}, tty2);
|
||||
if (error != 0) {
|
||||
kprintf("init_stage2: error spawning TTYServer for tty2: %d\n", error);
|
||||
hang();
|
||||
}
|
||||
tty2_process->set_priority(Process::HighPriority);
|
||||
|
||||
auto* tty3_process = Process::create_user_process("/bin/TTYServer", (uid_t)0, (gid_t)0, (pid_t)0, error, { "/bin/TTYServer", "tty3" }, {}, tty3);
|
||||
if (error != 0) {
|
||||
kprintf("init_stage2: error spawning TTYServer for tty3: %d\n", error);
|
||||
hang();
|
||||
}
|
||||
tty3_process->set_priority(Process::HighPriority);
|
||||
|
||||
current->process().sys$exit(0);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <LibCore/CFile.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void start_process(const char* prog, int prio)
|
||||
void start_process(const char* prog, const char* arg, int prio, const char* tty = nullptr)
|
||||
{
|
||||
pid_t pid = 0;
|
||||
|
||||
|
@ -32,9 +33,17 @@ void start_process(const char* prog, int prio)
|
|||
int ret = sched_setparam(pid, &p);
|
||||
ASSERT(ret == 0);
|
||||
|
||||
if (tty != nullptr) {
|
||||
close(0);
|
||||
ASSERT(open(tty, O_RDWR) == 0);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
}
|
||||
|
||||
char* progv[256];
|
||||
progv[0] = const_cast<char*>(prog);
|
||||
progv[1] = nullptr;
|
||||
progv[1] = const_cast<char*>(arg);
|
||||
progv[2] = nullptr;
|
||||
ret = execv(prog, progv);
|
||||
if (ret < 0) {
|
||||
dbgprintf("Exec %s failed! %s", prog, strerror(errno));
|
||||
|
@ -72,12 +81,26 @@ int main(int, char**)
|
|||
{
|
||||
int lowest_prio = sched_get_priority_min(SCHED_OTHER);
|
||||
int highest_prio = sched_get_priority_max(SCHED_OTHER);
|
||||
start_process("/bin/LookupServer", lowest_prio);
|
||||
start_process("/bin/WindowServer", highest_prio);
|
||||
start_process("/bin/AudioServer", highest_prio);
|
||||
start_process("/bin/Taskbar", highest_prio);
|
||||
start_process("/bin/Terminal", highest_prio - 1);
|
||||
start_process("/bin/Launcher", highest_prio);
|
||||
|
||||
// Mount the filesystems.
|
||||
start_process("/bin/mount", "-a", highest_prio);
|
||||
wait(nullptr);
|
||||
|
||||
start_process("/bin/TTYServer", "tty0", highest_prio, "/dev/tty0");
|
||||
start_process("/bin/TTYServer", "tty1", highest_prio, "/dev/tty1");
|
||||
start_process("/bin/TTYServer", "tty2", highest_prio, "/dev/tty2");
|
||||
start_process("/bin/TTYServer", "tty3", highest_prio, "/dev/tty3");
|
||||
|
||||
// Drop privileges.
|
||||
setuid(100);
|
||||
setgid(100);
|
||||
|
||||
start_process("/bin/LookupServer", nullptr, lowest_prio);
|
||||
start_process("/bin/WindowServer", nullptr, highest_prio);
|
||||
start_process("/bin/AudioServer", nullptr, highest_prio);
|
||||
start_process("/bin/Taskbar", nullptr, highest_prio);
|
||||
start_process("/bin/Terminal", nullptr, highest_prio - 1);
|
||||
start_process("/bin/Launcher", nullptr, highest_prio);
|
||||
|
||||
// This won't return if we're in test mode.
|
||||
check_for_test_mode();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue