1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

Kernel+LibC+Userland: Support mounting other kinds of filesystems

This commit is contained in:
Sergey Bugaev 2019-08-15 19:13:56 +03:00 committed by Andreas Kling
parent 66a0a12435
commit 425c356288
6 changed files with 58 additions and 46 deletions

View file

@ -2,28 +2,27 @@
#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");
args_parser.add_arg("fstype", "file system type");
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 {
if (argc < 3 || argc > 4) {
args_parser.print_usage();
return 0;
}
const char* devname = argv[1];
const char* mountpoint = argv[2];
const char* fstype = argc == 4 ? argv[3] : "ext2";
if (mount(devname, mountpoint, fstype) < 0) {
perror("mount");
return 1;
}
return 0;
}