[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-cpio] cpio-2.10 -- building mt fails badly
From: |
Sergey Poznyakoff |
Subject: |
Re: [Bug-cpio] cpio-2.10 -- building mt fails badly |
Date: |
Fri, 31 Jul 2009 10:45:29 +0300 |
Peter Breitenlohner <address@hidden> ha escrit:
> my attempt to build mt as part of cpio-2.10 failed badly:
Thanks for reporting. Please, apply the attached patch.
Regards,
Sergey
diff --git a/src/mt.c b/src/mt.c
index 5d128a9..e0a3883 100644
--- a/src/mt.c
+++ b/src/mt.c
@@ -73,7 +73,7 @@
#include <stdbool.h>
#ifdef HAVE_LOCALE_H
-# include <locale.h>
+# include <locale.h>
#endif
#include <rmt-command.h>
@@ -105,10 +105,27 @@ int atoi ();
void exit ();
#endif
-char *opnames[] =
+#include <argmatch.h>
+#include <paxlib.h>
+#include "configmake.h"
+
+#define MT_EXIT_SUCCESS 0
+#define MT_EXIT_INVOP 1
+#define MT_EXIT_FAILURE 2
+
+char const * const opnames[] =
{
- "eof", "weof", "fsf", "bsf", "fsr", "bsr",
- "rewind", "offline", "rewoffl", "eject", "status",
+ "eof",
+ "weof",
+ "fsf",
+ "bsf",
+ "fsr",
+ "bsr",
+ "rewind",
+ "offline",
+ "rewoffl",
+ "eject",
+ "status",
#ifdef MTBSFM
"bsfm",
#endif
@@ -134,8 +151,17 @@ char *opnames[] =
#define MTASF 600 /* Random unused number. */
short operations[] =
{
- MTWEOF, MTWEOF, MTFSF, MTBSF, MTFSR, MTBSR,
- MTREW, MTOFFL, MTOFFL, MTOFFL, MTNOP,
+ MTWEOF,
+ MTWEOF,
+ MTFSF,
+ MTBSF,
+ MTFSR,
+ MTBSR,
+ MTREW,
+ MTOFFL,
+ MTOFFL,
+ MTOFFL,
+ MTNOP,
#ifdef MTBSFM
MTBSFM,
#endif
@@ -155,9 +181,10 @@ short operations[] =
#ifdef MTSEEK
MTSEEK,
#endif
- 0
};
+ARGMATCH_VERIFY (opnames, operations);
+
struct option longopts[] =
{
{"file", 1, NULL, 'f'},
@@ -180,8 +207,9 @@ check_type (char *dev, int desc)
if (fstat (desc, &stats) == -1)
stat_error (dev);
if ((stats.st_mode & S_IFMT) != S_IFCHR)
- error (1, 0, _("%s is not a character special file"), dev);
+ error (MT_EXIT_INVOP, 0, _("%s is not a character special file"), dev);
}
+
void
perform_operation (char *dev, int desc, short op, int count)
{
@@ -193,7 +221,7 @@ perform_operation (char *dev, int desc, short op, int count)
error, not 0. This bug has been reported to
"address@hidden". (96/7/10) -BEM */
if (rmtioctl (desc, MTIOCTOP, (char*)&control) == -1)
- error (2, errno, _("%s: rmtioctl failed"), dev);
+ error (MT_EXIT_FAILURE, errno, _("%s: rmtioctl failed"), dev);
}
void
@@ -202,7 +230,7 @@ print_status (char *dev, int desc)
struct mtget status;
if (rmtioctl (desc, MTIOCGET, (char*)&status) == -1)
- error (2, errno, _("%s: rmtioctl failed"), dev);
+ error (MT_EXIT_FAILURE, errno, _("%s: rmtioctl failed"), dev);
printf ("drive type = %d\n", (int) status.mt_type);
#if defined(hpux) || defined(__hpux)
@@ -220,7 +248,7 @@ print_status (char *dev, int desc)
}
void
-usage (FILE *fp,int status)
+usage (FILE *fp, int status)
{
fprintf (fp, _("\
Usage: %s [-V] [-f device] [--file=device] [--rsh-command=command]\n\
@@ -229,6 +257,12 @@ Usage: %s [-V] [-f device] [--file=device]
[--rsh-command=command]\n\
exit (status);
}
+void
+fatal_exit ()
+{
+ exit (MT_EXIT_INVOP);
+}
+
int
main (int argc, char **argv)
{
@@ -264,23 +298,23 @@ main (int argc, char **argv)
case 'V':
printf ("mt (%s)\n", PACKAGE_STRING);
- exit (0);
+ exit (MT_EXIT_SUCCESS);
break;
case 'H':
default:
- usage (stdout, 0);
+ usage (stdout, MT_EXIT_SUCCESS);
}
}
if (optind == argc)
- usage (stderr, 1);
+ usage (stderr, MT_EXIT_INVOP);
- i = argmatch (argv[optind], opnames);
+ i = ARGMATCH (argv[optind], opnames, operations);
if (i < 0)
{
argmatch_invalid ("tape operation", argv[optind], i);
- exit (1);
+ exit (MT_EXIT_INVOP);
}
operation = operations[i];
@@ -295,7 +329,7 @@ main (int argc, char **argv)
count = atoi (argv[optind]);
#endif
if (++optind < argc)
- usage (stderr, 1);
+ usage (stderr, MT_EXIT_INVOP);
if (tapedev == NULL)
{
@@ -304,7 +338,7 @@ main (int argc, char **argv)
#ifdef DEFTAPE /* From sys/mtio.h. */
tapedev = DEFTAPE;
#else
- error (1, 0, _("no tape device specified"));
+ error (MT_EXIT_INVOP, 0, _("no tape device specified"));
#endif
}
@@ -317,7 +351,7 @@ main (int argc, char **argv)
else
tapedesc = rmtopen (tapedev, O_RDONLY, 0, rsh_command_option);
if (tapedesc == -1)
- error (1, errno, _("%s: rmtopen failed"), tapedev);
+ error (MT_EXIT_INVOP, errno, _("%s: rmtopen failed"), tapedev);
check_type (tapedev, tapedesc);
if (operation == MTASF)
@@ -330,8 +364,8 @@ main (int argc, char **argv)
print_status (tapedev, tapedesc);
if (rmtclose (tapedesc) == -1)
- error (2, errno, _("%s: rmtclose failed"), tapedev);
+ error (MT_EXIT_FAILURE, errno, _("%s: rmtclose failed"), tapedev);
- exit (0);
+ exit (MT_EXIT_SUCCESS);
}