summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2020-07-16 15:34:43 -0600
committerAndreas Kling <kling@serenityos.org>2020-07-19 11:46:37 +0200
commitb9619989dd73e0113c41c3ac8417da252ab5f09a (patch)
tree7e47fe8e8a1bf660c7d2cfbbe08dd973f6c90bdc /Userland
parentd01eba6fa3e144367501c9295a03641cb81f532b (diff)
downloadserenity-b9619989dd73e0113c41c3ac8417da252ab5f09a.zip
Userland: mknod: Don't use major/minor when creating a pipe
Diffstat (limited to 'Userland')
-rw-r--r--Userland/mknod.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/Userland/mknod.cpp b/Userland/mknod.cpp
index 8ec6e1c9e7..7482f08565 100644
--- a/Userland/mknod.cpp
+++ b/Userland/mknod.cpp
@@ -36,7 +36,7 @@ inline constexpr unsigned encoded_device(unsigned major, unsigned minor)
static int usage()
{
- printf("usage: mknod <name> <c|b|p> <major> <minor>\n");
+ printf("usage: mknod <name> <c|b|p> [<major> <minor>]\n");
return 0;
}
@@ -47,11 +47,17 @@ int main(int argc, char** argv)
return 1;
}
- // FIXME: When invoked with type "p", no need for major/minor numbers.
// FIXME: Add some kind of option for specifying the file permissions.
- if (argc != 5)
+ if (argc < 3)
return usage();
+ if (argv[2][0] == 'p') {
+ if (argc != 3)
+ return usage();
+ } else if (argc != 5) {
+ return usage();
+ }
+
const char* name = argv[1];
mode_t mode = 0666;
switch (argv[2][0]) {
@@ -69,8 +75,12 @@ int main(int argc, char** argv)
return usage();
}
- int major = atoi(argv[3]);
- int minor = atoi(argv[4]);
+ int major = 0;
+ int minor = 0;
+ if (argc == 5) {
+ major = atoi(argv[3]);
+ minor = atoi(argv[4]);
+ }
int rc = mknod(name, mode, encoded_device(major, minor));
if (rc < 0) {