OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 "update_engine/utils.h" | 5 #include "update_engine/utils.h" |
6 | 6 |
7 #include <sys/mount.h> | 7 #include <sys/mount.h> |
8 #include <sys/resource.h> | 8 #include <sys/resource.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return true; | 43 return true; |
44 } | 44 } |
45 return params.app_track != "buildbot-build" && | 45 return params.app_track != "buildbot-build" && |
46 params.app_track != "developer-build"; | 46 params.app_track != "developer-build"; |
47 } | 47 } |
48 | 48 |
49 bool WriteFile(const char* path, const char* data, int data_len) { | 49 bool WriteFile(const char* path, const char* data, int data_len) { |
50 DirectFileWriter writer; | 50 DirectFileWriter writer; |
51 TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path, | 51 TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path, |
52 O_WRONLY | O_CREAT | O_TRUNC, | 52 O_WRONLY | O_CREAT | O_TRUNC, |
53 0666)); | 53 0600)); |
54 ScopedFileWriterCloser closer(&writer); | 54 ScopedFileWriterCloser closer(&writer); |
55 TEST_AND_RETURN_FALSE_ERRNO(data_len == writer.Write(data, data_len)); | 55 TEST_AND_RETURN_FALSE_ERRNO(data_len == writer.Write(data, data_len)); |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 bool WriteAll(int fd, const void* buf, size_t count) { | 59 bool WriteAll(int fd, const void* buf, size_t count) { |
60 const char* c_buf = static_cast<const char*>(buf); | 60 const char* c_buf = static_cast<const char*>(buf); |
61 ssize_t bytes_written = 0; | 61 ssize_t bytes_written = 0; |
62 while (bytes_written < static_cast<ssize_t>(count)) { | 62 while (bytes_written < static_cast<ssize_t>(count)) { |
63 ssize_t rc = write(fd, c_buf + bytes_written, count - bytes_written); | 63 ssize_t rc = write(fd, c_buf + bytes_written, count - bytes_written); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 int min = value - range / 2; | 454 int min = value - range / 2; |
455 int max = value + range - range / 2; | 455 int max = value + range - range / 2; |
456 return base::RandInt(min, max); | 456 return base::RandInt(min, max); |
457 } | 457 } |
458 | 458 |
459 const char* const kStatefulPartition = "/mnt/stateful_partition"; | 459 const char* const kStatefulPartition = "/mnt/stateful_partition"; |
460 | 460 |
461 } // namespace utils | 461 } // namespace utils |
462 | 462 |
463 } // namespace chromeos_update_engine | 463 } // namespace chromeos_update_engine |
OLD | NEW |