mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
mkfifo: Add support for setting permissions with -m
This commit is contained in:
parent
9e323241f8
commit
3afce86e83
1 changed files with 9 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/FilePermissionsMask.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -13,14 +14,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
TRY(Core::System::pledge("stdio dpath"));
|
TRY(Core::System::pledge("stdio dpath"));
|
||||||
|
|
||||||
|
String mode_string;
|
||||||
|
mode_t mask_reference_mode = 0777;
|
||||||
mode_t mode = 0666;
|
mode_t mode = 0666;
|
||||||
Vector<StringView> paths;
|
Vector<StringView> paths;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
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.add_positional_argument(paths, "Paths of FIFOs to create", "paths");
|
||||||
args_parser.parse(arguments);
|
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;
|
int exit_code = 0;
|
||||||
for (auto path : paths) {
|
for (auto path : paths) {
|
||||||
auto error_or_void = Core::System::mkfifo(path, mode);
|
auto error_or_void = Core::System::mkfifo(path, mode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue