diff options
author | Eli Youngs <eli.m.youngs@gmail.com> | 2022-04-16 21:43:34 -0700 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-04-20 18:35:08 +0200 |
commit | 3afce86e8356d397d19d43845dfcd6cb66dac761 (patch) | |
tree | 2cb5e73b54b7aef6a1842d25c6346ea34570e409 /Userland | |
parent | 9e323241f87efe4fda81437c431bac64bc46f874 (diff) | |
download | serenity-3afce86e8356d397d19d43845dfcd6cb66dac761.zip |
mkfifo: Add support for setting permissions with -m
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/mkfifo.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Userland/Utilities/mkfifo.cpp b/Userland/Utilities/mkfifo.cpp index 6b683c3c0f..3cd722997e 100644 --- a/Userland/Utilities/mkfifo.cpp +++ b/Userland/Utilities/mkfifo.cpp @@ -5,6 +5,7 @@ */ #include <LibCore/ArgsParser.h> +#include <LibCore/FilePermissionsMask.h> #include <LibCore/System.h> #include <LibMain/Main.h> #include <sys/stat.h> @@ -13,14 +14,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio dpath")); + String mode_string; + mode_t mask_reference_mode = 0777; mode_t mode = 0666; Vector<StringView> paths; Core::ArgsParser args_parser; - // FIXME: add -m for file modes + args_parser.add_option(mode_string, "Set FIFO permissions", "mode", 'm', "mode"); args_parser.add_positional_argument(paths, "Paths of FIFOs to create", "paths"); args_parser.parse(arguments); + if (!mode_string.is_empty()) { + auto mask = TRY(Core::FilePermissionsMask::parse(mode_string)); + mode = mask.apply(mask_reference_mode); + } + int exit_code = 0; for (auto path : paths) { auto error_or_void = Core::System::mkfifo(path, mode); |