summaryrefslogtreecommitdiff
path: root/src/mknod.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-10-08 00:34:54 +0000
committerJim Meyering <jim@meyering.net>1994-10-08 00:34:54 +0000
commit5a31cea3d4d2f9293fdb794b950952ae89753883 (patch)
tree355262abdbc7f5680d81be44fb79cab11de51cfa /src/mknod.c
parent0eb406c7e6c83e9c925f0e42b0692dba95aeff79 (diff)
downloadcoreutils-5a31cea3d4d2f9293fdb794b950952ae89753883.tar.xz
.
Diffstat (limited to 'src/mknod.c')
-rw-r--r--src/mknod.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/mknod.c b/src/mknod.c
index 957e11a74..8d7ace86c 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -104,7 +104,17 @@ main (argc, argv)
}
if (argc - optind != 2 && argc - optind != 4)
- usage (1);
+ {
+ const char *msg;
+ if (argc - optind < 2)
+ msg = "too few arguments";
+ else if (argc - optind > 4)
+ msg = "too many arguments";
+ else
+ msg = "wrong number of arguments";
+ error (0, 0, msg);
+ usage (1);
+ }
/* Only check the first character, to allow mnemonic usage like
`mknod /dev/rst0 character 18 0'. */
@@ -116,7 +126,12 @@ main (argc, argv)
error (4, 0, "block special files not supported");
#else
if (argc - optind != 4)
- usage (1);
+ {
+ error (0, 0, "\
+when creating block special files, major and minor device\n\
+numbers must be specified");
+ usage (1);
+ }
if (mknod (argv[optind], newmode | S_IFBLK,
makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3]))))
error (1, errno, "%s", argv[optind]);
@@ -129,7 +144,12 @@ main (argc, argv)
error (4, 0, "character special files not supported");
#else
if (argc - optind != 4)
- usage (1);
+ {
+ error (0, 0, "\
+when creating character special files, major and minor device\n\
+numbers must be specified");
+ usage (1);
+ }
if (mknod (argv[optind], newmode | S_IFCHR,
makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3]))))
error (1, errno, "%s", argv[optind]);
@@ -141,7 +161,11 @@ main (argc, argv)
error (4, 0, "fifo files not supported");
#else
if (argc - optind != 2)
- usage (1);
+ {
+ error (0, 0, "\
+major and minor device numbers may not be specified for fifo files");
+ usage (1);
+ }
if (mkfifo (argv[optind], newmode))
error (1, errno, "%s", argv[optind]);
#endif