diff options
author | Zim <zezeozue@google.com> | 2019-10-03 21:01:26 +0100 |
---|---|---|
committer | Zim <zezeozue@google.com> | 2019-10-03 21:12:00 +0100 |
commit | 7c8712dfe5ffb80e2cbb259b961a2c38bda1df49 (patch) | |
tree | 3b25863b3d076ebdb1db9fc037cf6a4de1b75a21 /jni/com_android_providers_media_FuseDaemon.cpp | |
parent | 4e06f48c7681ba31f32b3b0fadac1e4fbcb8fef6 (diff) | |
download | MediaProvider-7c8712dfe5ffb80e2cbb259b961a2c38bda1df49.tar.gz |
Cleanup FuseDaemon properly when it exits
When vold unmounts a volume, the FuseDaemon exits and the
ExternalStorageService is unaware of that state change. This causes
the FuseDaemon to hang on the next mount with the same sessionId.
Now, we notify the ExternalStorageService when the FuseDaemon exits.
Also, since the /storage paths are bind mounts of the lower
filesystem, we simplify the FuseDameon code by passing only the upper
filesystem path (/storage/...) to libfuse. And all paths the FUSE
kernel driver can be directly accessed without any translation or
mapping to a lower filesystem path.
Minor code cleanups, fixed TODOs, improved logging and some clang-tidy
Bug: 135341433
Test: adb shell ls /sdcard when the FUSE property is turned on
Change-Id: I9589e61636c13a6d5c8a18aba39762497fdc18c3
Diffstat (limited to 'jni/com_android_providers_media_FuseDaemon.cpp')
-rw-r--r-- | jni/com_android_providers_media_FuseDaemon.cpp | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/jni/com_android_providers_media_FuseDaemon.cpp b/jni/com_android_providers_media_FuseDaemon.cpp index 003f10e4b..a6a8d1844 100644 --- a/jni/com_android_providers_media_FuseDaemon.cpp +++ b/jni/com_android_providers_media_FuseDaemon.cpp @@ -36,24 +36,17 @@ jlong com_android_providers_media_FuseDaemon_new(JNIEnv* env, jobject self, jobj } void com_android_providers_media_FuseDaemon_start(JNIEnv* env, jobject self, jlong java_daemon, - jint fd, jstring java_upper_path, - jstring java_lower_path) { + jint fd, jstring java_path) { LOG(DEBUG) << "Starting the FUSE daemon..."; fuse::FuseDaemon* const daemon = reinterpret_cast<fuse::FuseDaemon*>(java_daemon); - ScopedUtfChars utf_chars_upper_path(env, java_upper_path); - if (!utf_chars_upper_path.c_str()) { + ScopedUtfChars utf_chars_path(env, java_path); + if (!utf_chars_path.c_str()) { return; } - const std::string& string_upper_path = std::string(utf_chars_upper_path.c_str()); + const std::string& string_path = std::string(utf_chars_path.c_str()); - ScopedUtfChars utf_chars_lower_path(env, java_lower_path); - if (!utf_chars_lower_path.c_str()) { - return; - } - const std::string& string_lower_path = std::string(utf_chars_lower_path.c_str()); - - daemon->Start(fd, string_upper_path, string_lower_path); + daemon->Start(fd, string_path); } void com_android_providers_media_FuseDaemon_stop(JNIEnv* env, jobject self, jlong java_daemon) { @@ -69,27 +62,14 @@ void com_android_providers_media_FuseDaemon_delete(JNIEnv* env, jobject self, jl } const JNINativeMethod methods[] = { - { - "native_new", - "(Lcom/android/providers/media/MediaProvider;)J", - reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_new) - }, - { - "native_start", - "(JILjava/lang/String;Ljava/lang/String;)V", - reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_start) - }, - { - "native_stop", - "(J)V", - reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_stop) - }, - { - "native_delete", - "(J)V", - reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_delete) - } -}; + {"native_new", "(Lcom/android/providers/media/MediaProvider;)J", + reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_new)}, + {"native_start", "(JILjava/lang/String;)V", + reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_start)}, + {"native_stop", "(J)V", + reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_stop)}, + {"native_delete", "(J)V", + reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_delete)}}; } // namespace void register_android_providers_media_FuseDaemon(JNIEnv* env) { |