Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/utility/image_writer/image_writer_mac.cc

Issue 599853002: [Mac] Use raw disks (/dev/rdisk#) in image_writer_mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a DCHECK in WriteChunk. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/utility/image_writer/image_writer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <CoreFoundation/CoreFoundation.h> 5 #include <CoreFoundation/CoreFoundation.h>
6 #include <IOKit/IOBSD.h> 6 #include <IOKit/IOBSD.h>
7 #include <IOKit/IOKitLib.h> 7 #include <IOKit/IOKitLib.h>
8 #include <IOKit/storage/IOBlockStorageDevice.h> 8 #include <IOKit/storage/IOBlockStorageDevice.h>
9 #include <IOKit/storage/IOMedia.h> 9 #include <IOKit/storage/IOMedia.h>
10 #include <IOKit/storage/IOStorageProtocolCharacteristics.h> 10 #include <IOKit/storage/IOStorageProtocolCharacteristics.h>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 base::ScopedFD child_socket(sockets[1]); 88 base::ScopedFD child_socket(sockets[1]);
89 89
90 // Map the client socket to the client's STDOUT. 90 // Map the client socket to the client's STDOUT.
91 base::FileHandleMappingVector fd_map; 91 base::FileHandleMappingVector fd_map;
92 fd_map.push_back(std::pair<int, int>(child_socket.get(), STDOUT_FILENO)); 92 fd_map.push_back(std::pair<int, int>(child_socket.get(), STDOUT_FILENO));
93 options.fds_to_remap = &fd_map; 93 options.fds_to_remap = &fd_map;
94 94
95 // Find the file path to open. 95 // Find the file path to open.
96 base::FilePath real_device_path; 96 base::FilePath real_device_path;
97 if (device_path_.IsAbsolute()) { 97 if (device_path_.IsAbsolute()) {
98 // This only occurs for tests where the device path is mocked with a
99 // temporary file.
98 real_device_path = device_path_; 100 real_device_path = device_path_;
99 } else { 101 } else {
100 real_device_path = base::FilePath("/dev").Append(device_path_); 102 // Get the raw device file. Writes need to be in multiples of
103 // DAMediaBlockSize (usually 512). This is fine since WriteChunk() writes in
104 // multiples of kMemoryAlignment.
105 real_device_path =
106 base::FilePath("/dev").Append("r" + device_path_.BaseName().value());
101 } 107 }
102 108
103 // Build the command line. 109 // Build the command line.
104 std::string rdwr = base::StringPrintf("%d", O_RDWR); 110 std::string rdwr = base::StringPrintf("%d", O_RDWR);
105 111
106 base::CommandLine cmd_line = base::CommandLine(base::FilePath(kAuthOpenPath)); 112 base::CommandLine cmd_line = base::CommandLine(base::FilePath(kAuthOpenPath));
107 cmd_line.AppendSwitch("-stdoutpipe"); 113 cmd_line.AppendSwitch("-stdoutpipe");
108 // Using AppendSwitchNative will use an equal-symbol which we don't want. 114 // Using AppendSwitchNative will use an equal-symbol which we don't want.
109 cmd_line.AppendArg("-o"); 115 cmd_line.AppendArg("-o");
110 cmd_line.AppendArg(rdwr); 116 cmd_line.AppendArg(rdwr);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 164
159 if (child_exit_status) { 165 if (child_exit_status) {
160 LOG(ERROR) << "Child process returned failure."; 166 LOG(ERROR) << "Child process returned failure.";
161 return false; 167 return false;
162 } 168 }
163 169
164 return device_file_.IsValid(); 170 return device_file_.IsValid();
165 } 171 }
166 172
167 } // namespace image_writer 173 } // namespace image_writer
OLDNEW
« no previous file with comments | « chrome/utility/image_writer/image_writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698