{"record":{"id":"f268614d80e9a8ec","repo":"MuntashirAkon/AppManager","slug":"mount-point-s-is-already-in-use","errorCode":null,"errorMessage":"Mount point (%s) is already in use.","messagePattern":"Mount point \\((.+?)\\) is already in use\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/io/fs/VirtualFileSystem.java","lineNumber":155,"sourceCode":"    }\n\n    @WorkerThread\n    public static int mount(@NonNull Uri mountPoint,\n                            @NonNull Path file,\n                            @NonNull String type,\n                            @NonNull MountOptions options)\n            throws IOException {\n        return mount(mountPoint, getNewInstance(file, type), options);\n    }\n\n    @WorkerThread\n    private static int mount(@NonNull Uri mountPoint, @NonNull VirtualFileSystem fs, @NonNull MountOptions options)\n            throws IOException {\n        int vfsId;\n        synchronized (sFileSystems) {\n            synchronized (sUriVfsIdsMap) {\n                if (!options.remount && sUriVfsIdsMap.get(mountPoint) != null) {\n                    throw new IOException(String.format(\"Mount point (%s) is already in use.\", mountPoint));\n                }\n            }\n            do {\n                vfsId = ThreadLocalRandom.current().nextInt(1, Integer.MAX_VALUE);\n            } while (vfsId == 0 || sFileSystems.get(vfsId) != null);\n            fs.mount(mountPoint, vfsId, options);\n            sFileSystems.put(vfsId, fs);\n        }\n        synchronized (sUriVfsIdsMap) {\n            sUriVfsIdsMap.put(mountPoint, vfsId);\n        }\n        synchronized (sParentUriVfsIdsMap) {\n            Uri uri = Paths.removeLastPathSegment(mountPoint);\n            List<Integer> vfsIds = sParentUriVfsIdsMap.get(uri);\n            if (vfsIds == null) {\n                vfsIds = new ArrayList<>(1);\n                sParentUriVfsIdsMap.put(uri, vfsIds);\n            }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/io/fs/VirtualFileSystem.java#L137-L173","documentation":"VirtualFileSystem.mount (static, package-private) refuses to mount a filesystem when the requested mount point Uri is already registered in sUriVfsIdsMap and the options don't carry the remount flag. This prevents two filesystems from shadowing the same mount point; an IOException naming the Uri is thrown.","triggerScenarios":"Calling mount() twice with the same mount point without unmounting; mounting after a previous session's mount is still registered in the process; auto-mount code running again on a configuration change without remount=true.","commonSituations":"Re-running a mount routine on app restart while the old mount is still alive; two features both mounting at the same path; duplicate user action (double-tap on 'Mount').","solutions":["Unmount the existing filesystem at that mount point first (VirtualFileSystem.unmount(mountPoint)), then mount.","Pass remount=true in MountOptions if the intent is to re-mount over the same point.","Guard mounting code with a check of VirtualFileSystem.getFileSystem(mountPoint) != null to skip already-mounted points.","Debounce/idempotence-protect user-triggered mount actions."],"exampleFix":"// before\nVirtualFileSystem.mount(mountPoint, options);\n// after\nif (VirtualFileSystem.getFileSystem(mountPoint) == null) {\n    VirtualFileSystem.mount(mountPoint, options);\n}","handlingStrategy":"validation","validationCode":"if (VirtualFileSystem.getFileSystem(mountPoint) != null && !options.remount) {\n    VirtualFileSystem.unmount(mountPoint); // or skip mounting\n}","typeGuard":null,"tryCatchPattern":"try {\n    VirtualFileSystem.mount(mountPoint, options);\n} catch (IOException e) {\n    if (String.valueOf(e.getMessage()).contains(\"already in use\")) {\n        VirtualFileSystem.unmount(mountPoint);\n        VirtualFileSystem.mount(mountPoint, options);\n    } else throw e;\n}","preventionTips":["Make mount operations idempotent: check before mount.","Use remount=true for intentional re-mounts.","Track mount lifecycle in one owner component to avoid double-mounts."],"tags":["filesystem","mount-point","conflict","android"],"backgroundTag":"address-already-in-use","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}