usage (0);
/* Check for invalid combinations of arguments. */
- if ((dir_arg && strip_files)
- || (optind == argc)
- || (optind == argc - 1 && !dir_arg))
- usage (1);
+ if (dir_arg && strip_files)
+ error (1, 0,
+ "the strip option may not be used when installing a directory");
+
+ if (optind == argc || (optind == argc - 1 && !dir_arg))
+ {
+ error (0, 0, "too few arguments");
+ usage (1);
+ }
if (symbolic_mode)
{
}
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'. */
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]);
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]);
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