Loading include/utils/file.h +3 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,11 @@ namespace android { bool ReadFdToString(int fd, std::string* content); bool ReadFileToString(const std::string& path, std::string* content); bool WriteStringToFile(const std::string& content, const std::string& path); bool WriteStringToFd(const std::string& content, int fd); #if !defined(_WIN32) bool WriteStringToFile(const std::string& content, const std::string& path, Loading init/Android.mk +48 −24 Original line number Diff line number Diff line # Copyright 2005 The Android Open Source Project LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # -- ifeq ($(strip $(INIT_BOOTCHART)),true) LOCAL_CPPFLAGS += -DBOOTCHART=1 init_options += -DBOOTCHART=1 else LOCAL_CPPFLAGS += -DBOOTCHART=0 init_options += -DBOOTCHART=0 endif ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) LOCAL_CPPFLAGS += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_DISABLE_SELINUX=1 init_options += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_DISABLE_SELINUX=1 else LOCAL_CPPFLAGS += -DALLOW_LOCAL_PROP_OVERRIDE=0 -DALLOW_DISABLE_SELINUX=0 init_options += -DALLOW_LOCAL_PROP_OVERRIDE=0 -DALLOW_DISABLE_SELINUX=0 endif LOCAL_CPPFLAGS += -DLOG_UEVENTS=0 init_options += -DLOG_UEVENTS=0 init_cflags += \ $(init_options) \ -Wall -Wextra \ -Wno-unused-parameter \ -Werror \ # -- include $(CLEAR_VARS) LOCAL_CPPFLAGS := $(init_cflags) LOCAL_SRC_FILES:= \ init_parser.cpp \ parser.cpp \ util.cpp \ LOCAL_MODULE := libinit include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_CPPFLAGS := $(init_cflags) LOCAL_SRC_FILES:= \ bootchart.cpp \ builtins.cpp \ devices.cpp \ init.cpp \ init_parser.cpp \ keychords.cpp \ parser.cpp \ property_service.cpp \ signal_handler.cpp \ ueventd.cpp \ ueventd_parser.cpp \ util.cpp \ watchdogd.cpp \ #LOCAL_CLANG := true LOCAL_CPPFLAGS += \ -Wall -Wextra \ -Werror -Wno-error=deprecated-declarations \ -Wno-unused-parameter \ LOCAL_MODULE:= init LOCAL_FORCE_STATIC_EXECUTABLE := true Loading @@ -50,9 +57,11 @@ LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) LOCAL_STATIC_LIBRARIES := \ libinit \ libfs_mgr \ liblogwrap \ libcutils \ libutils \ liblog \ libc \ libselinux \ Loading @@ -65,3 +74,18 @@ LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \ ln -sf ../init $(TARGET_ROOT_OUT)/sbin/watchdogd include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_MODULE := init_tests LOCAL_SRC_FILES := \ util_test.cpp \ LOCAL_SHARED_LIBRARIES += \ libcutils \ libutils \ LOCAL_STATIC_LIBRARIES := libinit include $(BUILD_NATIVE_TEST) init/builtins.cpp +8 −37 Original line number Diff line number Diff line Loading @@ -56,42 +56,15 @@ int add_environment(const char *name, const char *value); // System call provided by bionic but not in any header file. extern "C" int init_module(void *, unsigned long, const char *); static int write_file(const char *path, const char *value) { int fd, ret, len; fd = open(path, O_WRONLY|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0600); if (fd < 0) return -errno; len = strlen(value); ret = TEMP_FAILURE_RETRY(write(fd, value, len)); close(fd); if (ret < 0) { return -errno; } else { return 0; } } static int insmod(const char *filename, char *options) { void *module; unsigned size; int ret; module = read_file(filename, &size); if (!module) std::string module; if (!read_file(filename, &module)) { return -1; } ret = init_module(module, size, options); free(module); return ret; // TODO: use finit_module for >= 3.8 kernels. return init_module(&module[0], module.size(), options); } static int setkey(struct kbentry *kbe) Loading Loading @@ -743,15 +716,13 @@ int do_write(int nargs, char **args) { const char *path = args[1]; const char *value = args[2]; char prop_val[PROP_VALUE_MAX]; int ret; ret = expand_props(prop_val, value, sizeof(prop_val)); if (ret) { char expanded_value[PROP_VALUE_MAX]; if (expand_props(expanded_value, value, sizeof(expanded_value))) { ERROR("cannot expand '%s' while writing to '%s'\n", value, path); return -EINVAL; } return write_file(path, prop_val); return write_file(path, expanded_value); } int do_copy(int nargs, char **args) Loading init/devices.cpp +2 −9 Original line number Diff line number Diff line Loading @@ -48,8 +48,6 @@ #include "util.h" #include "log.h" #define UNUSED __attribute__((__unused__)) #define SYSFS_PREFIX "/sys" #define FIRMWARE_DIR1 "/etc/firmware" #define FIRMWARE_DIR2 "/vendor/firmware" Loading Loading @@ -231,7 +229,7 @@ static mode_t get_device_perm(const char *path, const char **links, } static void make_device(const char *path, const char *upath UNUSED, const char */*upath*/, int block, int major, int minor, const char **links) { Loading Loading @@ -652,11 +650,6 @@ static void mkdir_recursive_for_devpath(const char *devpath) mkdir_recursive(dir, 0755); } static inline void __attribute__((__deprecated__)) kernel_logger() { INFO("kernel logger is deprecated\n"); } static void handle_generic_device_event(struct uevent *uevent) { const char *base; Loading Loading @@ -743,7 +736,7 @@ static void handle_generic_device_event(struct uevent *uevent) make_dir(base, 0755); } else if(!strncmp(uevent->subsystem, "misc", 4) && !strncmp(name, "log_", 4)) { kernel_logger(); INFO("kernel logger is deprecated\n"); base = "/dev/log/"; make_dir(base, 0755); name += 4; Loading init/init.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -940,7 +940,7 @@ int selinux_reload_policy(void) return 0; } static int audit_callback(void *data, security_class_t cls __attribute__((unused)), char *buf, size_t len) static int audit_callback(void *data, security_class_t /*cls*/, char *buf, size_t len) { snprintf(buf, len, "property=%s", !data ? "NULL" : (char *)data); return 0; Loading Loading @@ -1058,7 +1058,6 @@ int main(int argc, char **argv) INFO("property init\n"); property_load_boot_defaults(); INFO("reading config file\n"); init_parse_config_file("/init.rc"); action_for_each_trigger("early-init", action_add_queue_tail); Loading Loading @@ -1088,7 +1087,6 @@ int main(int argc, char **argv) /* run all property triggers based on current state of the properties */ queue_builtin_action(queue_property_triggers_action, "queue_property_triggers"); if (BOOTCHART) { queue_builtin_action(bootchart_init_action, "bootchart_init"); } Loading Loading
include/utils/file.h +3 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,11 @@ namespace android { bool ReadFdToString(int fd, std::string* content); bool ReadFileToString(const std::string& path, std::string* content); bool WriteStringToFile(const std::string& content, const std::string& path); bool WriteStringToFd(const std::string& content, int fd); #if !defined(_WIN32) bool WriteStringToFile(const std::string& content, const std::string& path, Loading
init/Android.mk +48 −24 Original line number Diff line number Diff line # Copyright 2005 The Android Open Source Project LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # -- ifeq ($(strip $(INIT_BOOTCHART)),true) LOCAL_CPPFLAGS += -DBOOTCHART=1 init_options += -DBOOTCHART=1 else LOCAL_CPPFLAGS += -DBOOTCHART=0 init_options += -DBOOTCHART=0 endif ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) LOCAL_CPPFLAGS += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_DISABLE_SELINUX=1 init_options += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_DISABLE_SELINUX=1 else LOCAL_CPPFLAGS += -DALLOW_LOCAL_PROP_OVERRIDE=0 -DALLOW_DISABLE_SELINUX=0 init_options += -DALLOW_LOCAL_PROP_OVERRIDE=0 -DALLOW_DISABLE_SELINUX=0 endif LOCAL_CPPFLAGS += -DLOG_UEVENTS=0 init_options += -DLOG_UEVENTS=0 init_cflags += \ $(init_options) \ -Wall -Wextra \ -Wno-unused-parameter \ -Werror \ # -- include $(CLEAR_VARS) LOCAL_CPPFLAGS := $(init_cflags) LOCAL_SRC_FILES:= \ init_parser.cpp \ parser.cpp \ util.cpp \ LOCAL_MODULE := libinit include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_CPPFLAGS := $(init_cflags) LOCAL_SRC_FILES:= \ bootchart.cpp \ builtins.cpp \ devices.cpp \ init.cpp \ init_parser.cpp \ keychords.cpp \ parser.cpp \ property_service.cpp \ signal_handler.cpp \ ueventd.cpp \ ueventd_parser.cpp \ util.cpp \ watchdogd.cpp \ #LOCAL_CLANG := true LOCAL_CPPFLAGS += \ -Wall -Wextra \ -Werror -Wno-error=deprecated-declarations \ -Wno-unused-parameter \ LOCAL_MODULE:= init LOCAL_FORCE_STATIC_EXECUTABLE := true Loading @@ -50,9 +57,11 @@ LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) LOCAL_STATIC_LIBRARIES := \ libinit \ libfs_mgr \ liblogwrap \ libcutils \ libutils \ liblog \ libc \ libselinux \ Loading @@ -65,3 +74,18 @@ LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \ ln -sf ../init $(TARGET_ROOT_OUT)/sbin/watchdogd include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_MODULE := init_tests LOCAL_SRC_FILES := \ util_test.cpp \ LOCAL_SHARED_LIBRARIES += \ libcutils \ libutils \ LOCAL_STATIC_LIBRARIES := libinit include $(BUILD_NATIVE_TEST)
init/builtins.cpp +8 −37 Original line number Diff line number Diff line Loading @@ -56,42 +56,15 @@ int add_environment(const char *name, const char *value); // System call provided by bionic but not in any header file. extern "C" int init_module(void *, unsigned long, const char *); static int write_file(const char *path, const char *value) { int fd, ret, len; fd = open(path, O_WRONLY|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0600); if (fd < 0) return -errno; len = strlen(value); ret = TEMP_FAILURE_RETRY(write(fd, value, len)); close(fd); if (ret < 0) { return -errno; } else { return 0; } } static int insmod(const char *filename, char *options) { void *module; unsigned size; int ret; module = read_file(filename, &size); if (!module) std::string module; if (!read_file(filename, &module)) { return -1; } ret = init_module(module, size, options); free(module); return ret; // TODO: use finit_module for >= 3.8 kernels. return init_module(&module[0], module.size(), options); } static int setkey(struct kbentry *kbe) Loading Loading @@ -743,15 +716,13 @@ int do_write(int nargs, char **args) { const char *path = args[1]; const char *value = args[2]; char prop_val[PROP_VALUE_MAX]; int ret; ret = expand_props(prop_val, value, sizeof(prop_val)); if (ret) { char expanded_value[PROP_VALUE_MAX]; if (expand_props(expanded_value, value, sizeof(expanded_value))) { ERROR("cannot expand '%s' while writing to '%s'\n", value, path); return -EINVAL; } return write_file(path, prop_val); return write_file(path, expanded_value); } int do_copy(int nargs, char **args) Loading
init/devices.cpp +2 −9 Original line number Diff line number Diff line Loading @@ -48,8 +48,6 @@ #include "util.h" #include "log.h" #define UNUSED __attribute__((__unused__)) #define SYSFS_PREFIX "/sys" #define FIRMWARE_DIR1 "/etc/firmware" #define FIRMWARE_DIR2 "/vendor/firmware" Loading Loading @@ -231,7 +229,7 @@ static mode_t get_device_perm(const char *path, const char **links, } static void make_device(const char *path, const char *upath UNUSED, const char */*upath*/, int block, int major, int minor, const char **links) { Loading Loading @@ -652,11 +650,6 @@ static void mkdir_recursive_for_devpath(const char *devpath) mkdir_recursive(dir, 0755); } static inline void __attribute__((__deprecated__)) kernel_logger() { INFO("kernel logger is deprecated\n"); } static void handle_generic_device_event(struct uevent *uevent) { const char *base; Loading Loading @@ -743,7 +736,7 @@ static void handle_generic_device_event(struct uevent *uevent) make_dir(base, 0755); } else if(!strncmp(uevent->subsystem, "misc", 4) && !strncmp(name, "log_", 4)) { kernel_logger(); INFO("kernel logger is deprecated\n"); base = "/dev/log/"; make_dir(base, 0755); name += 4; Loading
init/init.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -940,7 +940,7 @@ int selinux_reload_policy(void) return 0; } static int audit_callback(void *data, security_class_t cls __attribute__((unused)), char *buf, size_t len) static int audit_callback(void *data, security_class_t /*cls*/, char *buf, size_t len) { snprintf(buf, len, "property=%s", !data ? "NULL" : (char *)data); return 0; Loading Loading @@ -1058,7 +1058,6 @@ int main(int argc, char **argv) INFO("property init\n"); property_load_boot_defaults(); INFO("reading config file\n"); init_parse_config_file("/init.rc"); action_for_each_trigger("early-init", action_add_queue_tail); Loading Loading @@ -1088,7 +1087,6 @@ int main(int argc, char **argv) /* run all property triggers based on current state of the properties */ queue_builtin_action(queue_property_triggers_action, "queue_property_triggers"); if (BOOTCHART) { queue_builtin_action(bootchart_init_action, "bootchart_init"); } Loading