Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "update_engine/delta_diff_generator.h" | 5 #include "update_engine/delta_diff_generator.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <inttypes.h> | 9 #include <inttypes.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 LOG(INFO) << "Encoding file " << fs_iter.GetPartialPath(); | 162 LOG(INFO) << "Encoding file " << fs_iter.GetPartialPath(); |
| 163 | 163 |
| 164 // We can't visit each dst image inode more than once, as that would | 164 // We can't visit each dst image inode more than once, as that would |
| 165 // duplicate work. Here, we avoid visiting each source image inode | 165 // duplicate work. Here, we avoid visiting each source image inode |
| 166 // more than once. Technically, we could have multiple operations | 166 // more than once. Technically, we could have multiple operations |
| 167 // that read the same blocks from the source image for diffing, but | 167 // that read the same blocks from the source image for diffing, but |
| 168 // we choose not to to avoid complexity. Eventually we will move away | 168 // we choose not to to avoid complexity. Eventually we will move away |
| 169 // from using a graph/cycle detection/etc to generate diffs, and at that | 169 // from using a graph/cycle detection/etc to generate diffs, and at that |
| 170 // time, it will be easy (non-complex) to have many operations read | 170 // time, it will be easy (non-complex) to have many operations read |
| 171 // from the same source blocks. At that time, this code can die. -adlr | 171 // from the same source blocks. At that time, this code can die. -adlr |
| 172 bool should_diff_from_source = true; | 172 bool should_diff_from_source = false; |
| 173 string src_path = old_root + fs_iter.GetPartialPath(); | 173 string src_path = old_root + fs_iter.GetPartialPath(); |
| 174 if (utils::FileExists(src_path.c_str())) { | 174 struct stat src_stbuf; |
|
petkov
2011/02/22 20:04:04
so, if a symlink in the src image is replaced by a
adlr
2011/02/22 23:21:48
Yeah, symlinks could point to bunk data (imagine a
| |
| 175 struct stat src_stbuf; | 175 if (0 == lstat(src_path.c_str(), &src_stbuf) && |
|
petkov
2011/02/22 20:04:04
There's a utils::IsSymlink utility... You could ad
adlr
2011/02/22 23:21:48
I went to do that, then realized I need to get the
| |
| 176 TEST_AND_RETURN_FALSE_ERRNO(0 == stat(src_path.c_str(), &src_stbuf)); | 176 S_ISREG(src_stbuf.st_mode)) { |
| 177 should_diff_from_source = !utils::SetContainsKey(visited_src_inodes, | 177 should_diff_from_source = !utils::SetContainsKey(visited_src_inodes, |
| 178 src_stbuf.st_ino); | 178 src_stbuf.st_ino); |
| 179 visited_src_inodes.insert(src_stbuf.st_ino); | 179 visited_src_inodes.insert(src_stbuf.st_ino); |
| 180 } | 180 } |
| 181 | 181 |
| 182 TEST_AND_RETURN_FALSE(DeltaReadFile(graph, | 182 TEST_AND_RETURN_FALSE(DeltaReadFile(graph, |
| 183 Vertex::kInvalidIndex, | 183 Vertex::kInvalidIndex, |
| 184 blocks, | 184 blocks, |
| 185 (should_diff_from_source ? | 185 (should_diff_from_source ? |
| 186 old_root : | 186 old_root : |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1626 dummy_extent->set_start_block(kSparseHole); | 1626 dummy_extent->set_start_block(kSparseHole); |
| 1627 dummy_extent->set_num_blocks((signature_blob_length + kBlockSize - 1) / | 1627 dummy_extent->set_num_blocks((signature_blob_length + kBlockSize - 1) / |
| 1628 kBlockSize); | 1628 kBlockSize); |
| 1629 } | 1629 } |
| 1630 | 1630 |
| 1631 const char* const kBsdiffPath = "bsdiff"; | 1631 const char* const kBsdiffPath = "bsdiff"; |
| 1632 const char* const kBspatchPath = "bspatch"; | 1632 const char* const kBspatchPath = "bspatch"; |
| 1633 const char* const kDeltaMagic = "CrAU"; | 1633 const char* const kDeltaMagic = "CrAU"; |
| 1634 | 1634 |
| 1635 }; // namespace chromeos_update_engine | 1635 }; // namespace chromeos_update_engine |
| OLD | NEW |