mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Userland: mknod: Don't use major/minor when creating a pipe
This commit is contained in:
parent
d01eba6fa3
commit
b9619989dd
Notes:
sideshowbarker
2024-07-19 04:42:57 +09:00
Author: https://github.com/petelliott Commit: https://github.com/SerenityOS/serenity/commit/b9619989dd7 Pull-request: https://github.com/SerenityOS/serenity/pull/2829 Issue: https://github.com/SerenityOS/serenity/issues/203 Reviewed-by: https://github.com/bugaevc
1 changed files with 15 additions and 5 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue