Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/filesystem_copier_action.h" |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 6 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 7 | #include <sys/stat.h> |
| 8 | #include <sys/types.h> |
| 9 | #include <errno.h> |
| 10 | #include <fcntl.h> |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 11 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 12 | #include <algorithm> |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 13 | #include <cstdlib> |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 14 | #include <map> |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 15 | #include <string> |
| 16 | #include <vector> |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 17 | |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 18 | #include <gio/gio.h> |
| 19 | #include <gio/gunixinputstream.h> |
| 20 | #include <gio/gunixoutputstream.h> |
| 21 | #include <glib.h> |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 22 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 23 | #include "update_engine/filesystem_iterator.h" |
| 24 | #include "update_engine/subprocess.h" |
| 25 | #include "update_engine/utils.h" |
| 26 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 27 | using std::map; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 28 | using std::min; |
| 29 | using std::string; |
| 30 | using std::vector; |
| 31 | |
| 32 | namespace chromeos_update_engine { |
| 33 | |
| 34 | namespace { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 35 | const off_t kCopyFileBufferSize = 128 * 1024; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 36 | } // namespace {} |
| 37 | |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 38 | FilesystemCopierAction::FilesystemCopierAction( |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 39 | bool copying_kernel_install_path, |
| 40 | bool verify_hash) |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 41 | : copying_kernel_install_path_(copying_kernel_install_path), |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 42 | verify_hash_(verify_hash), |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 43 | src_stream_(NULL), |
| 44 | dst_stream_(NULL), |
| 45 | read_done_(false), |
| 46 | failed_(false), |
| 47 | cancelled_(false), |
| 48 | filesystem_size_(kint64max) { |
| 49 | // A lot of code works on the implicit assumption that processing is done on |
| 50 | // exactly 2 ping-pong buffers. |
| 51 | COMPILE_ASSERT(arraysize(buffer_) == 2 && |
| 52 | arraysize(buffer_state_) == 2 && |
| 53 | arraysize(buffer_valid_size_) == 2 && |
| 54 | arraysize(canceller_) == 2, |
| 55 | ping_pong_buffers_not_two); |
| 56 | for (int i = 0; i < 2; ++i) { |
| 57 | buffer_state_[i] = kBufferStateEmpty; |
| 58 | buffer_valid_size_[i] = 0; |
| 59 | canceller_[i] = NULL; |
| 60 | } |
| 61 | } |
| 62 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 63 | void FilesystemCopierAction::PerformAction() { |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 64 | // Will tell the ActionProcessor we've failed if we return. |
| 65 | ScopedActionCompleter abort_action_completer(processor_, this); |
| 66 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 67 | if (!HasInputObject()) { |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 68 | LOG(ERROR) << "FilesystemCopierAction missing input object."; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 69 | return; |
| 70 | } |
| 71 | install_plan_ = GetInputObject(); |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 72 | if (!verify_hash_ && install_plan_.is_resume) { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 73 | // No copy or hash verification needed. Done! |
Andrew de los Reyes | f98bff8 | 2010-05-06 13:33:25 -0700 | [diff] [blame] | 74 | if (HasOutputPipe()) |
| 75 | SetOutputObject(install_plan_); |
Darin Petkov | c1a8b42 | 2010-07-19 11:34:49 -0700 | [diff] [blame] | 76 | abort_action_completer.set_code(kActionCodeSuccess); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 77 | return; |
| 78 | } |
| 79 | |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 80 | const string destination = copying_kernel_install_path_ ? |
| 81 | install_plan_.kernel_install_path : |
| 82 | install_plan_.install_path; |
| 83 | string source = verify_hash_ ? destination : copy_source_; |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 84 | if (source.empty()) { |
| 85 | source = copying_kernel_install_path_ ? |
| 86 | utils::BootKernelDevice(utils::BootDevice()) : |
| 87 | utils::BootDevice(); |
| 88 | } |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 89 | int src_fd = open(source.c_str(), O_RDONLY); |
| 90 | if (src_fd < 0) { |
| 91 | PLOG(ERROR) << "Unable to open " << source << " for reading:"; |
| 92 | return; |
| 93 | } |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 94 | |
| 95 | if (!verify_hash_) { |
| 96 | int dst_fd = open(destination.c_str(), |
| 97 | O_WRONLY | O_TRUNC | O_CREAT, |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 98 | 0644); |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 99 | if (dst_fd < 0) { |
| 100 | close(src_fd); |
| 101 | PLOG(ERROR) << "Unable to open " << install_plan_.install_path |
| 102 | << " for writing:"; |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | dst_stream_ = g_unix_output_stream_new(dst_fd, TRUE); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 109 | DetermineFilesystemSize(src_fd); |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 110 | src_stream_ = g_unix_input_stream_new(src_fd, TRUE); |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 111 | |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 112 | for (int i = 0; i < 2; i++) { |
| 113 | buffer_[i].resize(kCopyFileBufferSize); |
| 114 | canceller_[i] = g_cancellable_new(); |
| 115 | } |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 116 | |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 117 | // Start the first read. |
| 118 | SpawnAsyncActions(); |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 119 | |
| 120 | abort_action_completer.set_should_complete(false); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | void FilesystemCopierAction::TerminateProcessing() { |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 124 | for (int i = 0; i < 2; i++) { |
| 125 | if (canceller_[i]) { |
| 126 | g_cancellable_cancel(canceller_[i]); |
| 127 | } |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 131 | void FilesystemCopierAction::Cleanup(ActionExitCode code) { |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 132 | for (int i = 0; i < 2; i++) { |
| 133 | g_object_unref(canceller_[i]); |
| 134 | canceller_[i] = NULL; |
| 135 | } |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 136 | g_object_unref(src_stream_); |
| 137 | src_stream_ = NULL; |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 138 | if (dst_stream_) { |
| 139 | g_object_unref(dst_stream_); |
| 140 | dst_stream_ = NULL; |
| 141 | } |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 142 | if (cancelled_) |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 143 | return; |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 144 | if (code == kActionCodeSuccess && HasOutputPipe()) |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 145 | SetOutputObject(install_plan_); |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 146 | processor_->ActionComplete(this, code); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 149 | void FilesystemCopierAction::AsyncReadReadyCallback(GObject *source_object, |
| 150 | GAsyncResult *res) { |
| 151 | int index = buffer_state_[0] == kBufferStateReading ? 0 : 1; |
| 152 | CHECK(buffer_state_[index] == kBufferStateReading); |
| 153 | |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 154 | GError* error = NULL; |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 155 | CHECK(canceller_[index]); |
| 156 | cancelled_ = g_cancellable_is_cancelled(canceller_[index]) == TRUE; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 157 | |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 158 | ssize_t bytes_read = g_input_stream_read_finish(src_stream_, res, &error); |
| 159 | if (bytes_read < 0) { |
Darin Petkov | a0b9e77 | 2011-10-06 05:05:56 -0700 | [diff] [blame] | 160 | LOG(ERROR) << "Read failed: " << utils::GetAndFreeGError(&error); |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 161 | failed_ = true; |
| 162 | buffer_state_[index] = kBufferStateEmpty; |
| 163 | } else if (bytes_read == 0) { |
| 164 | read_done_ = true; |
| 165 | buffer_state_[index] = kBufferStateEmpty; |
| 166 | } else { |
| 167 | buffer_valid_size_[index] = bytes_read; |
| 168 | buffer_state_[index] = kBufferStateFull; |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 169 | filesystem_size_ -= bytes_read; |
| 170 | } |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 171 | SpawnAsyncActions(); |
| 172 | |
| 173 | if (bytes_read > 0) { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 174 | // If read_done_ is set, SpawnAsyncActions may finalize the hash so the hash |
| 175 | // update below would happen too late. |
| 176 | CHECK(!read_done_); |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 177 | if (!hasher_.Update(buffer_[index].data(), bytes_read)) { |
| 178 | LOG(ERROR) << "Unable to update the hash."; |
| 179 | failed_ = true; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 180 | } |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 181 | if (verify_hash_) { |
| 182 | buffer_state_[index] = kBufferStateEmpty; |
| 183 | } |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 184 | } |
| 185 | } |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 186 | |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 187 | void FilesystemCopierAction::StaticAsyncReadReadyCallback( |
| 188 | GObject *source_object, |
| 189 | GAsyncResult *res, |
| 190 | gpointer user_data) { |
| 191 | reinterpret_cast<FilesystemCopierAction*>(user_data)-> |
| 192 | AsyncReadReadyCallback(source_object, res); |
| 193 | } |
| 194 | |
| 195 | void FilesystemCopierAction::AsyncWriteReadyCallback(GObject *source_object, |
| 196 | GAsyncResult *res) { |
| 197 | int index = buffer_state_[0] == kBufferStateWriting ? 0 : 1; |
| 198 | CHECK(buffer_state_[index] == kBufferStateWriting); |
| 199 | buffer_state_[index] = kBufferStateEmpty; |
| 200 | |
| 201 | GError* error = NULL; |
| 202 | CHECK(canceller_[index]); |
| 203 | cancelled_ = g_cancellable_is_cancelled(canceller_[index]) == TRUE; |
| 204 | |
| 205 | ssize_t bytes_written = g_output_stream_write_finish(dst_stream_, |
| 206 | res, |
| 207 | &error); |
| 208 | if (bytes_written < static_cast<ssize_t>(buffer_valid_size_[index])) { |
| 209 | if (bytes_written < 0) { |
Darin Petkov | a0b9e77 | 2011-10-06 05:05:56 -0700 | [diff] [blame] | 210 | LOG(ERROR) << "Write failed: " << utils::GetAndFreeGError(&error); |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 211 | } else { |
| 212 | LOG(ERROR) << "Write was short: wrote " << bytes_written |
| 213 | << " but expected to write " << buffer_valid_size_[index]; |
| 214 | } |
| 215 | failed_ = true; |
| 216 | } |
| 217 | |
| 218 | SpawnAsyncActions(); |
| 219 | } |
| 220 | |
| 221 | void FilesystemCopierAction::StaticAsyncWriteReadyCallback( |
| 222 | GObject *source_object, |
| 223 | GAsyncResult *res, |
| 224 | gpointer user_data) { |
| 225 | reinterpret_cast<FilesystemCopierAction*>(user_data)-> |
| 226 | AsyncWriteReadyCallback(source_object, res); |
| 227 | } |
| 228 | |
| 229 | void FilesystemCopierAction::SpawnAsyncActions() { |
| 230 | bool reading = false; |
| 231 | bool writing = false; |
| 232 | for (int i = 0; i < 2; i++) { |
| 233 | if (buffer_state_[i] == kBufferStateReading) { |
| 234 | reading = true; |
| 235 | } |
| 236 | if (buffer_state_[i] == kBufferStateWriting) { |
| 237 | writing = true; |
| 238 | } |
| 239 | } |
| 240 | if (failed_ || cancelled_) { |
| 241 | if (!reading && !writing) { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 242 | Cleanup(kActionCodeError); |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 243 | } |
| 244 | return; |
| 245 | } |
| 246 | for (int i = 0; i < 2; i++) { |
| 247 | if (!reading && !read_done_ && buffer_state_[i] == kBufferStateEmpty) { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 248 | int64_t bytes_to_read = std::min(static_cast<int64_t>(buffer_[0].size()), |
| 249 | filesystem_size_); |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 250 | g_input_stream_read_async( |
| 251 | src_stream_, |
| 252 | buffer_[i].data(), |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 253 | bytes_to_read, |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 254 | G_PRIORITY_DEFAULT, |
| 255 | canceller_[i], |
| 256 | &FilesystemCopierAction::StaticAsyncReadReadyCallback, |
| 257 | this); |
| 258 | reading = true; |
| 259 | buffer_state_[i] = kBufferStateReading; |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 260 | } else if (!writing && !verify_hash_ && |
| 261 | buffer_state_[i] == kBufferStateFull) { |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 262 | g_output_stream_write_async( |
| 263 | dst_stream_, |
| 264 | buffer_[i].data(), |
| 265 | buffer_valid_size_[i], |
| 266 | G_PRIORITY_DEFAULT, |
| 267 | canceller_[i], |
| 268 | &FilesystemCopierAction::StaticAsyncWriteReadyCallback, |
| 269 | this); |
| 270 | writing = true; |
| 271 | buffer_state_[i] = kBufferStateWriting; |
| 272 | } |
| 273 | } |
| 274 | if (!reading && !writing) { |
| 275 | // We're done! |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 276 | ActionExitCode code = kActionCodeSuccess; |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 277 | if (hasher_.Finalize()) { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 278 | LOG(INFO) << "Hash: " << hasher_.hash(); |
| 279 | if (verify_hash_) { |
| 280 | if (copying_kernel_install_path_) { |
| 281 | if (install_plan_.kernel_hash != hasher_.raw_hash()) { |
| 282 | code = kActionCodeNewKernelVerificationError; |
| 283 | LOG(ERROR) << "New kernel verification failed."; |
| 284 | } |
| 285 | } else { |
| 286 | if (install_plan_.rootfs_hash != hasher_.raw_hash()) { |
| 287 | code = kActionCodeNewRootfsVerificationError; |
| 288 | LOG(ERROR) << "New rootfs verification failed."; |
| 289 | } |
| 290 | } |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 291 | } else { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 292 | if (copying_kernel_install_path_) { |
| 293 | install_plan_.kernel_hash = hasher_.raw_hash(); |
| 294 | } else { |
| 295 | install_plan_.rootfs_hash = hasher_.raw_hash(); |
| 296 | } |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 297 | } |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 298 | } else { |
Darin Petkov | c2e4a7d | 2010-12-02 14:47:06 -0800 | [diff] [blame] | 299 | LOG(ERROR) << "Unable to finalize the hash."; |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 300 | code = kActionCodeError; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 301 | } |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 302 | Cleanup(code); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 303 | } |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 304 | } |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 305 | |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 306 | void FilesystemCopierAction::DetermineFilesystemSize(int fd) { |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 307 | if (verify_hash_) { |
| 308 | filesystem_size_ = copying_kernel_install_path_ ? |
| 309 | install_plan_.kernel_size : install_plan_.rootfs_size; |
| 310 | LOG(INFO) << "Filesystem size: " << filesystem_size_; |
| 311 | return; |
| 312 | } |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 313 | filesystem_size_ = kint64max; |
| 314 | int block_count = 0, block_size = 0; |
| 315 | if (!copying_kernel_install_path_ && |
| 316 | utils::GetFilesystemSizeFromFD(fd, &block_count, &block_size)) { |
| 317 | filesystem_size_ = static_cast<int64_t>(block_count) * block_size; |
| 318 | LOG(INFO) << "Filesystem size: " << filesystem_size_ << " bytes (" |
| 319 | << block_count << "x" << block_size << ")."; |
| 320 | } |
| 321 | } |
| 322 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 323 | } // namespace chromeos_update_engine |