redroid-doc icon indicating copy to clipboard operation
redroid-doc copied to clipboard

redroid10 image sdcard partition fuse mode cannot be mounted

Open liukeqqs opened this issue 2 years ago • 5 comments

Describe the bug redroid10 image sdcard partition fuse mode cannot be mounted

make sure the required kernel modules present

  • grep binder /proc/filesystems
  • grep ashmem /proc/misc

collect debug logs curl -fsSL https://raw.githubusercontent.com/remote-android/redroid-doc/master/debug.sh | sudo bash -s -- [CONTAINER] omit CONTAINER if not exist any more.

Screenshots If applicable, add screenshots to help explain your problem.

liukeqqs avatar Sep 18 '23 15:09 liukeqqs

Try apply this patch (workaround)

diff --git a/sdcard/fuse.cpp b/sdcard/fuse.cpp
index 95559d7ff2..e173c89c6b 100644
--- a/sdcard/fuse.cpp
+++ b/sdcard/fuse.cpp
@@ -843,6 +843,9 @@ static int handle_unlink(struct fuse* fuse, struct fuse_handler* handler,
         if (fuse != fuse->global->fuse_write) {
             fuse_notify_delete(fuse->global->fuse_write, parent_node->nid, child_node->nid, name);
         }
+        if (fuse != fuse->global->fuse_full) {
+            fuse_notify_delete(fuse->global->fuse_full, parent_node->nid, child_node->nid, name);
+        }
     }
     return 0;
 }
@@ -893,6 +896,11 @@ static int handle_rmdir(struct fuse* fuse, struct fuse_handler* handler,
         if (fuse != fuse->global->fuse_write) {
             fuse_notify_delete(fuse->global->fuse_write, parent_node->nid, child_node->nid, name);
         }
+#if 0
+        if (fuse != fuse->global->fuse_full) {
+            fuse_notify_delete(fuse->global->fuse_full, parent_node->nid, child_node->nid, name);
+        }
+#endif
     }
     return 0;
 }
diff --git a/sdcard/fuse.h b/sdcard/fuse.h
index 9ccd21dc48..b4c2bb1d27 100644
--- a/sdcard/fuse.h
+++ b/sdcard/fuse.h
@@ -176,6 +176,7 @@ struct fuse_global {
     struct fuse* fuse_default;
     struct fuse* fuse_read;
     struct fuse* fuse_write;
+    struct fuse* fuse_full;
 };

 /* Single FUSE mount */
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 0cfac382ab..f1bb782f5d 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -217,20 +217,25 @@ static void run(const char* source_path, const char* label, uid_t uid,
     struct fuse fuse_default;
     struct fuse fuse_read;
     struct fuse fuse_write;
+    struct fuse fuse_full;
     struct fuse_handler handler_default;
     struct fuse_handler handler_read;
     struct fuse_handler handler_write;
+    struct fuse_handler handler_full;
     pthread_t thread_default;
     pthread_t thread_read;
     pthread_t thread_write;
+    pthread_t thread_full;

     memset(&global, 0, sizeof(global));
     memset(&fuse_default, 0, sizeof(fuse_default));
     memset(&fuse_read, 0, sizeof(fuse_read));
     memset(&fuse_write, 0, sizeof(fuse_write));
+    memset(&fuse_full, 0, sizeof(fuse_full));
     memset(&handler_default, 0, sizeof(handler_default));
     memset(&handler_read, 0, sizeof(handler_read));
     memset(&handler_write, 0, sizeof(handler_write));
+    memset(&handler_full, 0, sizeof(handler_full));

     pthread_mutex_init(&global.lock, NULL);
     global.package_to_appid = new AppIdMap;
@@ -262,22 +267,27 @@ static void run(const char* source_path, const char* label, uid_t uid,
     fuse_default.global = &global;
     fuse_read.global = &global;
     fuse_write.global = &global;
+    fuse_full.global = &global;

     global.fuse_default = &fuse_default;
     global.fuse_read = &fuse_read;
     global.fuse_write = &fuse_write;
+    global.fuse_full = &fuse_full;

     snprintf(fuse_default.dest_path, PATH_MAX, "/mnt/runtime/default/%s", label);
     snprintf(fuse_read.dest_path, PATH_MAX, "/mnt/runtime/read/%s", label);
     snprintf(fuse_write.dest_path, PATH_MAX, "/mnt/runtime/write/%s", label);
+    snprintf(fuse_full.dest_path, PATH_MAX, "/mnt/runtime/full/%s", label);

     handler_default.fuse = &fuse_default;
     handler_read.fuse = &fuse_read;
     handler_write.fuse = &fuse_write;
+    handler_full.fuse = &fuse_full;

     handler_default.token = 0;
     handler_read.token = 1;
     handler_write.token = 2;
+    handler_full.token = 3;

     umask(0);

@@ -286,6 +296,7 @@ static void run(const char* source_path, const char* label, uid_t uid,
          * permissions are completely masked off. */
         if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                 || fuse_setup(&fuse_read, AID_EVERYBODY, 0027)
+                || fuse_setup(&fuse_full, AID_EVERYBODY, 0007)
                 || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0027)) {
             PLOG(FATAL) << "failed to fuse_setup";
         }
@@ -295,6 +306,7 @@ static void run(const char* source_path, const char* label, uid_t uid,
          * deep inside attr_from_stat(). */
         if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                 || fuse_setup(&fuse_read, AID_EVERYBODY, full_write ? 0027 : 0022)
+                || fuse_setup(&fuse_full, AID_EVERYBODY, 0007)
                 || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0022)) {
             PLOG(FATAL) << "failed to fuse_setup";
         }
