Loading init/builtins.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ static int do_class_reset(const std::vector<std::string>& args) { } static int do_domainname(const std::vector<std::string>& args) { return write_file("/proc/sys/kernel/domainname", args[1].c_str()); return write_file("/proc/sys/kernel/domainname", args[1].c_str()) ? 0 : 1; } static int do_enable(const std::vector<std::string>& args) { Loading Loading @@ -277,7 +277,7 @@ static int do_export(const std::vector<std::string>& args) { } static int do_hostname(const std::vector<std::string>& args) { return write_file("/proc/sys/kernel/hostname", args[1].c_str()); return write_file("/proc/sys/kernel/hostname", args[1].c_str()) ? 0 : 1; } static int do_ifup(const std::vector<std::string>& args) { Loading Loading @@ -814,7 +814,7 @@ static int do_verity_update_state(const std::vector<std::string>& args) { static int do_write(const std::vector<std::string>& args) { const char* path = args[1].c_str(); const char* value = args[2].c_str(); return write_file(path, value); return write_file(path, value) ? 0 : 1; } static int do_copy(const std::vector<std::string>& args) { Loading init/init.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -542,7 +542,7 @@ static void selinux_initialize(bool in_kernel_domain) { } } if (write_file("/sys/fs/selinux/checkreqprot", "0") == -1) { if (!write_file("/sys/fs/selinux/checkreqprot", "0")) { security_failure(); } Loading init/util.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -185,18 +185,18 @@ bool read_file(const char* path, std::string* content) { return okay; } int write_file(const char* path, const char* content) { bool write_file(const char* path, const char* content) { int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0600)); if (fd == -1) { PLOG(ERROR) << "write_file: Unable to open '" << path << "'"; return -1; return false; } int result = android::base::WriteStringToFd(content, fd) ? 0 : -1; if (result == -1) { bool success = android::base::WriteStringToFd(content, fd); if (!success) { PLOG(ERROR) << "write_file: Unable to write to '" << path << "'"; } close(fd); return result; return success; } boot_clock::time_point boot_clock::now() { Loading init/util.h +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid, const char *socketcon); bool read_file(const char* path, std::string* content); int write_file(const char* path, const char* content); bool write_file(const char* path, const char* content); // A std::chrono clock based on CLOCK_BOOTTIME. class boot_clock { Loading Loading
init/builtins.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -249,7 +249,7 @@ static int do_class_reset(const std::vector<std::string>& args) { } static int do_domainname(const std::vector<std::string>& args) { return write_file("/proc/sys/kernel/domainname", args[1].c_str()); return write_file("/proc/sys/kernel/domainname", args[1].c_str()) ? 0 : 1; } static int do_enable(const std::vector<std::string>& args) { Loading Loading @@ -277,7 +277,7 @@ static int do_export(const std::vector<std::string>& args) { } static int do_hostname(const std::vector<std::string>& args) { return write_file("/proc/sys/kernel/hostname", args[1].c_str()); return write_file("/proc/sys/kernel/hostname", args[1].c_str()) ? 0 : 1; } static int do_ifup(const std::vector<std::string>& args) { Loading Loading @@ -814,7 +814,7 @@ static int do_verity_update_state(const std::vector<std::string>& args) { static int do_write(const std::vector<std::string>& args) { const char* path = args[1].c_str(); const char* value = args[2].c_str(); return write_file(path, value); return write_file(path, value) ? 0 : 1; } static int do_copy(const std::vector<std::string>& args) { Loading
init/init.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -542,7 +542,7 @@ static void selinux_initialize(bool in_kernel_domain) { } } if (write_file("/sys/fs/selinux/checkreqprot", "0") == -1) { if (!write_file("/sys/fs/selinux/checkreqprot", "0")) { security_failure(); } Loading
init/util.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -185,18 +185,18 @@ bool read_file(const char* path, std::string* content) { return okay; } int write_file(const char* path, const char* content) { bool write_file(const char* path, const char* content) { int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0600)); if (fd == -1) { PLOG(ERROR) << "write_file: Unable to open '" << path << "'"; return -1; return false; } int result = android::base::WriteStringToFd(content, fd) ? 0 : -1; if (result == -1) { bool success = android::base::WriteStringToFd(content, fd); if (!success) { PLOG(ERROR) << "write_file: Unable to write to '" << path << "'"; } close(fd); return result; return success; } boot_clock::time_point boot_clock::now() { Loading
init/util.h +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid, const char *socketcon); bool read_file(const char* path, std::string* content); int write_file(const char* path, const char* content); bool write_file(const char* path, const char* content); // A std::chrono clock based on CLOCK_BOOTTIME. class boot_clock { Loading