diff options
author | Andreas Gampe <agampe@google.com> | 2015-06-26 18:58:42 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-06-30 14:57:17 +0000 |
commit | 52f0aeb8e9f16fa5c3067f6a36be701354448924 (patch) | |
tree | aa9cc5a499ceaa739052bf246d08bbdb1ddc4715 /dex2oat | |
parent | d735c41e95a5d89cc9dad0c78d7d052579d8bd41 (diff) | |
download | art-52f0aeb8e9f16fa5c3067f6a36be701354448924.zip art-52f0aeb8e9f16fa5c3067f6a36be701354448924.tar.gz art-52f0aeb8e9f16fa5c3067f6a36be701354448924.tar.bz2 |
ART: Unlink target oat file before compiling
Dex2oat must create a new file (new inode) when writing to a target
given by name, as the existing file may be in use. So unlink any
existing file first.
Bug: 22047255
Change-Id: Ief942c71564076e39c1e8340d5c4c55286f75896
Diffstat (limited to 'dex2oat')
-rw-r--r-- | dex2oat/dex2oat.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 7a23746..74d5c0c 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1038,6 +1038,10 @@ class Dex2Oat FINAL { bool OpenFile() { bool create_file = !oat_unstripped_.empty(); // as opposed to using open file descriptor if (create_file) { + // We're supposed to create this file. If the file already exists, it may be in use currently. + // We must not change the content of that file, then. So unlink it first. + unlink(oat_unstripped_.c_str()); + oat_file_.reset(OS::CreateEmptyFile(oat_unstripped_.c_str())); if (oat_location_.empty()) { oat_location_ = oat_filename_; |