OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium 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/filesystem_copier_action.h" | 5 #include "update_engine/filesystem_copier_action.h" |
6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 29 matching lines...) Expand all Loading... |
40 return; | 40 return; |
41 } | 41 } |
42 install_plan_ = GetInputObject(); | 42 install_plan_ = GetInputObject(); |
43 | 43 |
44 if (install_plan_.is_full_update) { | 44 if (install_plan_.is_full_update) { |
45 // No copy needed. Done! | 45 // No copy needed. Done! |
46 abort_action_completer.set_success(true); | 46 abort_action_completer.set_success(true); |
47 return; | 47 return; |
48 } | 48 } |
49 | 49 |
50 const string source = | 50 string source = copy_source_; |
51 copy_source_.empty() ? utils::BootDevice() : copy_source_; | 51 if (source.empty()) { |
52 LOG(INFO) << "Copying from " << source << " to " | 52 source = copying_kernel_install_path_ ? |
53 << install_plan_.install_path; | 53 utils::BootKernelDevice(utils::BootDevice()) : |
| 54 utils::BootDevice(); |
| 55 } |
| 56 |
| 57 const string destination = copying_kernel_install_path_ ? |
| 58 install_plan_.kernel_install_path : |
| 59 install_plan_.install_path; |
54 | 60 |
55 int src_fd = open(source.c_str(), O_RDONLY); | 61 int src_fd = open(source.c_str(), O_RDONLY); |
56 if (src_fd < 0) { | 62 if (src_fd < 0) { |
57 PLOG(ERROR) << "Unable to open " << source << " for reading:"; | 63 PLOG(ERROR) << "Unable to open " << source << " for reading:"; |
58 return; | 64 return; |
59 } | 65 } |
60 int dst_fd = open(install_plan_.install_path.c_str(), | 66 int dst_fd = open(destination.c_str(), |
61 O_WRONLY | O_TRUNC | O_CREAT, | 67 O_WRONLY | O_TRUNC | O_CREAT, |
62 0644); | 68 0644); |
63 if (dst_fd < 0) { | 69 if (dst_fd < 0) { |
64 close(src_fd); | 70 close(src_fd); |
65 PLOG(ERROR) << "Unable to open " << install_plan_.install_path | 71 PLOG(ERROR) << "Unable to open " << install_plan_.install_path |
66 << " for writing:"; | 72 << " for writing:"; |
67 return; | 73 return; |
68 } | 74 } |
69 | 75 |
70 src_stream_ = g_unix_input_stream_new(src_fd, TRUE); | 76 src_stream_ = g_unix_input_stream_new(src_fd, TRUE); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 src_stream_, | 168 src_stream_, |
163 &buffer_[0], | 169 &buffer_[0], |
164 buffer_.size(), | 170 buffer_.size(), |
165 G_PRIORITY_DEFAULT, | 171 G_PRIORITY_DEFAULT, |
166 canceller_, | 172 canceller_, |
167 &FilesystemCopierAction::StaticAsyncReadyCallback, | 173 &FilesystemCopierAction::StaticAsyncReadyCallback, |
168 this); | 174 this); |
169 } | 175 } |
170 | 176 |
171 } // namespace chromeos_update_engine | 177 } // namespace chromeos_update_engine |
OLD | NEW |