mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
Kernel: mount system call (#396)
It is now possible to mount ext2 `DiskDevice` devices under Serenity on any folder in the root filesystem. Currently any user can do this with any permissions. There's a fair amount of assumptions made here too, that might not be too good, but can be worked on in the future. This is a good start to allow more dynamic operation under the OS itself. It is also currently impossible to unmount and such, and devices will fail to mount in Linux as the FS 'needs to be cleaned'. I'll work on getting `umount` done ASAP to rectify this (as well as working on less assumption-making in the mount syscall. We don't want to just be able to mount DiskDevices!). This could probably be fixed with some `-t` flag or something similar.
This commit is contained in:
parent
3f91d2d0cc
commit
401c87a0cc
17 changed files with 123 additions and 14 deletions
29
Userland/mount.cpp
Normal file
29
Userland/mount.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <LibCore/CArgsParser.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// This version of 'mount' must have the following arguments
|
||||
// 'mount <device_path> <mount_point>
|
||||
// It can currently only mount _physical_ devices found in /dev
|
||||
//
|
||||
// Currently, it is only possible to mount ext2 devices. Sorry! :^)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CArgsParser args_parser("mount");
|
||||
args_parser.add_arg("devname", "device path");
|
||||
args_parser.add_arg("mountpoint", "mount point");
|
||||
CArgsParserResult args = args_parser.parse(argc, argv);
|
||||
|
||||
if (argc == 3) {
|
||||
// Let's use lstat so we can convert devname into a major/minor device pair!
|
||||
if (mount(argv[1], argv[2]) < 0) {
|
||||
perror("mount");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
args_parser.print_usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue