Merge "Switch run-as to libpackagelistparser."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 3cad427..31e60ca 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -58,3 +58,4 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/grep $(PRODUCT_OUT)/system/bin/toolbox)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/hw/gatekeeper.$(TARGET_DEVICE).so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/gatekeeper.$(TARGET_DEVICE).so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/vendor)
diff --git a/fs_mgr/fs_mgr_main.c b/fs_mgr/fs_mgr_main.c
index e5a00d5..b3f131e 100644
--- a/fs_mgr/fs_mgr_main.c
+++ b/fs_mgr/fs_mgr_main.c
@@ -85,7 +85,6 @@
char *fstab_file=NULL;
struct fstab *fstab=NULL;
- klog_init();
klog_set_level(6);
parse_options(argc, argv, &a_flag, &u_flag, &n_flag, &n_name, &n_blk_dev);
@@ -111,4 +110,3 @@
/* Should not get here */
exit(1);
}
-
diff --git a/include/cutils/klog.h b/include/cutils/klog.h
index 295d62b..2078fa2 100644
--- a/include/cutils/klog.h
+++ b/include/cutils/klog.h
@@ -26,7 +26,6 @@
void klog_init(void);
int klog_get_level(void);
void klog_set_level(int level);
-/* TODO: void klog_close(void); - and make klog_fd users thread safe. */
void klog_write(int level, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3)));
diff --git a/include/log/logprint.h b/include/log/logprint.h
index 539d1dc..1bc1f72 100644
--- a/include/log/logprint.h
+++ b/include/log/logprint.h
@@ -27,6 +27,7 @@
#endif
typedef enum {
+ /* Verbs */
FORMAT_OFF = 0,
FORMAT_BRIEF,
FORMAT_PROCESS,
@@ -36,7 +37,7 @@
FORMAT_TIME,
FORMAT_THREADTIME,
FORMAT_LONG,
- /* The following are modifiers to above formats */
+ /* Adverbs. The following are modifiers to above format verbs */
FORMAT_MODIFIER_COLOR, /* converts priority to color */
FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */
FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index e540de2..5ccd80e 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -92,6 +92,8 @@
#define AID_FIREWALL 1048 /* firewalld process */
#define AID_TRUNKS 1049 /* trunksd process (TPM daemon) */
#define AID_NVRAM 1050 /* Access-controlled NVRAM */
+#define AID_DNS 1051 /* DNS resolution daemon (system: netd) */
+#define AID_DNS_TETHER 1052 /* DNS resolution daemon (tether: dnsmasq) */
/* Changes to this file must be made in AOSP, *not* in internal branches. */
#define AID_SHELL 2000 /* adb and debug shell user */
@@ -203,6 +205,8 @@
{ "firewall", AID_FIREWALL, },
{ "trunks", AID_TRUNKS, },
{ "nvram", AID_NVRAM, },
+ { "dns", AID_DNS, },
+ { "dns_tether", AID_DNS_TETHER, },
{ "shell", AID_SHELL, },
{ "cache", AID_CACHE, },
diff --git a/init/init.cpp b/init/init.cpp
index 1495c68..fe2aee4 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -477,7 +477,6 @@
// kmsg and null, otherwise we won't be able to remount / read-only
// later on. Now that tmpfs is mounted on /dev, we can actually talk
// to the outside world.
- open_devnull_stdio();
InitKernelLogging(argv);
LOG(INFO) << "init " << (is_first_stage ? "first stage" : "second stage") << " started!";
diff --git a/init/log.cpp b/init/log.cpp
index ee75ffc..3934ca0 100644
--- a/init/log.cpp
+++ b/init/log.cpp
@@ -16,8 +16,11 @@
#include "log.h"
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/uio.h>
#include <selinux/selinux.h>
@@ -51,9 +54,20 @@
}
void InitKernelLogging(char* argv[]) {
- android::base::InitLogging(argv, &KernelLogger);
+ // Make stdin/stdout/stderr all point to /dev/null.
+ int fd = open("/sys/fs/selinux/null", O_RDWR);
+ if (fd == -1) {
+ int saved_errno = errno;
+ android::base::InitLogging(argv, &KernelLogger);
+ errno = saved_errno;
+ PLOG(FATAL) << "Couldn't open /sys/fs/selinux/null";
+ }
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ if (fd > 2) close(fd);
- klog_init();
+ android::base::InitLogging(argv, &KernelLogger);
klog_set_level(KLOG_NOTICE_LEVEL);
}
diff --git a/init/readme.txt b/init/readme.txt
index 27c5e67..7260775 100644
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -515,5 +515,5 @@
emulator -partition-size 1024 -verbose -show-kernel -no-window
-You might want to call klog_set_level(6) after the klog_init() call
-so you see the kernel logging in dmesg (or the emulator output).
+You might want to change the klog_set_level call so you see all the kernel
+logging in dmesg (or the emulator output).
diff --git a/init/service.cpp b/init/service.cpp
index 03c0064..c636677 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -52,6 +52,43 @@
#define CRITICAL_CRASH_THRESHOLD 4 // if we crash >4 times ...
#define CRITICAL_CRASH_WINDOW (4*60) // ... in 4 minutes, goto recovery
+static std::string ComputeContextFromExecutable(std::string& service_name,
+ const std::string& service_path) {
+ std::string computed_context;
+
+ char* raw_con = nullptr;
+ char* raw_filecon = nullptr;
+
+ if (getcon(&raw_con) == -1) {
+ LOG(ERROR) << "could not get context while starting '" << service_name << "'";
+ return "";
+ }
+ std::unique_ptr<char> mycon(raw_con);
+
+ if (getfilecon(service_path.c_str(), &raw_filecon) == -1) {
+ LOG(ERROR) << "could not get file context while starting '" << service_name << "'";
+ return "";
+ }
+ std::unique_ptr<char> filecon(raw_filecon);
+
+ char* new_con = nullptr;
+ int rc = security_compute_create(mycon.get(), filecon.get(),
+ string_to_security_class("process"), &new_con);
+ if (rc == 0) {
+ computed_context = new_con;
+ free(new_con);
+ }
+ if (rc == 0 && computed_context == mycon.get()) {
+ LOG(ERROR) << "service " << service_name << " does not have a SELinux domain defined";
+ return "";
+ }
+ if (rc < 0) {
+ LOG(ERROR) << "could not get context while starting '" << service_name << "'";
+ return "";
+ }
+ return computed_context;
+}
+
static void SetUpPidNamespace(const std::string& service_name) {
constexpr unsigned int kSafeFlags = MS_NODEV | MS_NOEXEC | MS_NOSUID;
@@ -92,6 +129,19 @@
}
}
+static void ExpandArgs(const std::vector<std::string>& args, std::vector<char*>* strs) {
+ std::vector<std::string> expanded_args;
+ expanded_args.resize(args.size());
+ strs->push_back(const_cast<char*>(args[0].c_str()));
+ for (std::size_t i = 1; i < args.size(); ++i) {
+ if (!expand_props(args[i], &expanded_args[i])) {
+ LOG(FATAL) << args[0] << ": cannot expand '" << args[i] << "'";
+ }
+ strs->push_back(const_cast<char*>(expanded_args[i].c_str()));
+ }
+ strs->push_back(nullptr);
+}
+
SocketInfo::SocketInfo() : uid(0), gid(0), perm(0) {
}
@@ -154,6 +204,50 @@
killProcessGroup(uid_, pid_, signal);
}
+void Service::CreateSockets(const std::string& context) {
+ for (const auto& si : sockets_) {
+ int socket_type = ((si.type == "stream" ? SOCK_STREAM :
+ (si.type == "dgram" ? SOCK_DGRAM :
+ SOCK_SEQPACKET)));
+ const char* socketcon = !si.socketcon.empty() ? si.socketcon.c_str() : context.c_str();
+
+ int s = create_socket(si.name.c_str(), socket_type, si.perm, si.uid, si.gid, socketcon);
+ if (s >= 0) {
+ PublishSocket(si.name, s);
+ }
+ }
+}
+
+void Service::SetProcessAttributes() {
+ setpgid(0, getpid());
+
+ if (gid_) {
+ if (setgid(gid_) != 0) {
+ PLOG(FATAL) << "setgid failed";
+ }
+ }
+ if (!supp_gids_.empty()) {
+ if (setgroups(supp_gids_.size(), &supp_gids_[0]) != 0) {
+ PLOG(FATAL) << "setgroups failed";
+ }
+ }
+ if (uid_) {
+ if (setuid(uid_) != 0) {
+ PLOG(FATAL) << "setuid failed";
+ }
+ }
+ if (!seclabel_.empty()) {
+ if (setexeccon(seclabel_.c_str()) < 0) {
+ PLOG(FATAL) << "cannot setexeccon('" << seclabel_ << "')";
+ }
+ }
+ if (priority_ != 0) {
+ if (setpriority(PRIO_PROCESS, 0, priority_) != 0) {
+ PLOG(FATAL) << "setpriority failed";
+ }
+ }
+}
+
bool Service::Reap() {
if (!(flags_ & SVC_ONESHOT) || (flags_ & SVC_RESTART)) {
KillProcessGroup(SIGKILL);
@@ -441,50 +535,18 @@
if (!seclabel_.empty()) {
scon = seclabel_;
} else {
- char* mycon = nullptr;
- char* fcon = nullptr;
-
- LOG(INFO) << "computing context for service '" << args_[0] << "'";
- int rc = getcon(&mycon);
- if (rc < 0) {
- LOG(ERROR) << "could not get context while starting '" << name_ << "'";
- return false;
- }
-
- rc = getfilecon(args_[0].c_str(), &fcon);
- if (rc < 0) {
- LOG(ERROR) << "could not get file context while starting '" << name_ << "'";
- free(mycon);
- return false;
- }
-
- char* ret_scon = nullptr;
- rc = security_compute_create(mycon, fcon, string_to_security_class("process"),
- &ret_scon);
- if (rc == 0) {
- scon = ret_scon;
- free(ret_scon);
- }
- if (rc == 0 && scon == mycon) {
- LOG(ERROR) << "Service " << name_ << " does not have a SELinux domain defined.";
- free(mycon);
- free(fcon);
- return false;
- }
- free(mycon);
- free(fcon);
- if (rc < 0) {
- LOG(ERROR) << "could not get context while starting '" << name_ << "'";
+ LOG(INFO) << "computing context for service '" << name_ << "'";
+ scon = ComputeContextFromExecutable(name_, args_[0]);
+ if (scon == "") {
return false;
}
}
- LOG(VERBOSE) << "Starting service '" << name_ << "'...";
+ LOG(VERBOSE) << "starting service '" << name_ << "'...";
pid_t pid = -1;
if (namespace_flags_) {
- pid = clone(nullptr, nullptr, namespace_flags_ | SIGCHLD,
- nullptr);
+ pid = clone(nullptr, nullptr, namespace_flags_ | SIGCHLD, nullptr);
} else {
pid = fork();
}
@@ -502,19 +564,7 @@
add_environment(ei.name.c_str(), ei.value.c_str());
}
- for (const auto& si : sockets_) {
- int socket_type = ((si.type == "stream" ? SOCK_STREAM :
- (si.type == "dgram" ? SOCK_DGRAM :
- SOCK_SEQPACKET)));
- const char* socketcon =
- !si.socketcon.empty() ? si.socketcon.c_str() : scon.c_str();
-
- int s = create_socket(si.name.c_str(), socket_type, si.perm,
- si.uid, si.gid, socketcon);
- if (s >= 0) {
- PublishSocket(si.name, s);
- }
- }
+ CreateSockets(scon);
std::string pid_str = StringPrintf("%d", getpid());
for (const auto& file : writepid_files_) {
@@ -525,7 +575,7 @@
if (ioprio_class_ != IoSchedClass_NONE) {
if (android_set_ioprio(getpid(), ioprio_class_, ioprio_pri_)) {
- PLOG(ERROR) << "Failed to set pid " << getpid()
+ PLOG(ERROR) << "failed to set pid " << getpid()
<< " ioprio=" << ioprio_class_ << "," << ioprio_pri_;
}
}
@@ -537,53 +587,12 @@
ZapStdio();
}
- setpgid(0, getpid());
+ // As requested, set our gid, supplemental gids, uid, context, and
+ // priority. Aborts on failure.
+ SetProcessAttributes();
- // As requested, set our gid, supplemental gids, and uid.
- if (gid_) {
- if (setgid(gid_) != 0) {
- PLOG(ERROR) << "setgid failed";
- _exit(127);
- }
- }
- if (!supp_gids_.empty()) {
- if (setgroups(supp_gids_.size(), &supp_gids_[0]) != 0) {
- PLOG(ERROR) << "setgroups failed";
- _exit(127);
- }
- }
- if (uid_) {
- if (setuid(uid_) != 0) {
- PLOG(ERROR) << "setuid failed";
- _exit(127);
- }
- }
- if (!seclabel_.empty()) {
- if (setexeccon(seclabel_.c_str()) < 0) {
- PLOG(ERROR) << "cannot setexeccon('" << seclabel_ << "')";
- _exit(127);
- }
- }
- if (priority_ != 0) {
- if (setpriority(PRIO_PROCESS, 0, priority_) != 0) {
- PLOG(ERROR) << "setpriority failed";
- _exit(127);
- }
- }
-
- std::vector<std::string> expanded_args;
std::vector<char*> strs;
- expanded_args.resize(args_.size());
- strs.push_back(const_cast<char*>(args_[0].c_str()));
- for (std::size_t i = 1; i < args_.size(); ++i) {
- if (!expand_props(args_[i], &expanded_args[i])) {
- LOG(ERROR) << args_[0] << ": cannot expand '" << args_[i] << "'";
- _exit(127);
- }
- strs.push_back(const_cast<char*>(expanded_args[i].c_str()));
- }
- strs.push_back(nullptr);
-
+ ExpandArgs(args_, &strs);
if (execve(strs[0], (char**) &strs[0], (char**) ENV) < 0) {
PLOG(ERROR) << "cannot execve('" << strs[0] << "')";
}
@@ -603,13 +612,14 @@
errno = -createProcessGroup(uid_, pid_);
if (errno != 0) {
- PLOG(ERROR) << "createProcessGroup(" << uid_ << ", " << pid_ << ") failed for service '" << name_ << "'";
+ PLOG(ERROR) << "createProcessGroup(" << uid_ << ", " << pid_ << ") failed for service '"
+ << name_ << "'";
}
if ((flags_ & SVC_EXEC) != 0) {
- LOG(INFO) << android::base::StringPrintf("SVC_EXEC pid %d (uid %d gid %d+%zu context %s) started; waiting...",
- pid_, uid_, gid_, supp_gids_.size(),
- !seclabel_.empty() ? seclabel_.c_str() : "default");
+ LOG(INFO) << android::base::StringPrintf(
+ "SVC_EXEC pid %d (uid %d gid %d+%zu context %s) started; waiting...", pid_, uid_, gid_,
+ supp_gids_.size(), !seclabel_.empty() ? seclabel_.c_str() : "default");
}
NotifyStateChange("running");
diff --git a/init/service.h b/init/service.h
index 38c5d64..aa73aaf 100644
--- a/init/service.h
+++ b/init/service.h
@@ -113,6 +113,8 @@
void OpenConsole() const;
void PublishSocket(const std::string& name, int fd) const;
void KillProcessGroup(int signal);
+ void CreateSockets(const std::string& scon);
+ void SetProcessAttributes();
bool ParseClass(const std::vector<std::string>& args, std::string* err);
bool ParseConsole(const std::vector<std::string>& args, std::string* err);
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 91f8b1a..e7794ec 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -52,7 +52,6 @@
*/
signal(SIGCHLD, SIG_IGN);
- open_devnull_stdio();
InitKernelLogging(argv);
LOG(INFO) << "ueventd started!";
diff --git a/init/util.cpp b/init/util.cpp
index 6315a7a..6c1923f 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -316,30 +316,6 @@
return ret;
}
-void open_devnull_stdio(void)
-{
- int fd = open("/sys/fs/selinux/null", O_RDWR);
- if (fd == -1) {
- /* Fail silently.
- * stdout/stderr isn't available, and because
- * klog_init() is called after open_devnull_stdio(), we can't
- * log to dmesg. Reordering klog_init() to be called before
- * open_devnull_stdio() isn't an option either, as then klog_fd
- * will be assigned 0 or 1, which will end up getting clobbered
- * by the code below. There's nowhere good to log.
- */
-
- exit(1);
- }
-
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
- if (fd > 2) {
- close(fd);
- }
-}
-
void import_kernel_cmdline(bool in_qemu,
std::function<void(const std::string&, const std::string&, bool)> fn) {
std::string cmdline;
diff --git a/init/util.h b/init/util.h
index 45207eb..9d522cc 100644
--- a/init/util.h
+++ b/init/util.h
@@ -54,7 +54,6 @@
void make_link_init(const char *oldpath, const char *newpath);
void remove_link(const char *oldpath, const char *newpath);
int wait_for_file(const char *filename, int timeout);
-void open_devnull_stdio(void);
void import_kernel_cmdline(bool in_qemu,
std::function<void(const std::string&, const std::string&, bool)>);
int make_dir(const char *path, mode_t mode);
diff --git a/init/watchdogd.cpp b/init/watchdogd.cpp
index 3a3d810..b196147 100644
--- a/init/watchdogd.cpp
+++ b/init/watchdogd.cpp
@@ -28,7 +28,6 @@
#define DEV_NAME "/dev/watchdog"
int watchdogd_main(int argc, char **argv) {
- open_devnull_stdio();
InitKernelLogging(argv);
int interval = 10;
diff --git a/libcutils/Android.mk b/libcutils/Android.mk
index e29c9ad..c830182 100644
--- a/libcutils/Android.mk
+++ b/libcutils/Android.mk
@@ -95,7 +95,7 @@
android_reboot.c \
ashmem-dev.c \
debugger.c \
- klog.c \
+ klog.cpp \
partition_utils.c \
properties.c \
qtaguid.c \
diff --git a/libcutils/canned_fs_config.c b/libcutils/canned_fs_config.c
index 5800857..e0e6a34 100644
--- a/libcutils/canned_fs_config.c
+++ b/libcutils/canned_fs_config.c
@@ -14,22 +14,22 @@
* limitations under the License.
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
#include <errno.h>
+#include <inttypes.h>
#include <limits.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <private/android_filesystem_config.h>
#include <private/canned_fs_config.h>
typedef struct {
- const char* path;
- unsigned uid;
- unsigned gid;
- unsigned mode;
- uint64_t capabilities;
+ const char* path;
+ unsigned uid;
+ unsigned gid;
+ unsigned mode;
+ uint64_t capabilities;
} Path;
static Path* canned_data = NULL;
@@ -37,81 +37,87 @@
static int canned_used = 0;
static int path_compare(const void* a, const void* b) {
- return strcmp(((Path*)a)->path, ((Path*)b)->path);
+ return strcmp(((Path*)a)->path, ((Path*)b)->path);
}
int load_canned_fs_config(const char* fn) {
- FILE* f = fopen(fn, "r");
- if (f == NULL) {
- fprintf(stderr, "failed to open %s: %s\n", fn, strerror(errno));
- return -1;
- }
+ char line[PATH_MAX + 200];
+ FILE* f;
- char line[PATH_MAX + 200];
- while (fgets(line, sizeof(line), f)) {
- while (canned_used >= canned_alloc) {
- canned_alloc = (canned_alloc+1) * 2;
- canned_data = (Path*) realloc(canned_data, canned_alloc * sizeof(Path));
- }
- Path* p = canned_data + canned_used;
- p->path = strdup(strtok(line, " "));
- p->uid = atoi(strtok(NULL, " "));
- p->gid = atoi(strtok(NULL, " "));
- p->mode = strtol(strtok(NULL, " "), NULL, 8); // mode is in octal
- p->capabilities = 0;
+ f = fopen(fn, "r");
+ if (f == NULL) {
+ fprintf(stderr, "failed to open %s: %s\n", fn, strerror(errno));
+ return -1;
+ }
- char* token = NULL;
- do {
- token = strtok(NULL, " ");
- if (token && strncmp(token, "capabilities=", 13) == 0) {
- p->capabilities = strtoll(token+13, NULL, 0);
- break;
- }
- } while (token);
+ while (fgets(line, sizeof(line), f)) {
+ Path* p;
+ char* token;
- canned_used++;
- }
+ while (canned_used >= canned_alloc) {
+ canned_alloc = (canned_alloc+1) * 2;
+ canned_data = (Path*) realloc(canned_data, canned_alloc * sizeof(Path));
+ }
+ p = canned_data + canned_used;
+ p->path = strdup(strtok(line, " "));
+ p->uid = atoi(strtok(NULL, " "));
+ p->gid = atoi(strtok(NULL, " "));
+ p->mode = strtol(strtok(NULL, " "), NULL, 8); // mode is in octal
+ p->capabilities = 0;
- fclose(f);
+ do {
+ token = strtok(NULL, " ");
+ if (token && strncmp(token, "capabilities=", 13) == 0) {
+ p->capabilities = strtoll(token+13, NULL, 0);
+ break;
+ }
+ } while (token);
- qsort(canned_data, canned_used, sizeof(Path), path_compare);
- printf("loaded %d fs_config entries\n", canned_used);
+ canned_used++;
+ }
- return 0;
+ fclose(f);
+
+ qsort(canned_data, canned_used, sizeof(Path), path_compare);
+ printf("loaded %d fs_config entries\n", canned_used);
+
+ return 0;
}
static const int kDebugCannedFsConfig = 0;
void canned_fs_config(const char* path, int dir, const char* target_out_path,
- unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) {
- Path key;
+ unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) {
+ Path key, *p;
+
key.path = path;
- if (path[0] == '/')
- key.path++; // canned paths lack the leading '/'
- Path* p = (Path*) bsearch(&key, canned_data, canned_used, sizeof(Path), path_compare);
- if (p == NULL) {
- fprintf(stderr, "failed to find [%s] in canned fs_config\n", path);
- exit(1);
- }
- *uid = p->uid;
- *gid = p->gid;
- *mode = p->mode;
- *capabilities = p->capabilities;
+ if (path[0] == '/') key.path++; // canned paths lack the leading '/'
+ p = (Path*) bsearch(&key, canned_data, canned_used, sizeof(Path), path_compare);
+ if (p == NULL) {
+ fprintf(stderr, "failed to find [%s] in canned fs_config\n", path);
+ exit(1);
+ }
+ *uid = p->uid;
+ *gid = p->gid;
+ *mode = p->mode;
+ *capabilities = p->capabilities;
- if (kDebugCannedFsConfig) {
- // for debugging, run the built-in fs_config and compare the results.
+ if (kDebugCannedFsConfig) {
+ // for debugging, run the built-in fs_config and compare the results.
- unsigned c_uid, c_gid, c_mode;
- uint64_t c_capabilities;
- fs_config(path, dir, target_out_path, &c_uid, &c_gid, &c_mode, &c_capabilities);
+ unsigned c_uid, c_gid, c_mode;
+ uint64_t c_capabilities;
- if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid);
- if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid);
- if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode);
- if (c_capabilities != *capabilities)
- printf("%s capabilities %" PRIx64 " %" PRIx64 "\n",
- path,
- *capabilities,
- c_capabilities);
+ fs_config(path, dir, target_out_path, &c_uid, &c_gid, &c_mode, &c_capabilities);
+
+ if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid);
+ if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid);
+ if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode);
+ if (c_capabilities != *capabilities) {
+ printf("%s capabilities %" PRIx64 " %" PRIx64 "\n",
+ path,
+ *capabilities,
+ c_capabilities);
}
+ }
}
diff --git a/libcutils/klog.c b/libcutils/klog.cpp
similarity index 78%
rename from libcutils/klog.c
rename to libcutils/klog.cpp
index 7402903..11ebf88 100644
--- a/libcutils/klog.c
+++ b/libcutils/klog.cpp
@@ -26,7 +26,6 @@
#include <cutils/klog.h>
-static int klog_fd = -1;
static int klog_level = KLOG_DEFAULT_LEVEL;
int klog_get_level(void) {
@@ -38,31 +37,33 @@
}
void klog_init(void) {
- if (klog_fd >= 0) return; /* Already initialized */
+}
- klog_fd = open("/dev/kmsg", O_WRONLY | O_CLOEXEC);
- if (klog_fd >= 0) {
- return;
+static int __open_klog(void) {
+ int fd = open("/dev/kmsg", O_WRONLY | O_CLOEXEC);
+ if (fd == -1) {
+ static const char* name = "/dev/__kmsg__";
+ if (mknod(name, S_IFCHR | 0600, (1 << 8) | 11) == 0) {
+ fd = open(name, O_WRONLY | O_CLOEXEC);
+ unlink(name);
+ }
}
-
- static const char* name = "/dev/__kmsg__";
- if (mknod(name, S_IFCHR | 0600, (1 << 8) | 11) == 0) {
- klog_fd = open(name, O_WRONLY | O_CLOEXEC);
- unlink(name);
- }
+ return fd;
}
#define LOG_BUF_MAX 512
void klog_writev(int level, const struct iovec* iov, int iov_count) {
if (level > klog_level) return;
- if (klog_fd < 0) klog_init();
- if (klog_fd < 0) return;
+
+ static int klog_fd = __open_klog();
+ if (klog_fd == -1) return;
TEMP_FAILURE_RETRY(writev(klog_fd, iov, iov_count));
}
void klog_write(int level, const char* fmt, ...) {
if (level > klog_level) return;
+
char buf[LOG_BUF_MAX];
va_list ap;
va_start(ap, fmt);
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index ea698c8..5bac717 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -285,9 +285,10 @@
" -n <count>, --rotate-count=<count>\n"
" Sets max number of rotated logs to <count>, default 4\n"
" -v <format>, --format=<format>\n"
- " Sets the log print format, where <format> is:\n"
- " brief color epoch long monotonic printable process raw\n"
- " tag thread threadtime time uid usec UTC year zone\n"
+ " Sets log print format verb and adverbs, where <format> is:\n"
+ " brief long process raw tag thread threadtime time\n"
+ " and individually flagged modifying adverbs can be added:\n"
+ " color epoch monotonic printable uid usec UTC year zone\n"
" -D, --dividers Print dividers between each log buffer\n"
" -c, --clear Clear (flush) the entire log and exit\n"
" if Log to File specified, clear fileset instead\n"
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index d53af2f..e060a2c 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -58,7 +58,7 @@
ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
ln -sf /sys/kernel/debug $(TARGET_ROOT_OUT)/d; \
ln -sf /storage/self/primary $(TARGET_ROOT_OUT)/sdcard
-ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+ifdef BOARD_USES_VENDORIMAGE
LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/vendor
else
LOCAL_POST_INSTALL_CMD += ; ln -sf /system/vendor $(TARGET_ROOT_OUT)/vendor
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index c7b6d4c0..c9e2ddd 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -70,7 +70,7 @@
$(LOCAL_PATH)/getevent.c: $(intermediates)/input.h-labels.h
-UAPI_INPUT_EVENT_CODES_H := bionic/libc/kernel/uapi/linux/input-event-codes.h
+UAPI_INPUT_EVENT_CODES_H := bionic/libc/kernel/uapi/linux/input.h bionic/libc/kernel/uapi/linux/input-event-codes.h
INPUT_H_LABELS_H := $(intermediates)/input.h-labels.h
$(INPUT_H_LABELS_H): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
# The PRIVATE_CUSTOM_TOOL line uses = to evaluate the output path late.
diff --git a/toolbox/generate-input.h-labels.py b/toolbox/generate-input.h-labels.py
index a2b9111..c0e9fce 100755
--- a/toolbox/generate-input.h-labels.py
+++ b/toolbox/generate-input.h-labels.py
@@ -38,39 +38,40 @@
r = re.compile(r'#define\s+(\S+)\s+((?:0x)?\d+)')
-with open(sys.argv[1], 'r') as f:
- for line in f:
- m = r.match(line)
- if m:
- name = m.group(1)
- if name.startswith("INPUT_PROP_"):
- input_prop_list.append(name)
- elif name.startswith("EV_"):
- ev_list.append(name)
- elif name.startswith("SYN_"):
- syn_list.append(name)
- elif name.startswith("KEY_") or name.startswith("BTN_"):
- key_list.append(name)
- elif name.startswith("REL_"):
- rel_list.append(name)
- elif name.startswith("ABS_"):
- abs_list.append(name)
- elif name.startswith("SW_"):
- sw_list.append(name)
- elif name.startswith("MSC_"):
- msc_list.append(name)
- elif name.startswith("LED_"):
- led_list.append(name)
- elif name.startswith("REP_"):
- rep_list.append(name)
- elif name.startswith("SND_"):
- snd_list.append(name)
- elif name.startswith("MT_TOOL_"):
- mt_tool_list.append(name)
- elif name.startswith("FF_STATUS_"):
- ff_status_list.append(name)
- elif name.startswith("FF_"):
- ff_list.append(name)
+for arg in sys.argv[1:]:
+ with open(arg, 'r') as f:
+ for line in f:
+ m = r.match(line)
+ if m:
+ name = m.group(1)
+ if name.startswith("INPUT_PROP_"):
+ input_prop_list.append(name)
+ elif name.startswith("EV_"):
+ ev_list.append(name)
+ elif name.startswith("SYN_"):
+ syn_list.append(name)
+ elif name.startswith("KEY_") or name.startswith("BTN_"):
+ key_list.append(name)
+ elif name.startswith("REL_"):
+ rel_list.append(name)
+ elif name.startswith("ABS_"):
+ abs_list.append(name)
+ elif name.startswith("SW_"):
+ sw_list.append(name)
+ elif name.startswith("MSC_"):
+ msc_list.append(name)
+ elif name.startswith("LED_"):
+ led_list.append(name)
+ elif name.startswith("REP_"):
+ rep_list.append(name)
+ elif name.startswith("SND_"):
+ snd_list.append(name)
+ elif name.startswith("MT_TOOL_"):
+ mt_tool_list.append(name)
+ elif name.startswith("FF_STATUS_"):
+ ff_status_list.append(name)
+ elif name.startswith("FF_"):
+ ff_list.append(name)
def Dump(struct_name, values):
print('static struct label %s[] = {' % (struct_name))