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

Unified Diff: utils.cc

Issue 3034026: AU: Provide a reboot_if_needed D-Bus API. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: reboot error code doesn't necessarily signal a problem. Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils.cc
diff --git a/utils.cc b/utils.cc
index b19e6fc112ea29b2b74397970fd6da3e87965720..4c5a195cf4982246ce06d1c68f1ced5a12856b5a 100644
--- a/utils.cc
+++ b/utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,6 +16,7 @@
#include <algorithm>
#include "chromeos/obsolete_logging.h"
#include "update_engine/file_writer.h"
+#include "update_engine/subprocess.h"
using std::min;
using std::string;
@@ -73,7 +74,7 @@ bool PReadAll(int fd, void* buf, size_t count, off_t offset,
}
*out_bytes_read = bytes_read;
return true;
-
+
}
bool ReadFile(const std::string& path, std::vector<char>* out) {
@@ -282,7 +283,7 @@ bool MakeTempFile(const std::string& filename_template,
vector<char> buf(filename_template.size() + 1);
memcpy(&buf[0], filename_template.data(), filename_template.size());
buf[filename_template.size()] = '\0';
-
+
int mkstemp_fd = mkstemp(&buf[0]);
TEST_AND_RETURN_FALSE_ERRNO(mkstemp_fd >= 0);
if (filename) {
@@ -302,7 +303,7 @@ bool MakeTempDirectory(const std::string& dirname_template,
vector<char> buf(dirname_template.size() + 1);
memcpy(&buf[0], dirname_template.data(), dirname_template.size());
buf[dirname_template.size()] = '\0';
-
+
char* return_code = mkdtemp(&buf[0]);
TEST_AND_RETURN_FALSE_ERRNO(return_code != NULL);
*dirname = &buf[0];
@@ -393,9 +394,19 @@ const char* GetGErrorMessage(const GError* error) {
return error->message;
}
+bool Reboot() {
+ vector<string> command;
+ command.push_back("/sbin/shutdown");
+ command.push_back("-r");
+ command.push_back("now");
+ int rc = 0;
+ Subprocess::SynchronousExec(command, &rc);
+ TEST_AND_RETURN_FALSE(rc == 0);
+ return true;
+}
+
const char* const kStatefulPartition = "/mnt/stateful_partition";
} // namespace utils
} // namespace chromeos_update_engine
-
« no previous file with comments | « utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698