Merge changes from topic "resgidz"
* changes:
Add reserved disk GID to critical component.
Set reserved GID when setting reserved blocks.
Allocate GID to use reserved disk space.
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 34afed1..d913af0 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -654,12 +654,13 @@
}
for (int i = a->num_entries, j = 0; i < total_entries; i++, j++) {
- // copy the pointer directly *without* malloc and memcpy
+ // Copy the structs by assignment.
a->recs[i] = b->recs[j];
}
- // Frees up b, but don't free b->recs[X] to make sure they are
- // accessible through a->recs[X].
+ // We can't call fs_mgr_free_fstab because a->recs still references the
+ // memory allocated by strdup.
+ free(b->recs);
free(b->fstab_filename);
free(b);
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index e9f0c0f..6ddec4d 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -662,22 +662,51 @@
return handle;
}
#else
- UNUSED(env, target_sdk_version, class_loader, library_path);
- *needs_native_bridge = false;
- void* handle = dlopen(path, RTLD_NOW);
- if (handle == nullptr) {
- if (NativeBridgeIsSupported(path)) {
- *needs_native_bridge = true;
- handle = NativeBridgeLoadLibrary(path, RTLD_NOW);
- if (handle == nullptr) {
- *error_msg = NativeBridgeGetError();
- }
+ UNUSED(env, target_sdk_version, class_loader);
+
+ // Do some best effort to emulate library-path support. It will not
+ // work for dependencies.
+ //
+ // Note: null has a special meaning and must be preserved.
+ std::string c_library_path; // Empty string by default.
+ if (library_path != nullptr && path != nullptr && path[0] != '/') {
+ ScopedUtfChars library_path_utf_chars(env, library_path);
+ c_library_path = library_path_utf_chars.c_str();
+ }
+
+ std::vector<std::string> library_paths = base::Split(c_library_path, ":");
+
+ for (const std::string& lib_path : library_paths) {
+ *needs_native_bridge = false;
+ const char* path_arg;
+ std::string complete_path;
+ if (path == nullptr) {
+ // Preserve null.
+ path_arg = nullptr;
} else {
- *needs_native_bridge = false;
+ complete_path = lib_path;
+ if (!complete_path.empty()) {
+ complete_path.append("/");
+ }
+ complete_path.append(path);
+ path_arg = complete_path.c_str();
+ }
+ void* handle = dlopen(path_arg, RTLD_NOW);
+ if (handle != nullptr) {
+ return handle;
+ }
+ if (NativeBridgeIsSupported(path_arg)) {
+ *needs_native_bridge = true;
+ handle = NativeBridgeLoadLibrary(path_arg, RTLD_NOW);
+ if (handle != nullptr) {
+ return handle;
+ }
+ *error_msg = NativeBridgeGetError();
+ } else {
*error_msg = dlerror();
}
}
- return handle;
+ return nullptr;
#endif
}
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 492d63a..19269d8 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -77,7 +77,7 @@
#
# create some directories (some are mount points) and symlinks
LOCAL_POST_INSTALL_CMD := mkdir -p $(addprefix $(TARGET_ROOT_OUT)/, \
- sbin dev proc sys system data oem acct config storage mnt $(BOARD_ROOT_EXTRA_FOLDERS)); \
+ sbin dev proc sys system data odm oem acct config storage mnt $(BOARD_ROOT_EXTRA_FOLDERS)); \
ln -sf /system/bin $(TARGET_ROOT_OUT)/bin; \
ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
ln -sf /data/user_de/0/com.android.shell/files/bugreports $(TARGET_ROOT_OUT)/bugreports; \