diff options
Diffstat (limited to 'init/util.cpp')
-rw-r--r-- | init/util.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/init/util.cpp b/init/util.cpp index 3b49b30..332aa2a 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -179,9 +179,13 @@ bool read_file(const char* path, std::string* content) { int 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) { - return -errno; + NOTICE("write_file: Unable to open '%s': %s\n", path, strerror(errno)); + return -1; + } + int result = android::base::WriteStringToFd(content, fd) ? 0 : -1; + if (result == -1) { + NOTICE("write_file: Unable to write to '%s': %s\n", path, strerror(errno)); } - int result = android::base::WriteStringToFd(content, fd) ? 0 : -errno; TEMP_FAILURE_RETRY(close(fd)); return result; } |