@@ -309,6 +321,7 @@ static void run(const char* source_path, const char* label, uid_t uid,

     if (pthread_create(&thread_default, NULL, start_handler, &handler_default)
             || pthread_create(&thread_read, NULL, start_handler, &handler_read)
+            || pthread_create(&thread_full, NULL, start_handler, &handler_full)
             || pthread_create(&thread_write, NULL, start_handler, &handler_write)) {
         LOG(FATAL) << "failed to pthread_create";
     }

zhouziyang avatar Sep 19 '23 10:09 zhouziyang

Try apply this patch (workaround)

diff --git a/sdcard/fuse.cpp b/sdcard/fuse.cpp
index 95559d7ff2..e173c89c6b 100644
--- a/sdcard/fuse.cpp
+++ b/sdcard/fuse.cpp
@@ -843,6 +843,9 @@ static int handle_unlink(struct fuse* fuse, struct fuse_handler* handler,
         if (fuse != fuse->global->fuse_write) {
             fuse_notify_delete(fuse->global->fuse_write, parent_node->nid, child_node->nid, name);
         }
+        if (fuse != fuse->global->fuse_full) {
+            fuse_notify_delete(fuse->global->fuse_full, parent_node->nid, child_node->nid, name);
+        }
     }
     return 0;
 }
@@ -893,6 +896,11 @@ static int handle_rmdir(struct fuse* fuse, struct fuse_handler* handler,
         if (fuse != fuse->global->fuse_write) {
             fuse_notify_delete(fuse->global->fuse_write, parent_node->nid, child_node->nid, name);
         }
+#if 0
+        if (fuse != fuse->global->fuse_full) {
+            fuse_notify_delete(fuse->global->fuse_full, parent_node->nid, child_node->nid, name);
+        }
+#endif
     }
     return 0;
 }
