Compare commits

..

No commits in common. "b0506bf88fde57834dffdb17ed7f131d386f1147" and "cba0a23db974391b19a3d0f6effb8fd020892a93" have entirely different histories.

11 changed files with 6 additions and 48 deletions
apps
kernel/src
libc
include/sys
src/sys
libluna/include/luna

@ -272,8 +272,6 @@ int main()
stdout = fopen("/dev/console", "w");
stderr = fopen("/dev/console", "w");
umask(022);
g_init_log = fopen("/init.log", "w+");
fcntl(fileno(g_init_log), F_SETFD, FD_CLOEXEC);

@ -2,14 +2,6 @@
#include <luna/PathParser.h>
#include <os/ArgumentParser.h>
#include <os/FileSystem.h>
#include <sys/stat.h>
static mode_t s_umask = 0;
static void read_umask()
{
s_umask = umask(0);
}
Result<void> mkdir_recursively(StringView path, mode_t mode)
{
@ -23,7 +15,7 @@ begin:
PathParser parser = TRY(PathParser::create(path.chars()));
auto parent = TRY(parser.dirname());
TRY(mkdir_recursively(parent.view(), (0777 & ~s_umask) | S_IWUSR | S_IXUSR));
TRY(mkdir_recursively(parent.view(), mode));
goto begin;
}
@ -41,18 +33,12 @@ Result<int> luna_main(int argc, char** argv)
parser.add_description("Create directories."_sv);
parser.add_system_program_info("mkdir"_sv);
parser.add_positional_argument(path, "path"_sv, true);
parser.add_value_argument(mode_string, 'm', "mode"_sv, true, "set the mode for the newly created directory");
parser.add_positional_argument(mode_string, "mode"_sv, "755"_sv);
parser.add_switch_argument(recursive, 'p', "parents"_sv,
"if parent directories do not exist, create them as well"_sv);
parser.parse(argc, argv);
read_umask();
mode_t mode;
if (mode_string.is_empty()) mode = 0777 & ~s_umask;
else
mode = (mode_t)parse_unsigned_integer(mode_string.chars(), nullptr, 8) & 01777;
mode_t mode = (mode_t)parse_unsigned_integer(mode_string.chars(), nullptr, 8);
if (recursive)
{

@ -14,7 +14,6 @@ Result<u64> sys_chdir(Registers*, SyscallArgs args)
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth));
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
if (!VFS::can_execute(inode, current->auth)) return err(EACCES);
inode->add_handle();
if (current->current_directory) current->current_directory->remove_handle();
@ -29,7 +28,6 @@ Result<u64> sys_chdir(Registers*, SyscallArgs args)
SharedPtr<VFS::Inode> inode = TRY(VFS::resolve_path(path.chars(), current->auth, current->current_directory));
if (inode->type() != VFS::InodeType::Directory) return err(ENOTDIR);
if (!VFS::can_execute(inode, current->auth)) return err(EACCES);
auto old_wdir = current->current_directory_path.view();

@ -134,7 +134,6 @@ Result<u64> sys_fork(Registers* regs, SyscallArgs)
thread->auth = current->auth;
thread->current_directory = current->current_directory;
thread->current_directory_path = move(current_directory_path);
thread->umask = current->umask;
thread->parent = current;
for (int i = 0; i < FD_MAX; i++)

@ -194,16 +194,3 @@ Result<u64> sys_pipe(Registers*, SyscallArgs args)
return 0;
}
Result<u64> sys_umask(Registers*, SyscallArgs args)
{
mode_t new_umask = (mode_t)args[0];
auto* current = Scheduler::current();
mode_t old_umask = current->umask;
current->umask = new_umask & 0777;
return old_umask;
}

@ -12,7 +12,7 @@ Result<u64> sys_mkdir(Registers*, SyscallArgs args)
Thread* current = Scheduler::current();
auto inode = TRY(VFS::create_directory(path.chars(), current->auth, current->current_directory));
inode->chmod(mode & ~current->umask);
inode->chmod(mode);
inode->chown(current->auth.euid, current->auth.egid);
return 0;

@ -38,7 +38,7 @@ Result<u64> sys_openat(Registers*, SyscallArgs args)
if (error == ENOENT && (flags & O_CREAT) && !path.is_empty())
{
inode = TRY(VFS::create_file(path.chars(), current->auth, parent_inode));
inode->chmod(mode & ~current->umask);
inode->chmod(mode);
inode->chown(current->auth.euid, current->auth.egid);
}
else

@ -87,8 +87,6 @@ struct Thread : public LinkedListNode<Thread>
u8 status { 0 };
mode_t umask { 0 };
StaticString<128> name;
String current_directory_path = {};

@ -38,9 +38,6 @@ extern "C"
/* Retrieve information about a file. */
int fstatat(int dirfd, const char* path, struct stat* st, int flags);
/* Change the process's file creation mask. */
mode_t umask(mode_t mask);
#ifdef __cplusplus
}
#endif

@ -47,9 +47,4 @@ extern "C"
long rc = syscall(SYS_fstatat, dirfd, path, st, flags);
__errno_return(rc, int);
}
mode_t umask(mode_t mask)
{
return (mode_t)syscall(SYS_umask, mask);
}
}

@ -5,7 +5,7 @@
_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) _e(pstat) _e(getrusage) _e(symlinkat) _e(readlinkat) _e(umask)
_e(umount) _e(pstat) _e(getrusage) _e(symlinkat) _e(readlinkat)
enum Syscalls
{