1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 18:17:34 +00:00

Userland+SystemMonitor: Recognize the MS_RDONLY mount flag

This commit is contained in:
Sergey Bugaev 2020-05-28 18:03:58 +03:00 committed by Andreas Kling
parent fdb71cdf8f
commit 4b300e085d
3 changed files with 11 additions and 4 deletions

View file

@ -78,7 +78,7 @@ static NonnullRefPtr<GUI::Widget> build_graphs_tab();
class UnavailableProcessWidget final : public GUI::Frame { class UnavailableProcessWidget final : public GUI::Frame {
C_OBJECT(UnavailableProcessWidget) C_OBJECT(UnavailableProcessWidget)
public: public:
virtual ~UnavailableProcessWidget() override {} virtual ~UnavailableProcessWidget() override { }
const String& text() const { return m_text; } const String& text() const { return m_text; }
void set_text(String text) { m_text = move(text); } void set_text(String text) { m_text = move(text); }
@ -285,7 +285,7 @@ int main(int argc, char** argv)
class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate { class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate {
public: public:
virtual ~ProgressBarPaintingDelegate() override {} virtual ~ProgressBarPaintingDelegate() override { }
virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override
{ {
@ -357,7 +357,9 @@ NonnullRefPtr<GUI::Widget> build_file_systems_tab()
return object.get("free_block_count").to_u32() * object.get("block_size").to_u32(); return object.get("free_block_count").to_u32() * object.get("block_size").to_u32();
}); });
df_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) { df_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) {
return object.get("readonly").to_bool() ? "Read-only" : "Read/Write"; bool readonly = object.get("readonly").to_bool();
int mount_flags = object.get("mount_flags").to_int();
return readonly || (mount_flags & MS_RDONLY) ? "Read-only" : "Read/Write";
}); });
df_fields.empend("Mount flags", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) { df_fields.empend("Mount flags", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) {
int mount_flags = object.get("mount_flags").to_int(); int mount_flags = object.get("mount_flags").to_int();
@ -375,6 +377,7 @@ NonnullRefPtr<GUI::Widget> build_file_systems_tab()
check(MS_NOEXEC, "noexec"); check(MS_NOEXEC, "noexec");
check(MS_NOSUID, "nosuid"); check(MS_NOSUID, "nosuid");
check(MS_BIND, "bind"); check(MS_BIND, "bind");
check(MS_RDONLY, "ro");
if (builder.string_view().is_empty()) if (builder.string_view().is_empty())
return String("defaults"); return String("defaults");
return builder.to_string(); return builder.to_string();

View file

@ -57,6 +57,8 @@ int main(int argc, char** argv)
flags |= MS_NOEXEC; flags |= MS_NOEXEC;
else if (part == "nosuid") else if (part == "nosuid")
flags |= MS_NOSUID; flags |= MS_NOSUID;
else if (part == "ro")
flags |= MS_RDONLY;
else if (part == "bind") else if (part == "bind")
fprintf(stderr, "Ignoring -o bind, as it doesn't make sense for chroot\n"); fprintf(stderr, "Ignoring -o bind, as it doesn't make sense for chroot\n");
else else

View file

@ -50,6 +50,8 @@ int parse_options(const StringView& options)
flags |= MS_NOSUID; flags |= MS_NOSUID;
else if (part == "bind") else if (part == "bind")
flags |= MS_BIND; flags |= MS_BIND;
else if (part == "ro")
flags |= MS_RDONLY;
else else
fprintf(stderr, "Ignoring invalid option: %s\n", part.to_string().characters()); fprintf(stderr, "Ignoring invalid option: %s\n", part.to_string().characters());
} }
@ -157,7 +159,7 @@ bool print_mounts()
printf("%s on %s type %s (", source.characters(), mount_point.characters(), class_name.characters()); printf("%s on %s type %s (", source.characters(), mount_point.characters(), class_name.characters());
if (readonly) if (readonly || mount_flags & MS_RDONLY)
printf("ro"); printf("ro");
else else
printf("rw"); printf("rw");