Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3553ae73 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "init: Make 'write_file' return bool to match 'read_file'."

parents f37948d6 77f0e9fd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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) {
@@ -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) {
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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();
        }

+5 −5
Original line number Diff line number Diff line
@@ -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() {
+1 −1
Original line number Diff line number Diff line
@@ -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 {