This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] better error output from ar when given a directory

if you feed a directory to ar when trying to create an archive, the error is a 
bit misleading:
$ mkdir foo
$ touch foo.c
$ ar rcv foo.a foo.c foo
a - foo.c
a - foo
ar: foo.a: Is a directory

the Debian guys got a bug report a long time ago about this issue:
but i cant seem to find any conversation on the binutils list about it ... so 
lets start one :)

updated/tweaked patch against latest cvs is attached ... Debian has been using 
this since and Gentoo since without any known 

Attachment: pgp00000.pgp
Description: PGP signature

--- bfd/opncls.c
+++ bfd/opncls.c
@@ -182,6 +182,15 @@ bfd_fopen (const char *filename, const c
   bfd *nbfd;
   const bfd_target *target_vec;
+  struct stat s;
+  if ((fd != -1 && fstat (fd, &s) == 0) ||
+      (fd == -1 && stat (filename, &s) == 0))
+    if (S_ISDIR(s.st_mode))
+      {
+        bfd_set_error (bfd_error_file_not_recognized);
+        return NULL;
+      }
   nbfd = _bfd_new_bfd ();
   if (nbfd == NULL)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]