Merge "Revert "Make init re-exec itself for its SELinux domain transition.""
diff --git a/liblog/log_is_loggable.c b/liblog/log_is_loggable.c
index df67123..2e09192 100644
--- a/liblog/log_is_loggable.c
+++ b/liblog/log_is_loggable.c
@@ -28,7 +28,7 @@
return def;
}
{
- static const char log_namespace[] = "log.tag.";
+ static const char log_namespace[] = "persist.log.tag.";
char key[sizeof(log_namespace) + strlen(tag)];
strcpy(key, log_namespace);
@@ -37,6 +37,9 @@
if (__system_property_get(key + 8, buf) <= 0) {
buf[0] = '\0';
}
+ if (!buf[0] && __system_property_get(key, buf) <= 0) {
+ buf[0] = '\0';
+ }
}
switch (toupper(buf[0])) {
case 'V': return ANDROID_LOG_VERBOSE;
@@ -53,17 +56,6 @@
int __android_log_is_loggable(int prio, const char *tag, int def)
{
- static char user;
- int logLevel;
-
- if (user == 0) {
- char buf[PROP_VALUE_MAX];
- if (__system_property_get("ro.build.type", buf) <= 0) {
- buf[0] = '\0';
- }
- user = strcmp(buf, "user") ? -1 : 1;
- }
-
- logLevel = (user == 1) ? def : __android_log_level(tag, def);
+ int logLevel = __android_log_level(tag, def);
return logLevel >= 0 && prio >= logLevel;
}
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 1859461..1dced11 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -247,7 +247,7 @@
uint64_t getKey() { return value; }
};
-struct LogBufferElementEntry {
+class LogBufferElementEntry {
const uint64_t key;
LogBufferElement *last;
@@ -259,8 +259,9 @@
LogBufferElement *getLast() { return last; }
};
-struct LogBufferElementLast : public android::BasicHashtable<uint64_t, LogBufferElementEntry> {
+class LogBufferElementLast : public android::BasicHashtable<uint64_t, LogBufferElementEntry> {
+public:
bool merge(LogBufferElement *e, unsigned short dropped) {
LogBufferElementKey key(e->getUid(), e->getPid(), e->getTid());
android::hash_t hash = android::hash_type(key.getKey());
@@ -286,6 +287,21 @@
add(hash, LogBufferElementEntry(key.getKey(), e));
}
+ inline void clear() {
+ android::BasicHashtable<uint64_t, LogBufferElementEntry>::clear();
+ }
+
+ void clear(LogBufferElement *e) {
+ uint64_t current = e->getRealTime().nsec() - NS_PER_SEC;
+ ssize_t index = -1;
+ while((index = next(index)) >= 0) {
+ if (current > editEntryAt(index).getLast()->getRealTime().nsec()) {
+ removeAt(index);
+ index = -1;
+ }
+ }
+ }
+
};
// prune "pruneRows" of type "id" from the buffer.
@@ -349,9 +365,16 @@
if (sorted.get()) {
if (sorted[0] && sorted[1]) {
- worst = sorted[0]->getKey();
worst_sizes = sorted[0]->getSizes();
- second_worst_sizes = sorted[1]->getSizes();
+ // Calculate threshold as 12.5% of available storage
+ size_t threshold = log_buffer_size(id) / 8;
+ if (worst_sizes > threshold) {
+ worst = sorted[0]->getKey();
+ second_worst_sizes = sorted[1]->getSizes();
+ if (second_worst_sizes < threshold) {
+ second_worst_sizes = threshold;
+ }
+ }
}
}
}
@@ -395,7 +418,7 @@
leading = false;
if (hasBlacklist && mPrune.naughty(e)) {
- last.clear();
+ last.clear(e);
it = erase(it);
if (dropped) {
continue;
@@ -423,7 +446,7 @@
}
if (e->getUid() != worst) {
- last.clear();
+ last.clear(e);
++it;
continue;
}
diff --git a/rootdir/etc/mountd.conf b/rootdir/etc/mountd.conf
deleted file mode 100644
index 094a2c7..0000000
--- a/rootdir/etc/mountd.conf
+++ /dev/null
@@ -1,19 +0,0 @@
-## mountd configuration file
-
-## add a mount entry for each mount point to be managed by mountd
-mount {
- ## root block device with partition map or raw FAT file system
- block_device /dev/block/mmcblk0
-
- ## mount point for block device
- mount_point /sdcard
-
- ## true if this mount point can be shared via USB mass storage
- enable_ums true
-
- ## path to the UMS driver file for specifying the block device path
- ## use this for the mass_storage function driver
- driver_store_path /sys/devices/platform/usb_mass_storage/lun0/file
- ## use this for android_usb composite gadget driver
- ##driver_store_path /sys/devices/platform/msm_hsusb/gadget/lun0/file
-}
diff --git a/rootdir/init.rc b/rootdir/init.rc
index a5ea60a..d3c562f 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -162,6 +162,7 @@
# Load properties from /system/ + /factory after fs mount.
on load_all_props_action
load_all_props
+ start logd
start logd-reinit
# Indicate to fw loaders that the relevant mounts are up.
@@ -445,6 +446,7 @@
on property:vold.decrypt=trigger_load_persist_props
load_persist_props
+ start logd
start logd-reinit
on property:vold.decrypt=trigger_post_fs_data
@@ -490,7 +492,6 @@
socket logdw dgram 0222 logd logd
service logd-reinit /system/bin/logd --reinit
- start logd
oneshot
disabled
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 041c37a..893c0dc 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -1875,7 +1875,7 @@
struct fuse fuse;
/* cleanup from previous instance, if necessary */
- umount2(dest_path, 2);
+ umount2(dest_path, MNT_DETACH);
fd = open("/dev/fuse", O_RDWR);
if (fd < 0){