2023-05-17 18:30:15 +00:00
|
|
|
#include <os/ArgumentParser.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
|
|
|
Result<int> luna_main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
StringView target;
|
2023-06-17 18:58:54 +00:00
|
|
|
StringView fstype { "auto" };
|
2023-06-20 19:39:41 +00:00
|
|
|
StringView source;
|
2023-05-17 18:30:15 +00:00
|
|
|
|
|
|
|
os::ArgumentParser parser;
|
|
|
|
parser.add_description("Mount a file system.");
|
|
|
|
parser.add_system_program_info("mount"_sv);
|
2023-06-20 19:39:41 +00:00
|
|
|
parser.add_positional_argument(source, "source"_sv, true);
|
2023-06-20 19:44:09 +00:00
|
|
|
parser.add_positional_argument(target, "mountpoint"_sv, true);
|
2023-06-17 18:58:54 +00:00
|
|
|
parser.add_value_argument(fstype, 't', "type"_sv, "the file system type to use");
|
2023-05-17 18:30:15 +00:00
|
|
|
parser.parse(argc, argv);
|
|
|
|
|
2023-06-20 19:39:41 +00:00
|
|
|
if (mount(target.chars(), fstype.chars(), source.chars()) < 0)
|
2023-05-17 18:30:15 +00:00
|
|
|
{
|
|
|
|
perror("mount");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|