diff options
author | Liav A <liavalb@gmail.com> | 2021-08-20 08:49:07 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-08 00:42:20 +0200 |
commit | 74c4c864bdc625c3584cbe6107a1617b946d7a86 (patch) | |
tree | dcb3ab2a528bca209f7bbbb4ff9ee14c7be3c7a6 /Userland/Services/SystemServer | |
parent | a7cb2ca1bf26e25142a5076ad02e5ced31ca2fbc (diff) | |
download | serenity-74c4c864bdc625c3584cbe6107a1617b946d7a86.zip |
Kernel+SystemServer: Simplify the DevTmpFS design
We are no longer have a separate Inode object class for the pts
directory. With a small exception to this, all chmod and chown code
is now at one place.
It's now possible to create any name of a sub-directory in the
filesystem.
Diffstat (limited to 'Userland/Services/SystemServer')
-rw-r--r-- | Userland/Services/SystemServer/main.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp index 4931a7677b..c37c001854 100644 --- a/Userland/Services/SystemServer/main.cpp +++ b/Userland/Services/SystemServer/main.cpp @@ -83,6 +83,13 @@ static void chown_wrapper(const char* path, uid_t uid, gid_t gid) VERIFY_NOT_REACHED(); } } +static void chmod_wrapper(const char* path, mode_t mode) +{ + int rc = chmod(path, mode); + if (rc < 0 && errno != ENOENT) { + VERIFY_NOT_REACHED(); + } +} static void chown_all_matching_device_nodes(group* group, unsigned major_number) { @@ -341,6 +348,21 @@ static void prepare_synthetic_filesystems() VERIFY_NOT_REACHED(); } + rc = symlink("/proc/self/fd/0", "/dev/stdin"); + if (rc < 0) { + VERIFY_NOT_REACHED(); + } + + rc = symlink("/proc/self/fd/1", "/dev/stdout"); + if (rc < 0) { + VERIFY_NOT_REACHED(); + } + + rc = symlink("/proc/self/fd/2", "/dev/stderr"); + if (rc < 0) { + VERIFY_NOT_REACHED(); + } + populate_devfs(); rc = mkdir("/dev/pts", 0755); @@ -357,6 +379,7 @@ static void prepare_synthetic_filesystems() if (rc < 0) { VERIFY_NOT_REACHED(); } + chmod_wrapper("/dev/urandom", 0666); auto phys_group = getgrnam("phys"); VERIFY(phys_group); @@ -376,19 +399,6 @@ static void prepare_synthetic_filesystems() VERIFY(audio_group); chown_wrapper("/dev/audio", 0, audio_group->gr_gid); - rc = symlink("/proc/self/fd/0", "/dev/stdin"); - if (rc < 0) { - VERIFY_NOT_REACHED(); - } - rc = symlink("/proc/self/fd/1", "/dev/stdout"); - if (rc < 0) { - VERIFY_NOT_REACHED(); - } - rc = symlink("/proc/self/fd/2", "/dev/stderr"); - if (rc < 0) { - VERIFY_NOT_REACHED(); - } - // Note: We open the /dev/null device and set file descriptors 0, 1, 2 to it // because otherwise these file descriptors won't have a custody, making // the ProcFS file descriptor links (at /proc/PID/fd/{0,1,2}) to have an @@ -396,7 +406,6 @@ static void prepare_synthetic_filesystems() // This affects also every other process that inherits the file descriptors // from SystemServer, so it is important for other things (also for ProcFS // tests that are running in CI mode). - int stdin_new_fd = open("/dev/null", O_NONBLOCK); if (stdin_new_fd < 0) { VERIFY_NOT_REACHED(); |