Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error opening volumes on USB drives on Android #1

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cryfs/impl/localstate/BasedirMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ void _save(const bf::path &metadataFilePath, const ptree& data) {
}

string jsonPathForBasedir(const bf::path &basedir) {
#ifdef __ANDROID__
// if basedir starts with /mnt/media_rw
if (basedir.string().rfind("/mnt/media_rw", 0) == 0) {
// Android returns permission denied when attempting to stat() /mnt/media_rw for some reason
// (even with "all files access") so checking if /mnt/media_rw is a symlink, as canonical()
// would, results in an error. Because we know /mnt/media_rw is not a symlink, and Android
// doesn't support removable storage filesystems that support symlinks, the canonical path
// for any path starting with /mnt/media_rw is equal to the absolute path after normalization
// (removal of "../" and "./" elements).
// See: https://github.com/hardcore-sushi/DroidFS/issues/281
return bf::absolute(basedir).lexically_normal().string() + ".filesystemId";
}
#endif
return bf::canonical(basedir).string() + ".filesystemId";
}

Expand Down