summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaichi Hirono2017-03-06 00:37:20 -0600
committerDaichi Hirono2017-03-23 02:22:03 -0500
commit96c6aa4f20717535921a927401cbfa16b56c193b (patch)
tree14d7d213b10f16d2feac08238d112ee9a5c5f5f2 /libappfuse/include/libappfuse
parent2b9a3391d0928f49d264d920e6ba0288e2e83e44 (diff)
downloadplatform-system-core-96c6aa4f20717535921a927401cbfa16b56c193b.tar.gz
platform-system-core-96c6aa4f20717535921a927401cbfa16b56c193b.tar.xz
platform-system-core-96c6aa4f20717535921a927401cbfa16b56c193b.zip
Enable FuseBridgeLoop to accept new mount point after starting
The CL turns StartFuseBridgeLoop function into FuseBridgeLoop class, and adds a method adding new appfuse mount to the loop. After doing this, one FuseBridgeLoop can process FUSE commands from multiple AppFuse mounts. Bug: 34903085 Test: libappfuse_test Change-Id: I54f11f54bc26c551281b9c32e9bb91f8f043774c
Diffstat (limited to 'libappfuse/include/libappfuse')
-rw-r--r--libappfuse/include/libappfuse/EpollController.h4
-rw-r--r--libappfuse/include/libappfuse/FuseBridgeLoop.h44
2 files changed, 43 insertions, 5 deletions
diff --git a/libappfuse/include/libappfuse/EpollController.h b/libappfuse/include/libappfuse/EpollController.h
index 3863abae7..622bd2cc9 100644
--- a/libappfuse/include/libappfuse/EpollController.h
+++ b/libappfuse/include/libappfuse/EpollController.h
@@ -37,8 +37,10 @@ class EpollController {
37 37
38 const std::vector<epoll_event>& events() const; 38 const std::vector<epoll_event>& events() const;
39 39
40 private: 40 protected:
41 bool InvokeControl(int op, int fd, int events, void* data) const; 41 bool InvokeControl(int op, int fd, int events, void* data) const;
42
43 private:
42 base::unique_fd poll_fd_; 44 base::unique_fd poll_fd_;
43 std::vector<epoll_event> events_; 45 std::vector<epoll_event> events_;
44 46
diff --git a/libappfuse/include/libappfuse/FuseBridgeLoop.h b/libappfuse/include/libappfuse/FuseBridgeLoop.h
index 1f71cf272..6bfda9819 100644
--- a/libappfuse/include/libappfuse/FuseBridgeLoop.h
+++ b/libappfuse/include/libappfuse/FuseBridgeLoop.h
@@ -17,6 +17,13 @@
17#ifndef ANDROID_LIBAPPFUSE_FUSEBRIDGELOOP_H_ 17#ifndef ANDROID_LIBAPPFUSE_FUSEBRIDGELOOP_H_
18#define ANDROID_LIBAPPFUSE_FUSEBRIDGELOOP_H_ 18#define ANDROID_LIBAPPFUSE_FUSEBRIDGELOOP_H_
19 19
20#include <map>
21#include <mutex>
22#include <queue>
23#include <unordered_set>
24
25#include <android-base/macros.h>
26
20#include "libappfuse/FuseBuffer.h" 27#include "libappfuse/FuseBuffer.h"
21 28
22namespace android { 29namespace android {
@@ -24,12 +31,41 @@ namespace fuse {
24 31
25class FuseBridgeLoopCallback { 32class FuseBridgeLoopCallback {
26 public: 33 public:
27 virtual void OnMount() = 0; 34 virtual void OnMount(int mount_id) = 0;
28 virtual ~FuseBridgeLoopCallback() = default; 35 virtual void OnClosed(int mount_id) = 0;
36 virtual ~FuseBridgeLoopCallback() = default;
29}; 37};
30 38
31bool StartFuseBridgeLoop( 39class FuseBridgeEntry;
32 int dev_fd, int proxy_fd, FuseBridgeLoopCallback* callback); 40class BridgeEpollController;
41
42class FuseBridgeLoop final {
43 public:
44 FuseBridgeLoop();
45 ~FuseBridgeLoop();
46
47 void Start(FuseBridgeLoopCallback* callback);
48
49 // Add bridge to the loop. It's OK to invoke the method from a different
50 // thread from one which invokes |Start|.
51 bool AddBridge(int mount_id, base::unique_fd dev_fd, base::unique_fd proxy_fd);
52
53 private:
54 bool ProcessEventLocked(const std::unordered_set<FuseBridgeEntry*>& entries,
55 FuseBridgeLoopCallback* callback);
56
57 std::unique_ptr<BridgeEpollController> epoll_controller_;
58
59 // Map between |mount_id| and bridge entry.
60 std::map<int, std::unique_ptr<FuseBridgeEntry>> bridges_;
61
62 // Lock for multi-threading.
63 std::mutex mutex_;
64
65 bool opened_;
66
67 DISALLOW_COPY_AND_ASSIGN(FuseBridgeLoop);
68};
33 69
34} // namespace fuse 70} // namespace fuse
35} // namespace android 71} // namespace android