summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaichi Hirono2017-03-06 00:23:16 -0600
committerDaichi Hirono2017-03-28 19:13:58 -0500
commit8e16ceecb770df194ed7fb6ba70c01505a52a609 (patch)
tree32fac895d893e97e279fbf6998604904fd31df31 /libappfuse/include/libappfuse/FuseAppLoop.h
parentdf937b8255d86d97c97fd8d9ca7ea5352e2d8975 (diff)
downloadplatform-system-core-8e16ceecb770df194ed7fb6ba70c01505a52a609.tar.gz
platform-system-core-8e16ceecb770df194ed7fb6ba70c01505a52a609.tar.xz
platform-system-core-8e16ceecb770df194ed7fb6ba70c01505a52a609.zip
Change FuseAppLoop so that it can process messages asynchronously.
Previously FuseAppLoopCallback needs to return values in a synchrnous manner. The CL changes it to asynchronous mannger so that apps can process FUSE message asynchrnously. Bug: 35229514 Test: FuseAppLoopTest Change-Id: I8edcfdb003a25cfd5e9c490ec871140220b21e35 (cherry picked from commit f5d15f9fc4b8bd7a866660fe208bf857dea839ba)
Diffstat (limited to 'libappfuse/include/libappfuse/FuseAppLoop.h')
-rw-r--r--libappfuse/include/libappfuse/FuseAppLoop.h48
1 files changed, 38 insertions, 10 deletions
diff --git a/libappfuse/include/libappfuse/FuseAppLoop.h b/libappfuse/include/libappfuse/FuseAppLoop.h
index c3edfcc32..f2ef2b5c5 100644
--- a/libappfuse/include/libappfuse/FuseAppLoop.h
+++ b/libappfuse/include/libappfuse/FuseAppLoop.h
@@ -17,23 +17,51 @@
17#ifndef ANDROID_LIBAPPFUSE_FUSEAPPLOOP_H_ 17#ifndef ANDROID_LIBAPPFUSE_FUSEAPPLOOP_H_
18#define ANDROID_LIBAPPFUSE_FUSEAPPLOOP_H_ 18#define ANDROID_LIBAPPFUSE_FUSEAPPLOOP_H_
19 19
20#include <memory>
21#include <mutex>
22
23#include <android-base/unique_fd.h>
24
20#include "libappfuse/FuseBuffer.h" 25#include "libappfuse/FuseBuffer.h"
21 26
22namespace android { 27namespace android {
23namespace fuse { 28namespace fuse {
24 29
30class EpollController;
31
25class FuseAppLoopCallback { 32class FuseAppLoopCallback {
26 public: 33 public:
27 virtual bool IsActive() = 0; 34 virtual void OnLookup(uint64_t unique, uint64_t inode) = 0;
28 virtual int64_t OnGetSize(uint64_t inode) = 0; 35 virtual void OnGetAttr(uint64_t unique, uint64_t inode) = 0;
29 virtual int32_t OnFsync(uint64_t inode) = 0; 36 virtual void OnFsync(uint64_t unique, uint64_t inode) = 0;
30 virtual int32_t OnWrite( 37 virtual void OnWrite(uint64_t unique, uint64_t inode, uint64_t offset, uint32_t size,
31 uint64_t inode, uint64_t offset, uint32_t size, const void* data) = 0; 38 const void* data) = 0;
32 virtual int32_t OnRead( 39 virtual void OnRead(uint64_t unique, uint64_t inode, uint64_t offset, uint32_t size) = 0;
33 uint64_t inode, uint64_t offset, uint32_t size, void* data) = 0; 40 virtual void OnOpen(uint64_t unique, uint64_t inode) = 0;
34 virtual int32_t OnOpen(uint64_t inode) = 0; 41 virtual void OnRelease(uint64_t unique, uint64_t inode) = 0;
35 virtual int32_t OnRelease(uint64_t inode) = 0; 42 virtual ~FuseAppLoopCallback();
36 virtual ~FuseAppLoopCallback() = default; 43};
44
45class FuseAppLoop final {
46 public:
47 FuseAppLoop(base::unique_fd&& fd);
48
49 void Start(FuseAppLoopCallback* callback);
50 void Break();
51
52 bool ReplySimple(uint64_t unique, int32_t result);
53 bool ReplyLookup(uint64_t unique, uint64_t inode, int64_t size);
54 bool ReplyGetAttr(uint64_t unique, uint64_t inode, int64_t size, int mode);
55 bool ReplyOpen(uint64_t unique, uint64_t fh);
56 bool ReplyWrite(uint64_t unique, uint32_t size);
57 bool ReplyRead(uint64_t unique, uint32_t size, const void* data);
58
59 private:
60 base::unique_fd fd_;
61 base::unique_fd break_fd_;
62
63 // Lock for multi-threading.
64 std::mutex mutex_;
37}; 65};
38 66
39bool StartFuseAppLoop(int fd, FuseAppLoopCallback* callback); 67bool StartFuseAppLoop(int fd, FuseAppLoopCallback* callback);