cpio-2.10 -- building mt fails badly

View: New views
5 Messages — Rating Filter:   Alert me  

cpio-2.10 -- building mt fails badly

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

my attempt to build mt as part of cpio-2.10 failed badly:

(1) src/mt.c must include "configmake.h" in order to define LOCALEDIR
and "paxlib.h" in order to define xxx (don't remember).

(2) mt_SOURCES should be declared to include mt.c and fatal.c

according to the ChangeLog fatal.c used to be in lib/ and thus be part of
libcpio.a, why has this been changed.

(3) when compiling mt.c, there are implicit declarations of `argmatch' and
`argmatch_invalid'.  I do, however, get an `mt' executable, but...

Including argmatch.h makes thing only worse because the use of argmatch in
mt.c(main) is incompatible with the definition in gnu/argmatch.[ch].

Thus the `mt' execuatble almost certainly is bad, will segfault or...

(4) a minor final item: the explicit dependency in src/Makefile.am should
use '.$(OBJEXT)' instead of '.o' (for cygwin).

==================

attached is a small patch addressing the points 1, 2, and 4.

Regards
Peter Breitenlohner <peb@...>



Re: cpio-2.10 -- building mt fails badly

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 30 Jul 2009, Peter Breitenlohner wrote:

>
> attached is a small patch addressing the points 1, 2, and 4.

Sorry, I forgot to attach the patch.

Regards
Peter Breitenlohner <peb@...>
diff -ur cpio-2.10.orig/src/Makefile.am cpio-2.10/src/Makefile.am
--- cpio-2.10.orig/src/Makefile.am 2009-06-19 11:24:50.000000000 +0200
+++ cpio-2.10/src/Makefile.am 2009-07-29 18:27:31.000000000 +0200
@@ -37,6 +37,10 @@
  makepath.c\
  userspec.c
 
+mt_SOURCES = \
+ fatal.c\
+ mt.c
+
 noinst_HEADERS =\
  cpio.h\
  cpiohdr.h\
@@ -50,4 +54,4 @@
 
 LDADD=../lib/libpax.a ../gnu/libgnu.a @INTLLIBS@
 
-mt.o main.o: ../lib/rmt-command.h
+mt.$(OBJEXT) main.$(OBJEXT): ../lib/rmt-command.h
diff -ur cpio-2.10.orig/src/mt.c cpio-2.10/src/mt.c
--- cpio-2.10.orig/src/mt.c 2009-02-14 19:15:50.000000000 +0100
+++ cpio-2.10/src/mt.c 2009-07-29 18:36:50.000000000 +0200
@@ -77,6 +77,9 @@
 #endif
 #include <rmt-command.h>
 
+#include "configmake.h"
+#include "paxlib.h"
+
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
 #endif

Re: cpio-2.10 -- building mt fails badly

by Sergey Poznyakoff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter Breitenlohner <peb@...> 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
      "bug-gnu-utils@...".  (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);
 }
 

Re: cpio-2.10 -- building mt fails badly

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 31 Jul 2009, Sergey Poznyakoff wrote:

>> my attempt to build mt as part of cpio-2.10 failed badly:
>
> Thanks for reporting. Please, apply the attached patch.

Hi Sergey,

works nicely. Thanks for your quick answer.

Regards
Peter



cpio-2.10.90 (alpha) available

by Sergey Poznyakoff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Please be informed that a new alpha version of cpio (cpio-2.10.90) is
available for download from ftp://alpha.gnu.org/gnu/cpio.
This version fixes build problems discovered recently
by Peter Breitenlohner.

Here are the compressed sources:
  ftp://alpha.gnu.org/gnu/cpio/cpio-2.10.90.tar.gz   (1.3MB)
  ftp://alpha.gnu.org/gnu/cpio/cpio-2.10.90.tar.bz2  (929KB)

Here are the GPG detached signatures[*]:
  ftp://alpha.gnu.org/gnu/cpio/cpio-2.10.90.tar.gz.sig
  ftp://alpha.gnu.org/gnu/cpio/cpio-2.10.90.tar.bz2.sig

Here are the MD5 and SHA1 checksums:

f5a2733acd0f7ce32df427b72ada10a9  cpio-2.10.90.tar.gz
213f6a0ecdcd3d3512ce23e43bdccf67  cpio-2.10.90.tar.bz2
b72e037d2dc34d795e2e8e30a806484832019276  cpio-2.10.90.tar.gz
a56bd3f80a33181318e87967afa9116a952bcfe0  cpio-2.10.90.tar.bz2

[*] You can use either of the above signature files to verify that
the corresponding file (without the .sig suffix) is intact.  First,
be sure to download both the .sig file and the corresponding tarball.
Then, run a command like this:

  gpg --verify cpio-2.10.90.tar.gz.sig

If that command fails because you don't have the required public key,
then run this command to import it:

  gpg --keyserver keys.gnupg.net --recv-keys 55D0C732

and rerun the `gpg --verify' command.

This release was bootstrapped with the following tools:
  Autoconf 2.63
  Automake 1.11
  Gnulib-tool 0.0.2231-836f3
  Makeinfo 4.13

Regards,
Sergey