diff --git a/sdcard/fuse.h b/sdcard/fuse.h
index 9ccd21dc48..b4c2bb1d27 100644
--- a/sdcard/fuse.h
+++ b/sdcard/fuse.h
@@ -176,6 +176,7 @@ struct fuse_global {
     struct fuse* fuse_default;
     struct fuse* fuse_read;
     struct fuse* fuse_write;
+    struct fuse* fuse_full;
 };

 /* Single FUSE mount */
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 0cfac382ab..f1bb782f5d 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -217,20 +217,25 @@ static void run(const char* source_path, const char* label, uid_t uid,
     struct fuse fuse_default;
     struct fuse fuse_read;
     struct fuse fuse_write;
+    struct fuse fuse_full;
     struct fuse_handler handler_default;
     struct fuse_handler handler_read;
     struct fuse_handler handler_write;
+    struct fuse_handler handler_full;
     pthread_t thread_default;
     pthread_t thread_read;
     pthread_t thread_write;
+    pthread_t thread_full;

     memset(&global, 0, sizeof(global));
     memset(&fuse_default, 0, sizeof(fuse_default));
     memset(&fuse_read, 0, sizeof(fuse_read));
     memset(&fuse_write, 0, sizeof(fuse_write));
+    memset(&fuse_full, 0, sizeof(fuse_full));
     memset(&handler_default, 0, sizeof(handler_default));
     memset(&handler_read, 0, sizeof(handler_read));
     memset(&handler_write, 0, sizeof(handler_write));
+    memset(&handler_full, 0, sizeof(handler_full));

     pthread_mutex_init(&global.lock, NULL);
     global.package_to_appid = new AppIdMap;
@@ -262,22 +267,27 @@ static void run(const char* source_path, const char* label, uid_t uid,
     fuse_default.global = &global;
     fuse_read.global = &global;
     fuse_write.global = &global;
+    fuse_full.global = &global;

     global.fuse_default = &fuse_default;
     global.fuse_read = &fuse_read;
     global.fuse_write = &fuse_write;
+    global.fuse_full = &fuse_full;

     snprintf(fuse_default.dest_path, PATH_MAX, "/mnt/runtime/default/%s", label);
     snprintf(fuse_read.dest_path, PATH_MAX, "/mnt/runtime/read/%s", label);
     snprintf(fuse_write.dest_path, PATH_MAX, "/mnt/runtime/write/%s", label);
+    snprintf(fuse_full.dest_path, PATH_MAX, "/mnt/runtime/full/%s", label);

     handler_default.fuse = &fuse_default;
     handler_read.fuse = &fuse_read;
     handler_write.fuse = &fuse_write;
+    handler_full.fuse = &fuse_full;

     handler_default.token = 0;
     handler_read.token = 1;
     handler_write.token = 2;
+    handler_full.token = 3;

     umask(0);

@@ -286,6 +296,7 @@ static void run(const char* source_path, const char* label, uid_t uid,
          * permissions are completely masked off. */
         if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                 || fuse_setup(&fuse_read, AID_EVERYBODY, 0027)
+                || fuse_setup(&fuse_full, AID_EVERYBODY, 0007)
                 || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0027)) {
             PLOG(FATAL) << "failed to fuse_setup";
         }
@@ -295,6 +306,7 @@ static void run(const char* source_path, const char* label, uid_t uid,
          * deep inside attr_from_stat(). */
         if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                 || fuse_setup(&fuse_read, AID_EVERYBODY, full_write ? 0027 : 0022)
+                || fuse_setup(&fuse_full, AID_EVERYBODY, 0007)
                 || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0022)) {
             PLOG(FATAL) << "failed to fuse_setup";
         }
@@ -309,6 +321,7 @@ static void run(const char* source_path, const char* label, uid_t uid,

     if (pthread_create(&thread_default, NULL, start_handler, &handler_default)
             || pthread_create(&thread_read, NULL, start_handler, &handler_read)
+            || pthread_create(&thread_full, NULL, start_handler, &handler_full)
             || pthread_create(&thread_write, NULL, start_handler, &handler_write)) {
         LOG(FATAL) << "failed to pthread_create";
     }

I modified the AOSP source code according to your diff and recompiled it, but sdcrad still failed to mount successfully.

liukeqqs avatar Sep 19 '23 14:09 liukeqqs

Try apply this patch (workaround)

diff --git a/sdcard/fuse.cpp b/sdcard/fuse.cpp
index 95559d7ff2..e173c89c6b 100644
--- a/sdcard/fuse.cpp
+++ b/sdcard/fuse.cpp
@@ -843,6 +843,9 @@ static int handle_unlink(struct fuse* fuse, struct fuse_handler* handler,
         if (fuse != fuse->global->fuse_write) {
             fuse_notify_delete(fuse->global->fuse_write, parent_node->nid, child_node->nid, name);
         }
+        if (fuse != fuse->global->fuse_full) {
+            fuse_notify_delete(fuse->global->fuse_full, parent_node->nid, child_node->nid, name);
+        }
     }
     return 0;
 }
@@ -893,6 +896,11 @@ static int handle_rmdir(struct fuse* fuse, struct fuse_handler* handler,
         if (fuse != fuse->global->fuse_write) {
             fuse_notify_delete(fuse->global->fuse_write, parent_node->nid, child_node->nid, name);
         }
+#if 0
+        if (fuse != fuse->global->fuse_full) {
+            fuse_notify_delete(fuse->global->fuse_full, parent_node->nid, child_node->nid, name);
+        }
+#endif
     }
     return 0;
 }
