summaryrefslogtreecommitdiff
path: root/jni/include
diff options
context:
space:
mode:
authorSahana Rao <sahanas@google.com>2019-10-10 18:10:37 +0100
committerSahana Rao <sahanas@google.com>2019-11-27 13:43:58 +0000
commita82bd6abfba82f2e7ab710a3376459f4c7a657ff (patch)
treea5496edda87cb2f81b2674fd2b8947ab3357a793 /jni/include
parent44f85f27c9e2d9bd709b37208b209deb47d86118 (diff)
downloadMediaProvider-a82bd6abfba82f2e7ab710a3376459f4c7a657ff.tar.gz
Implement FUSE readdir Function
Returns the buffer with directory entries. readdir gets most of the directory entries by querying MediaProvider database. Paths that are not indexed by MediaProvider database are handled by querying the lower file system. Bug: 142806973 Bug: 142475473 Test: ls -R /storage/emulated/0/ Returns a list of files and directories filtered based on the visibility of the app to the corresponding file/directory. Change-Id: Ic9840d71483d7abe1b950c90f06f96ef9895ca61
Diffstat (limited to 'jni/include')
-rw-r--r--jni/include/libfuse_jni/ReaddirHelper.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/jni/include/libfuse_jni/ReaddirHelper.h b/jni/include/libfuse_jni/ReaddirHelper.h
new file mode 100644
index 000000000..04746133f
--- /dev/null
+++ b/jni/include/libfuse_jni/ReaddirHelper.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIA_PROVIDER_FUSE_READDIR_HELPER_H
+#define MEDIA_PROVIDER_FUSE_READDIR_HELPER_H
+
+#include <dirent.h>
+#include <string>
+#include <vector>
+
+namespace mediaprovider {
+namespace fuse {
+
+/**
+ * Holds a directory entry.
+ *
+ * DirectoryEntry object holds information about the directory entry such as
+ * name and type of the file or directory.
+ */
+struct DirectoryEntry {
+ /**
+ * Create a directory entry.
+ *
+ * @param name directory entry name.
+ * @param type directory entry type. Directory entry type corresponds to
+ * d_type of dirent structure defined in dirent.h
+ */
+ DirectoryEntry(const std::string& name, int type) : d_name(name), d_type(type) {}
+ const std::string d_name;
+ const int d_type;
+};
+
+/**
+ * Gets directory entries from lower file system.
+ *
+ * This will be used for FUSE root node and other paths which are not indexed by
+ * MediaProvider database.
+ */
+std::vector<std::shared_ptr<DirectoryEntry>> getDirectoryEntriesFromLowerFs(DIR* d);
+
+/**
+ * Checks if the given path is indexed by MediaProvider database.
+ *
+ * TODO(b/142806973): App based filtering of directory contents can not be done for
+ * some of the paths here. Remove/Modify this function to obtain the filtering option
+ * information from MediaProvider instead of comparing raw path.
+ */
+bool IsDirectoryEntryFilteringNeeded(const std::string& path);
+
+} // namespace fuse
+} // namespace mediaprovider
+#endif