diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-15 03:35:35 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-15 03:35:35 +0000 |
commit | 5ffcaa866f6442c3a1ad3daf95bff45d73835b25 (patch) | |
tree | 41fccfea83e5443585550a1f117682fdae574328 | |
parent | cd4662c7e40fd7c9d51526c07f082eaf5c4e62a6 (diff) | |
download | gdb-5ffcaa866f6442c3a1ad3daf95bff45d73835b25.zip gdb-5ffcaa866f6442c3a1ad3daf95bff45d73835b25.tar.gz gdb-5ffcaa866f6442c3a1ad3daf95bff45d73835b25.tar.bz2 |
From Craig Silverstein: call unlink_if_ordinary.
-rw-r--r-- | gold/output.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gold/output.cc b/gold/output.cc index 60d9496..6406c78 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -29,6 +29,7 @@ #include <sys/mman.h> #include <sys/stat.h> #include <algorithm> +#include "libiberty.h" // for unlink_if_ordinary() #include "parameters.h" #include "object.h" @@ -1685,11 +1686,9 @@ Output_file::open(off_t file_size) // If we fail, continue; this command is merely a best-effort attempt // to improve the odds for open(). - // FIXME: unlink the file if it's a symlink, even a symlink to a dir. - // Or do we want to follow the symlink and unlink its target? struct stat s; - if (::stat(this->name_, &s) == 0 && s.st_size != 0 && S_ISREG(s.st_mode)) - ::unlink(this->name_); + if (::stat(this->name_, &s) == 0 && s.st_size != 0) + unlink_if_ordinary(this->name_); int mode = parameters->output_is_object() ? 0666 : 0777; int o = ::open(this->name_, O_RDWR | O_CREAT | O_TRUNC, mode); |