diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2019-08-15 19:13:56 +0300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-17 12:07:55 +0200 |
commit | 425c356288dbe2c6a01bde6d76e71c1ae0137acf (patch) | |
tree | e6b3c01eef03fce6d59aeba3d119722bda2bfc2b /Userland | |
parent | 66a0a12435dbea6e4c7a773fe317d38c79f697f0 (diff) | |
download | serenity-425c356288dbe2c6a01bde6d76e71c1ae0137acf.zip |
Kernel+LibC+Userland: Support mounting other kinds of filesystems
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/mount.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Userland/mount.cpp b/Userland/mount.cpp index 751063799e..0267215f3c 100644 --- a/Userland/mount.cpp +++ b/Userland/mount.cpp @@ -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; } |