summaryrefslogtreecommitdiff
path: root/jni/include
diff options
context:
space:
mode:
authorSahana Rao <sahanas@google.com>2019-12-06 11:32:56 +0000
committerSahana Rao <sahanas@google.com>2019-12-20 16:13:17 +0000
commit8a588e7e5c66475fe2be069158f31985bd7bdb97 (patch)
tree3e33133a72267e9ae55c18bffcaef23a507efba5 /jni/include
parent327f5944e0412fe788ea3e978825054ed1796202 (diff)
downloadMediaProvider-8a588e7e5c66475fe2be069158f31985bd7bdb97.tar.gz
List all directory names in FUSE readdir
Previously, FUSE readdir returned a filtered list of directory names. A directory name was returned only if the directory had at least one file in the directory tree to which calling package had access permissions. Also, readdir() skipped all empty directories since MediaProvider database doesn't include empty directories. Current implementation of readdir includes all directory names in the given directory. Directory names are obtained from lower file system to get unfiltered list of directory names and empty directories. File names are still filtered based on calling package's access permissions. This commit also removes extra code which handled readdir of external files and obb directories. These paths don't go through FUSE anymore. Bug: 144350275 Bug: 145287327 Bug: 142806973 Bug: 142475473 Test: atest -c FuseDaemonHostTest#testListDirectoriesWithMediaFiles atest -c FuseDaemonHostTest#testListDirectoriesWithNonMediaFiles atest -c MediaProviderTest#testRelativePathForInvalidDirectories atest -c MediaProviderTest#testRelativePathForValidDirectories Change-Id: I1f34d8faa29b2a507a3f981f3edb6a63c4331f04
Diffstat (limited to 'jni/include')
-rw-r--r--jni/include/libfuse_jni/ReaddirHelper.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/jni/include/libfuse_jni/ReaddirHelper.h b/jni/include/libfuse_jni/ReaddirHelper.h
index b4e7c8258..31a9aabcd 100644
--- a/jni/include/libfuse_jni/ReaddirHelper.h
+++ b/jni/include/libfuse_jni/ReaddirHelper.h
@@ -44,12 +44,18 @@ struct DirectoryEntry {
};
/**
- * Gets directory entries from lower file system.
+ * Adds directory entries from lower file system to the list.
*
- * This will be used for FUSE root node and other paths which are not indexed by
- * MediaProvider database.
+ * If a filter is specified, directory entries must satisfy the given filter. If filter is null,
+ * all directory entries(except '.' & '..') are returned.
*/
-std::vector<std::shared_ptr<DirectoryEntry>> getDirectoryEntriesFromLowerFs(DIR* d);
+void addDirectoryEntriesFromLowerFs(DIR* dirp, bool (*const filter)(const dirent&),
+ std::vector<std::shared_ptr<DirectoryEntry>>* directory_entries);
+
+/**
+ * Checks if the given dirent is directory.
+ */
+bool isDirectory(const dirent& entry);
} // namespace fuse
} // namespace mediaprovider