Compare commits

..

22 Commits

Author SHA1 Message Date
8939edf313
ATA: Mark the CDROM as a block device
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-26 20:30:54 +02:00
921b5ce360
kernel/ATA: Pass extra information to DeviceRegistry
This is needed since merging e7d482e from main.
2023-05-26 20:30:54 +02:00
4dc8a13058
kernel+init: Create a device node in /dev to access the CDROM from userspace!
Still using PIO, though.
2023-05-26 20:30:54 +02:00
b41fe9d45e
kernel/ATA: Read the CDROM's first sector using ATAPI PIO!!
Sadly, for some reason, DMA is not working right now.
This is a problem, as PIO is inconvenient. But hey, it works for now!
2023-05-26 20:30:54 +02:00
6e22d4649f
kernel/x86_64: Implement writing to PCI fields 2023-05-26 20:30:54 +02:00
e864965400
kernel/PCI: Add bit enum for the Command field 2023-05-26 20:30:53 +02:00
74d5e7759f
kernel: Actually register interrupt handlers properly 2023-05-26 20:30:53 +02:00
4d949d48c4
kernel/ATA: Calculate block sizes for ATA devices as well 2023-05-26 20:30:53 +02:00
aaf3934d9a
kernel/ATA: Send a READ CAPACITY packet to an ATA drive on initialization 2023-05-26 20:30:53 +02:00
6854daf673
kernel/ATA: Read the PCI Busmaster registers and start preparing for DMA 2023-05-26 20:30:53 +02:00
3742ae23a1
kernel/ATA: Read the Busmaster base port and verify it 2023-05-26 20:30:53 +02:00
e0c84a0174
kernel: Handle device BARs properly 2023-05-26 20:30:53 +02:00
fc6aa2bb36
kernel/ATA: Read ATA strings properly instead of backwards
Now we can see the model string. What does it say...

"QEMU DVD-ROM". Let's go!
2023-05-26 20:30:53 +02:00
b578680bf5
kernel/ATA: Implement enough to send an IDENTIFY command and read the model number :) 2023-05-26 20:30:53 +02:00
20a1d16606
kernel/ATA: Handle drive IRQs in compatibility mode 2023-05-26 20:30:53 +02:00
a558c3b2d0
kernel/CPU: Allow passing arbitrary data to interrupt handlers 2023-05-26 20:30:53 +02:00
e22c9a9659
kernel/ATA: Start reading/writing registers and detecting drives 2023-05-26 20:30:52 +02:00
6f02dde85e
kernel: Warn if no ATA controller is found 2023-05-26 20:30:52 +02:00
4aa4cd47e2
kernel: Add a KMutex class and use that for ATA::Controller locking 2023-05-26 20:30:52 +02:00
2d28f03304
kernel/x86_64: Add basic ATA controller and channel identification 2023-05-26 20:30:52 +02:00
c83bf29ef4
kernel/PCI: Add more PCI field types 2023-05-26 20:30:52 +02:00
3ca3a138fc
kernel/x86_64: Add a way to register IRQ handlers from other kernel subsystems 2023-05-26 20:30:52 +02:00
12 changed files with 6 additions and 53 deletions

View File

@ -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);

View File

@ -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)
{

View File

@ -13,11 +13,6 @@ class FramebufferDevice : public Device
bool blocking() const override;
bool is_block_device() const override
{
return true;
}
Result<u64> ioctl(int request, void* arg) override;
usize size() const override;

View File

@ -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();

View File

@ -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++)

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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
{