use make_tempname() for tmp dir too. from in-tree binutils.

This commit is contained in:
brad 2004-01-08 02:09:54 +00:00
parent 4dd77497cf
commit fbc8c213a9

View File

@ -1,7 +1,21 @@
$OpenBSD: patch-binutils_objcopy_c,v 1.5 2003/10/11 00:52:22 brad Exp $
$OpenBSD: patch-binutils_objcopy_c,v 1.6 2004/01/08 02:09:54 brad Exp $
--- binutils/objcopy.c.orig 2003-06-02 16:35:15.000000000 -0400
+++ binutils/objcopy.c 2003-09-04 02:03:35.000000000 -0400
@@ -1364,7 +1364,7 @@ copy_archive (ibfd, obfd, output_target)
+++ binutils/objcopy.c 2004-01-02 21:36:44.000000000 -0500
@@ -1340,13 +1340,6 @@ copy_object (ibfd, obfd)
}
}
-#undef MKDIR
-#if defined (_WIN32) && !defined (__CYGWIN32__)
-#define MKDIR(DIR, MODE) mkdir (DIR)
-#else
-#define MKDIR(DIR, MODE) mkdir (DIR, MODE)
-#endif
-
/* Read each archive element in turn from IBFD, copy the
contents to temp file, and keep the temp file handle. */
@@ -1364,13 +1357,13 @@ copy_archive (ibfd, obfd, output_target)
} *list, *l;
bfd **ptr = &obfd->archive_head;
bfd *this_element;
@ -9,17 +23,33 @@ $OpenBSD: patch-binutils_objcopy_c,v 1.5 2003/10/11 00:52:22 brad Exp $
+ char *dir = make_tempname (bfd_get_filename (obfd), 1);
/* Make a temp directory to hold the contents. */
if (MKDIR (dir, 0700) != 0)
@@ -1396,7 +1396,7 @@ copy_archive (ibfd, obfd, output_target)
- if (MKDIR (dir, 0700) != 0)
+ if (dir == (char *) NULL)
{
- fatal (_("cannot mkdir %s for archive copying (error: %s)"),
- dir, strerror (errno));
+ fatal (_("cannot make temp directory for archive copying (error: %s)"),
+ strerror (errno));
}
obfd->has_armap = ibfd->has_armap;
@@ -1396,11 +1389,11 @@ copy_archive (ibfd, obfd, output_target)
/* If the file already exists, make another temp dir. */
if (stat (output_name, &buf) >= 0)
{
- output_name = make_tempname (output_name);
- if (MKDIR (output_name, 0700) != 0)
+ output_name = make_tempname (output_name, 1);
if (MKDIR (output_name, 0700) != 0)
+ if (dir == (char *) NULL)
{
fatal (_("cannot mkdir %s for archive copying (error: %s)"),
@@ -2204,7 +2204,7 @@ strip_main (argc, argv)
- fatal (_("cannot mkdir %s for archive copying (error: %s)"),
- output_name, strerror (errno));
+ fatal (_("cannot make temp directory for archive copying (error: %s)"),
+ strerror (errno));
}
l = (struct name_list *) xmalloc (sizeof (struct name_list));
l->name = output_name;
@@ -2204,7 +2197,7 @@ strip_main (argc, argv)
if (output_file != NULL)
tmpname = output_file;
else
@ -28,7 +58,7 @@ $OpenBSD: patch-binutils_objcopy_c,v 1.5 2003/10/11 00:52:22 brad Exp $
status = 0;
copy_file (argv[i], tmpname, input_target, output_target);
@@ -2738,7 +2738,7 @@ copy_main (argc, argv)
@@ -2738,7 +2731,7 @@ copy_main (argc, argv)
if ((output_filename == (char *) NULL) ||
(strcmp (input_filename, output_filename) == 0))
{