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

Side by Side Diff: src/platform/update_engine/utils.h

Issue 1881001: AU: Many minor cleanup changes (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 7 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Calls mkdtemp() with the tempate passed. Returns the generated dirname 70 // Calls mkdtemp() with the tempate passed. Returns the generated dirname
71 // in the dirname param. Returns TRUE on success. dirname must not be NULL. 71 // in the dirname param. Returns TRUE on success. dirname must not be NULL.
72 bool MakeTempDirectory(const std::string& dirname_template, 72 bool MakeTempDirectory(const std::string& dirname_template,
73 std::string* dirname); 73 std::string* dirname);
74 74
75 // Deletes a directory and all its contents synchronously. Returns true 75 // Deletes a directory and all its contents synchronously. Returns true
76 // on success. This may be called with a regular file--it will just unlink it. 76 // on success. This may be called with a regular file--it will just unlink it.
77 // This WILL cross filesystem boundaries. 77 // This WILL cross filesystem boundaries.
78 bool RecursiveUnlinkDir(const std::string& path); 78 bool RecursiveUnlinkDir(const std::string& path);
79 79
80 // Returns the root device for a partition. For example,
81 // RootDevice("/dev/sda3") returns "/dev/sda".
82 std::string RootDevice(const std::string& partition_device);
83
84 // Returns the partition number, as a string, of partition_device. For example,
85 // PartitionNumber("/dev/sda3") return "3".
86 std::string PartitionNumber(const std::string& partition_device);
87
80 // Synchronously mount or unmount a filesystem. Return true on success. 88 // Synchronously mount or unmount a filesystem. Return true on success.
81 // Mounts as ext3 with default options. 89 // Mounts as ext3 with default options.
82 bool MountFilesystem(const std::string& device, const std::string& mountpoint, 90 bool MountFilesystem(const std::string& device, const std::string& mountpoint,
83 unsigned long flags); 91 unsigned long flags);
84 bool UnmountFilesystem(const std::string& mountpoint); 92 bool UnmountFilesystem(const std::string& mountpoint);
85 93
94 enum BootLoader {
95 BootLoader_SYSLINUX = 0,
96 BootLoader_CHROME_FIRMWARE = 1
97 };
98 // Detects which bootloader this system uses and returns it via the out
99 // param. Returns true on success.
100 bool GetBootloader(BootLoader* out_bootloader);
101
86 // Returns the error message, if any, from a GError pointer. 102 // Returns the error message, if any, from a GError pointer.
87 const char* GetGErrorMessage(const GError* error); 103 const char* GetGErrorMessage(const GError* error);
88 104
89 // Log a string in hex to LOG(INFO). Useful for debugging. 105 // Log a string in hex to LOG(INFO). Useful for debugging.
90 void HexDumpArray(const unsigned char* const arr, const size_t length); 106 void HexDumpArray(const unsigned char* const arr, const size_t length);
91 inline void HexDumpString(const std::string& str) { 107 inline void HexDumpString(const std::string& str) {
92 HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size()); 108 HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size());
93 } 109 }
94 inline void HexDumpVector(const std::vector<char>& vect) { 110 inline void HexDumpVector(const std::vector<char>& vect) {
95 HexDumpArray(reinterpret_cast<const unsigned char*>(&vect[0]), vect.size()); 111 HexDumpArray(reinterpret_cast<const unsigned char*>(&vect[0]), vect.size());
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 bool _success = (_x); \ 292 bool _success = (_x); \
277 if (!_success) { \ 293 if (!_success) { \
278 LOG(ERROR) << #_x " failed."; \ 294 LOG(ERROR) << #_x " failed."; \
279 return; \ 295 return; \
280 } \ 296 } \
281 } while (0) 297 } while (0)
282 298
283 299
284 300
285 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 301 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
OLDNEW
« no previous file with comments | « src/platform/update_engine/update_check_action_unittest.cc ('k') | src/platform/update_engine/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698