mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
mount: Use more StringView instead of const char*
This commit is contained in:
parent
9d48406312
commit
cf207ad938
1 changed files with 15 additions and 15 deletions
|
@ -41,12 +41,12 @@ static int parse_options(StringView options)
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_source_none(const char* source)
|
static bool is_source_none(StringView source)
|
||||||
{
|
{
|
||||||
return !strcmp("none", source);
|
return source == "none"sv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_source_fd(const char* source)
|
static int get_source_fd(StringView source)
|
||||||
{
|
{
|
||||||
if (is_source_none(source))
|
if (is_source_none(source))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -84,16 +84,16 @@ static ErrorOr<void> mount_all()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* mountpoint = parts[1].characters();
|
auto mountpoint = parts[1];
|
||||||
const char* fstype = parts[2].characters();
|
auto fstype = parts[2];
|
||||||
int flags = parts.size() >= 4 ? parse_options(parts[3]) : 0;
|
int flags = parts.size() >= 4 ? parse_options(parts[3]) : 0;
|
||||||
|
|
||||||
if (strcmp(mountpoint, "/") == 0) {
|
if (mountpoint == "/") {
|
||||||
dbgln("Skipping mounting root");
|
dbgln("Skipping mounting root");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* filename = parts[0].characters();
|
auto filename = parts[0];
|
||||||
|
|
||||||
int fd = get_source_fd(filename);
|
int fd = get_source_fd(filename);
|
||||||
|
|
||||||
|
@ -153,10 +153,10 @@ static ErrorOr<void> print_mounts()
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
const char* source = nullptr;
|
StringView source;
|
||||||
const char* mountpoint = nullptr;
|
StringView mountpoint;
|
||||||
const char* fs_type = nullptr;
|
StringView fs_type;
|
||||||
const char* options = nullptr;
|
StringView options;
|
||||||
bool should_mount_all = false;
|
bool should_mount_all = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
|
@ -170,13 +170,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
if (should_mount_all)
|
if (should_mount_all)
|
||||||
TRY(mount_all());
|
TRY(mount_all());
|
||||||
|
|
||||||
if (!source && !mountpoint)
|
if (source.is_empty() && mountpoint.is_empty())
|
||||||
TRY(print_mounts());
|
TRY(print_mounts());
|
||||||
|
|
||||||
if (source && mountpoint) {
|
if (!source.is_empty() && !mountpoint.is_empty()) {
|
||||||
if (!fs_type)
|
if (fs_type.is_empty())
|
||||||
fs_type = "ext2";
|
fs_type = "ext2";
|
||||||
int flags = options ? parse_options(options) : 0;
|
int flags = !options.is_empty() ? parse_options(options) : 0;
|
||||||
|
|
||||||
int fd = get_source_fd(source);
|
int fd = get_source_fd(source);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue