diff options
author | Elliott Hughes <enh@google.com> | 2016-06-24 15:12:21 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2016-06-27 08:11:31 -0700 |
commit | f86b5a6b90619e02d1d034ef7b0adc3b439f4abb (patch) | |
tree | 1348657947a4a875d740dc1df134ae9150ef53d6 /init/builtins.cpp | |
parent | 90db709a2fbccefcee82e54289cd517cd8cb99b5 (diff) |
Move init to libbase logging.
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 452e3332e..d64c3d265 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -71,12 +71,12 @@ static const int kTerminateServiceDelayMicroSeconds = 50000; static int insmod(const char *filename, const char *options, int flags) { int fd = open(filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC); if (fd == -1) { - ERROR("insmod: open(\"%s\") failed: %s", filename, strerror(errno)); + PLOG(ERROR) << "insmod: open(\"" << filename << "\") failed"; return -1; } int rc = syscall(__NR_finit_module, fd, options, flags); if (rc == -1) { - ERROR("finit_module for \"%s\" failed: %s", filename, strerror(errno)); + PLOG(ERROR) << "finit_module for \"" << filename << "\" failed"; } close(fd); return rc; @@ -201,13 +201,13 @@ static void unmount_and_fsck(const struct mntent *entry) { const char *f2fs_argv[] = { "/system/bin/fsck.f2fs", "-f", entry->mnt_fsname, }; - android_fork_execvp_ext(ARRAY_SIZE(f2fs_argv), (char **)f2fs_argv, + android_fork_execvp_ext(arraysize(f2fs_argv), (char **)f2fs_argv, &st, true, LOG_KLOG, true, NULL, NULL, 0); } else if (!strcmp(entry->mnt_type, "ext4")) { const char *ext4_argv[] = { "/system/bin/e2fsck", "-f", "-y", entry->mnt_fsname, }; - android_fork_execvp_ext(ARRAY_SIZE(ext4_argv), (char **)ext4_argv, + android_fork_execvp_ext(arraysize(ext4_argv), (char **)ext4_argv, &st, true, LOG_KLOG, true, NULL, NULL, 0); } } @@ -421,7 +421,7 @@ static int do_mount(const std::vector<std::string>& args) { } close(fd); - ERROR("out of loopback devices"); + LOG(ERROR) << "out of loopback devices"; return -1; } else { if (wait) @@ -445,7 +445,7 @@ static int wipe_data_via_recovery() { write(fd, "--reason=wipe_data_via_recovery\n", strlen("--reason=wipe_data_via_recovery\n") + 1); close(fd); } else { - ERROR("could not open /cache/recovery/command\n"); + PLOG(ERROR) << "could not open /cache/recovery/command"; return -1; } android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); @@ -499,9 +499,9 @@ static int do_mount_all(const std::vector<std::string>& args) { if (pid > 0) { /* Parent. Wait for the child to return */ int wp_ret = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); - if (wp_ret < 0) { - /* Unexpected error code. We will continue anyway. */ - NOTICE("waitpid failed rc=%d: %s\n", wp_ret, strerror(errno)); + if (wp_ret == -1) { + // Unexpected error code. We will continue anyway. + PLOG(WARNING) << "waitpid failed"; } if (WIFEXITED(status)) { @@ -516,7 +516,7 @@ static int do_mount_all(const std::vector<std::string>& args) { child_ret = fs_mgr_mount_all(fstab); fs_mgr_free_fstab(fstab); if (child_ret == -1) { - ERROR("fs_mgr_mount_all returned an error\n"); + PLOG(ERROR) << "fs_mgr_mount_all returned an error"; } _exit(child_ret); } else { @@ -541,7 +541,7 @@ static int do_mount_all(const std::vector<std::string>& args) { ActionManager::GetInstance().QueueEventTrigger("nonencrypted"); } else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) { /* Setup a wipe via recovery, and reboot into recovery */ - ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n"); + PLOG(ERROR) << "fs_mgr_mount_all suggested recovery, so wiping data via recovery."; ret = wipe_data_via_recovery(); /* If reboot worked, there is no return. */ } else if (ret == FS_MGR_MNTALL_DEV_DEFAULT_FILE_ENCRYPTED) { @@ -562,7 +562,7 @@ static int do_mount_all(const std::vector<std::string>& args) { property_set("ro.crypto.type", "file"); property_set("vold.decrypt", "trigger_restart_min_framework"); } else if (ret > 0) { - ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret); + PLOG(ERROR) << "fs_mgr_mount_all returned unexpected error " << ret; } /* else ... < 0: error */ @@ -599,7 +599,7 @@ static int do_setrlimit(const std::vector<std::string>& args) { static int do_start(const std::vector<std::string>& args) { Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]); if (!svc) { - ERROR("do_start: Service %s not found\n", args[1].c_str()); + LOG(ERROR) << "do_start: Service " << args[1] << " not found"; return -1; } if (!svc->Start()) @@ -610,7 +610,7 @@ static int do_start(const std::vector<std::string>& args) { static int do_stop(const std::vector<std::string>& args) { Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]); if (!svc) { - ERROR("do_stop: Service %s not found\n", args[1].c_str()); + LOG(ERROR) << "do_stop: Service " << args[1] << " not found"; return -1; } svc->Stop(); @@ -620,7 +620,7 @@ static int do_stop(const std::vector<std::string>& args) { static int do_restart(const std::vector<std::string>& args) { Service* svc = ServiceManager::GetInstance().FindServiceByName(args[1]); if (!svc) { - ERROR("do_restart: Service %s not found\n", args[1].c_str()); + LOG(ERROR) << "do_restart: Service " << args[1] << " not found"; return -1; } svc->Restart(); @@ -641,7 +641,7 @@ static int do_powerctl(const std::vector<std::string>& args) { cmd = ANDROID_RB_RESTART2; len = 6; } else { - ERROR("powerctl: unrecognized command '%s'\n", command); + LOG(ERROR) << "powerctl: unrecognized command '" << command << "'"; return -EINVAL; } @@ -655,7 +655,7 @@ static int do_powerctl(const std::vector<std::string>& args) { reboot_target = &command[len + 1]; } } else if (command[len] != '\0') { - ERROR("powerctl: unrecognized reboot target '%s'\n", &command[len]); + LOG(ERROR) << "powerctl: unrecognized reboot target '" << &command[len] << "'"; return -EINVAL; } @@ -692,7 +692,7 @@ static int do_powerctl(const std::vector<std::string>& args) { // Wait a bit before recounting the number or running services. usleep(kTerminateServiceDelayMicroSeconds); } - NOTICE("Terminating running services took %.02f seconds", t.duration()); + LOG(VERBOSE) << "Terminating running services took " << t.duration() << " seconds"; } return android_reboot_with_callback(cmd, 0, reboot_target, @@ -868,7 +868,7 @@ static int do_restorecon_recursive(const std::vector<std::string>& args) { static int do_loglevel(const std::vector<std::string>& args) { int log_level = std::stoi(args[1]); if (log_level < KLOG_ERROR_LEVEL || log_level > KLOG_DEBUG_LEVEL) { - ERROR("loglevel: invalid log level'%d'\n", log_level); + LOG(ERROR) << "loglevel: invalid log level " << log_level; return -EINVAL; } klog_set_level(log_level); |