kernel+libc: Remove mknod()
All checks were successful
continuous-integration/drone/push Build is passing

Now that we automatically create files in /dev, mknod() is not needed anymore.
This commit is contained in:
apio 2023-05-18 19:42:14 +02:00
parent d7c563aebd
commit 84bed3ceb3
Signed by: apio
GPG Key ID: B8A7D06E42258954
5 changed files with 4 additions and 50 deletions

View File

@ -31,7 +31,6 @@ set(SOURCES
src/sys/file.cpp
src/sys/id.cpp
src/sys/mkdir.cpp
src/sys/mknod.cpp
src/sys/waitpid.cpp
src/sys/getdents.cpp
src/sys/stat.cpp

View File

@ -1,36 +0,0 @@
#include "Log.h"
#include "fs/VFS.h"
#include "memory/MemoryManager.h"
#include "sys/Syscall.h"
#include "thread/Scheduler.h"
#include <bits/makedev.h>
#include <luna/PathParser.h>
Result<u64> sys_mknod(Registers*, SyscallArgs args)
{
auto path = TRY(MemoryManager::strdup_from_user(args[0]));
mode_t mode = (mode_t)args[1];
dev_t dev = (dev_t)args[2];
Thread* current = Scheduler::current();
u32 maj = luna_dev_major(dev);
u32 min = luna_dev_minor(dev);
auto parser = TRY(PathParser::create(path.chars()));
auto dirname = TRY(parser.dirname());
auto basename = TRY(parser.basename());
TRY(VFS::validate_filename(basename.view()));
auto parent = TRY(VFS::resolve_path(dirname.chars(), current->auth, current->current_directory));
if (!VFS::can_write(parent, current->auth)) return err(EACCES);
auto inode = TRY(parent->fs()->create_device_inode(maj, min));
TRY(parent->add_entry(inode, basename.chars()));
TRY(inode->chmod(mode));
return 0;
}

View File

@ -15,9 +15,6 @@ extern "C"
/* Create a directory. */
int mkdir(const char* path, mode_t mode);
/* Create a special file. */
int mknod(const char* path, mode_t mode, dev_t dev);
/* Change the mode bits of a file. */
int chmod(const char* path, mode_t mode);

View File

@ -12,12 +12,6 @@ extern "C"
__errno_return(rc, int);
}
int mknod(const char* path, mode_t mode, dev_t dev)
{
long rc = syscall(SYS_mknod, path, mode, dev);
__errno_return(rc, int);
}
int chmod(const char* path, mode_t mode)
{
long rc = syscall(SYS_fchmodat, AT_FDCWD, path, mode, 0);

View File

@ -2,10 +2,10 @@
#define enumerate_syscalls(_e) \
_e(exit) _e(clock_gettime) _e(mmap) _e(munmap) _e(usleep) _e(openat) _e(close) _e(read) _e(getpid) _e(write) \
_e(lseek) _e(mkdir) _e(execve) _e(mknod) _e(fork) _e(waitpid) _e(getppid) _e(fcntl) _e(getdents) _e(getuid) \
_e(geteuid) _e(getgid) _e(getegid) _e(setuid) _e(setgid) _e(seteuid) _e(setegid) _e(fchmodat) _e(fchownat) \
_e(ioctl) _e(fstatat) _e(chdir) _e(getcwd) _e(unlinkat) _e(uname) _e(sethostname) _e(dup2) _e(pipe) \
_e(mount) _e(umount)
_e(lseek) _e(mkdir) _e(execve) _e(fork) _e(waitpid) _e(getppid) _e(fcntl) _e(getdents) _e(getuid) _e(geteuid) \
_e(getgid) _e(getegid) _e(setuid) _e(setgid) _e(seteuid) _e(setegid) _e(fchmodat) _e(fchownat) _e(ioctl) \
_e(fstatat) _e(chdir) _e(getcwd) _e(unlinkat) _e(uname) _e(sethostname) _e(dup2) _e(pipe) _e(mount) \
_e(umount)
enum Syscalls
{