diff --git a/sdcard/fuse.h b/sdcard/fuse.h
index 9ccd21dc48..b4c2bb1d27 100644
--- a/sdcard/fuse.h
+++ b/sdcard/fuse.h
@@ -176,6 +176,7 @@ struct fuse_global {
     struct fuse* fuse_default;
     struct fuse* fuse_read;
     struct fuse* fuse_write;
+    struct fuse* fuse_full;
 };

 /* Single FUSE mount */
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 0cfac382ab..f1bb782f5d 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -217,20 +217,25 @@ static void run(const char* source_path, const char* label, uid_t uid,
     struct fuse fuse_default;
     struct fuse fuse_read;
     struct fuse fuse_write;
+    struct fuse fuse_full;
     struct fuse_handler handler_default;
     struct fuse_handler handler_read;
     struct fuse_handler handler_write;
+    struct fuse_handler handler_full;
     pthread_t thread_default;
     pthread_t thread_read;
     pthread_t thread_write;
+    pthread_t thread_full;

     memset(&global, 0, sizeof(global));
     memset(&fuse_default, 0, sizeof(fuse_default));
     memset(&fuse_read, 0, sizeof(fuse_read));
     memset(&fuse_write, 0, sizeof(fuse_write));
+    memset(&fuse_full, 0, sizeof(fuse_full));
     memset(&handler_default, 0, sizeof(handler_default));
     memset(&handler_read, 0, sizeof(handler_read));
     memset(&handler_write, 0, sizeof(handler_write));
+    memset(&handler_full, 0, sizeof(handler_full));

     pthread_mutex_init(&global.lock, NULL);
     global.package_to_appid = new AppIdMap;
@@ -262,22 +267,27 @@ static void run(const char* source_path, const char* label, uid_t uid,
     fuse_default.global = &global;
     fuse_read.global = &global;
     fuse_write.global = &global;
+    fuse_full.global = &global;

     global.fuse_default = &fuse_default;
     global.fuse_read = &fuse_read;
     global.fuse_write = &fuse_write;
+    global.fuse_full = &fuse_full;

     snprintf(fuse_default.dest_path, PATH_MAX, "/mnt/runtime/default/%s", label);
     snprintf(fuse_read.dest_path, PATH_MAX, "/mnt/runtime/read/%s", label);
     snprintf(fuse_write.dest_path, PATH_MAX, "/mnt/runtime/write/%s", label);
+    snprintf(fuse_full.dest_path, PATH_MAX, "/mnt/runtime/full/%s", label);

     handler_default.fuse = &fuse_default;
     handler_read.fuse = &fuse_read;
     handler_write.fuse = &fuse_write;
+    handler_full.fuse = &fuse_full;

     handler_default.token = 0;
     handler_read.token = 1;
     handler_write.token = 2;
+    handler_full.token = 3;

     umask(0);

@@ -286,6 +296,7 @@ static void run(const char* source_path, const char* label, uid_t uid,
          * permissions are completely masked off. */
         if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                 || fuse_setup(&fuse_read, AID_EVERYBODY, 0027)
+                || fuse_setup(&fuse_full, AID_EVERYBODY, 0007)
                 || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0027)) {
             PLOG(FATAL) << "failed to fuse_setup";
         }
@@ -295,6 +306,7 @@ static void run(const char* source_path, const char* label, uid_t uid,
          * deep inside attr_from_stat(). */
         if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006)
                 || fuse_setup(&fuse_read, AID_EVERYBODY, full_write ? 0027 : 0022)
+                || fuse_setup(&fuse_full, AID_EVERYBODY, 0007)
                 || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0022)) {
             PLOG(FATAL) << "failed to fuse_setup";
         }
@@ -309,6 +321,7 @@ static void run(const char* source_path, const char* label, uid_t uid,

     if (pthread_create(&thread_default, NULL, start_handler, &handler_default)
             || pthread_create(&thread_read, NULL, start_handler, &handler_read)
+            || pthread_create(&thread_full, NULL, start_handler, &handler_full)
             || pthread_create(&thread_write, NULL, start_handler, &handler_write)) {
         LOG(FATAL) << "failed to pthread_create";
     }

Can you help me take a look? Still failed to mount successfully. I have made the modifications according to your request 1 2 3 4 5 6 7

liukeqqs avatar Sep 20 '23 04:09 liukeqqs

handle_rmdir

why not call fuse_notify_delete in handle_rmdir()?

teejoe avatar Jan 18 '24 06:01 teejoe

ccessfully. I have ma

try remove waitpid() from vold->EmulatedVolume::doMount(), because sdcard in fuse never returns, thus vold become stucked here waiting for pid.

teejoe avatar Jan 18 '24 09:01 teejoe