mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:07:35 +00:00
Userland: mknod: Don't use major/minor when creating a pipe
This commit is contained in:
parent
d01eba6fa3
commit
b9619989dd
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()
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +47,17 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
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.
|
// FIXME: Add some kind of option for specifying the file permissions.
|
||||||
if (argc != 5)
|
if (argc < 3)
|
||||||
return usage();
|
return usage();
|
||||||
|
|
||||||
|
if (argv[2][0] == 'p') {
|
||||||
|
if (argc != 3)
|
||||||
|
return usage();
|
||||||
|
} else if (argc != 5) {
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
|
||||||
const char* name = argv[1];
|
const char* name = argv[1];
|
||||||
mode_t mode = 0666;
|
mode_t mode = 0666;
|
||||||
switch (argv[2][0]) {
|
switch (argv[2][0]) {
|
||||||
|
@ -69,8 +75,12 @@ int main(int argc, char** argv)
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
int major = atoi(argv[3]);
|
int major = 0;
|
||||||
int minor = atoi(argv[4]);
|
int minor = 0;
|
||||||
|
if (argc == 5) {
|
||||||
|
major = atoi(argv[3]);
|
||||||
|
minor = atoi(argv[4]);
|
||||||
|
}
|
||||||
|
|
||||||
int rc = mknod(name, mode, encoded_device(major, minor));
|
int rc = mknod(name, mode, encoded_device(major, minor));
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue