OLD | NEW |
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_FILESYSTEM_COPIER_ACTION_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_FILESYSTEM_COPIER_ACTION_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_FILESYSTEM_COPIER_ACTION_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_FILESYSTEM_COPIER_ACTION_H__ |
7 | 7 |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <string> | 10 #include <string> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 copy_source_("/"), | 54 copy_source_("/"), |
55 skipped_copy_(false) {} | 55 skipped_copy_(false) {} |
56 typedef ActionTraits<FilesystemCopierAction>::InputObjectType | 56 typedef ActionTraits<FilesystemCopierAction>::InputObjectType |
57 InputObjectType; | 57 InputObjectType; |
58 typedef ActionTraits<FilesystemCopierAction>::OutputObjectType | 58 typedef ActionTraits<FilesystemCopierAction>::OutputObjectType |
59 OutputObjectType; | 59 OutputObjectType; |
60 void PerformAction(); | 60 void PerformAction(); |
61 void TerminateProcessing(); | 61 void TerminateProcessing(); |
62 | 62 |
63 // Used for testing, so we can copy from somewhere other than root | 63 // Used for testing, so we can copy from somewhere other than root |
64 void set_copy_source(const string& path) { | 64 void set_copy_source(const std::string& path) { |
65 copy_source_ = path; | 65 copy_source_ = path; |
66 } | 66 } |
67 // Returns true if we detected that a copy was unneeded and thus skipped it. | 67 // Returns true if we detected that a copy was unneeded and thus skipped it. |
68 bool skipped_copy() { return skipped_copy_; } | 68 bool skipped_copy() { return skipped_copy_; } |
69 | 69 |
70 // Debugging/logging | 70 // Debugging/logging |
71 static std::string StaticType() { return "FilesystemCopierAction"; } | 71 static std::string StaticType() { return "FilesystemCopierAction"; } |
72 std::string Type() const { return StaticType(); } | 72 std::string Type() const { return StaticType(); } |
73 | 73 |
74 private: | 74 private: |
75 // These synchronously mount or unmount the given mountpoint | 75 // These synchronously mount or unmount the given mountpoint |
76 bool Mount(const string& device, const string& mountpoint); | 76 bool Mount(const std::string& device, const std::string& mountpoint); |
77 bool Unmount(const string& mountpoint); | 77 bool Unmount(const std::string& mountpoint); |
78 | 78 |
79 // Performs a recursive file/directory copy from copy_source_ to dest_path_. | 79 // Performs a recursive file/directory copy from copy_source_ to dest_path_. |
80 // Doesn't return until the copy has completed. Returns true on success | 80 // Doesn't return until the copy has completed. Returns true on success |
81 // or false on error. | 81 // or false on error. |
82 bool CopySynchronously(); | 82 bool CopySynchronously(); |
83 | 83 |
84 // There are helper functions for CopySynchronously. They handle creating | 84 // There are helper functions for CopySynchronously. They handle creating |
85 // various types of files. They return true on success. | 85 // various types of files. They return true on success. |
86 bool CreateDirSynchronously(const std::string& new_path, | 86 bool CreateDirSynchronously(const std::string& new_path, |
87 const struct stat& stbuf); | 87 const struct stat& stbuf); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 pthread_t helper_thread_; | 120 pthread_t helper_thread_; |
121 | 121 |
122 volatile gint thread_should_exit_; | 122 volatile gint thread_should_exit_; |
123 | 123 |
124 static const char* kCompleteFilesystemMarker; | 124 static const char* kCompleteFilesystemMarker; |
125 | 125 |
126 // Whether or not the destination device is currently mounted. | 126 // Whether or not the destination device is currently mounted. |
127 bool is_mounted_; | 127 bool is_mounted_; |
128 | 128 |
129 // Where the destination device is mounted. | 129 // Where the destination device is mounted. |
130 string dest_path_; | 130 std::string dest_path_; |
131 | 131 |
132 // The path to copy from. Usually left as the default "/", but tests can | 132 // The path to copy from. Usually left as the default "/", but tests can |
133 // change it. | 133 // change it. |
134 string copy_source_; | 134 std::string copy_source_; |
135 | 135 |
136 // The install plan we're passed in via the input pipe. | 136 // The install plan we're passed in via the input pipe. |
137 InstallPlan install_plan_; | 137 InstallPlan install_plan_; |
138 | 138 |
139 // Set to true if we detected the copy was unneeded and thus we skipped it. | 139 // Set to true if we detected the copy was unneeded and thus we skipped it. |
140 bool skipped_copy_; | 140 bool skipped_copy_; |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(FilesystemCopierAction); | 142 DISALLOW_COPY_AND_ASSIGN(FilesystemCopierAction); |
143 }; | 143 }; |
144 | 144 |
145 } // namespace chromeos_update_engine | 145 } // namespace chromeos_update_engine |
146 | 146 |
147 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_FILESYSTEM_COPIER_ACTION_H__ | 147 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_FILESYSTEM_COPIER_ACTION_H__ |
OLD | NEW |