summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaichi Hirono2016-11-07 19:17:51 -0600
committerDaichi Hirono2016-11-14 18:47:31 -0600
commita0aecda12b9a76aa15a8c5175e15538574a05af7 (patch)
treeac1e8eda1f03a8922445ae13d6d7a4173158c4ec /libappfuse/include/libappfuse/FuseBuffer.h
parentb5ce6f02dd11b42c03884dd9531c6c8a80bcecda (diff)
downloadplatform-system-core-a0aecda12b9a76aa15a8c5175e15538574a05af7.tar.gz
platform-system-core-a0aecda12b9a76aa15a8c5175e15538574a05af7.tar.xz
platform-system-core-a0aecda12b9a76aa15a8c5175e15538574a05af7.zip
Add FuseAppLoop to libappfuse.
The class is used at the app side (StorageManager) to parse FUSE commands. Bug: 32260320 Test: libappfuse_test Change-Id: I1ae2904d3290a041f1efbf8fc10ba032eda5449c
Diffstat (limited to 'libappfuse/include/libappfuse/FuseBuffer.h')
-rw-r--r--libappfuse/include/libappfuse/FuseBuffer.h39
1 files changed, 23 insertions, 16 deletions
diff --git a/libappfuse/include/libappfuse/FuseBuffer.h b/libappfuse/include/libappfuse/FuseBuffer.h
index 071b77715..1464142c4 100644
--- a/libappfuse/include/libappfuse/FuseBuffer.h
+++ b/libappfuse/include/libappfuse/FuseBuffer.h
@@ -20,6 +20,7 @@
20#include <linux/fuse.h> 20#include <linux/fuse.h>
21 21
22namespace android { 22namespace android {
23namespace fuse {
23 24
24// The numbers came from sdcard.c. 25// The numbers came from sdcard.c.
25// Maximum number of bytes to write/read in one request/one reply. 26// Maximum number of bytes to write/read in one request/one reply.
@@ -37,33 +38,51 @@ struct FuseMessage {
37 bool CheckResult(int result, const char* operation_name) const; 38 bool CheckResult(int result, const char* operation_name) const;
38}; 39};
39 40
40struct FuseRequest : public FuseMessage<FuseRequest, fuse_in_header> { 41// FuseRequest represents file operation requests from /dev/fuse. It starts
42// from fuse_in_header. The body layout depends on the operation code.
43struct FuseRequest final : public FuseMessage<FuseRequest, fuse_in_header> {
41 union { 44 union {
45 // for FUSE_WRITE
42 struct { 46 struct {
43 fuse_write_in write_in; 47 fuse_write_in write_in;
44 char write_data[kFuseMaxWrite]; 48 char write_data[kFuseMaxWrite];
45 }; 49 };
50 // for FUSE_OPEN
46 fuse_open_in open_in; 51 fuse_open_in open_in;
52 // for FUSE_INIT
47 fuse_init_in init_in; 53 fuse_init_in init_in;
54 // for FUSE_READ
48 fuse_read_in read_in; 55 fuse_read_in read_in;
56 // for FUSE_LOOKUP
49 char lookup_name[0]; 57 char lookup_name[0];
50 }; 58 };
59 void Reset(uint32_t data_length, uint32_t opcode, uint64_t unique);
51}; 60};
52 61
53struct FuseResponse : public FuseMessage<FuseResponse, fuse_out_header> { 62// FuseResponse represents file operation responses to /dev/fuse. It starts
63// from fuse_out_header. The body layout depends on the operation code.
64struct FuseResponse final : public FuseMessage<FuseResponse, fuse_out_header> {
54 union { 65 union {
66 // for FUSE_INIT
55 fuse_init_out init_out; 67 fuse_init_out init_out;
68 // for FUSE_LOOKUP
56 fuse_entry_out entry_out; 69 fuse_entry_out entry_out;
70 // for FUSE_GETATTR
57 fuse_attr_out attr_out; 71 fuse_attr_out attr_out;
72 // for FUSE_OPEN
58 fuse_open_out open_out; 73 fuse_open_out open_out;
74 // for FUSE_READ
59 char read_data[kFuseMaxRead]; 75 char read_data[kFuseMaxRead];
76 // for FUSE_WRITE
60 fuse_write_out write_out; 77 fuse_write_out write_out;
61 }; 78 };
62 void Reset(uint32_t data_length, int32_t error, uint64_t unique); 79 void Reset(uint32_t data_length, int32_t error, uint64_t unique);
63 void ResetHeader(uint32_t data_length, int32_t error, uint64_t unique); 80 void ResetHeader(uint32_t data_length, int32_t error, uint64_t unique);
64}; 81};
65 82
66union FuseBuffer { 83// To reduce memory usage, FuseBuffer shares the memory region for request and
84// response.
85union FuseBuffer final {
67 FuseRequest request; 86 FuseRequest request;
68 FuseResponse response; 87 FuseResponse response;
69 88
@@ -71,19 +90,7 @@ union FuseBuffer {
71 void HandleNotImpl(); 90 void HandleNotImpl();
72}; 91};
73 92
74class FuseProxyLoop { 93} // namespace fuse
75 class IFuseProxyLoopCallback {
76 public:
77 virtual void OnMount() = 0;
78 virtual ~IFuseProxyLoopCallback() = default;
79 };
80
81 bool Start(int dev_fd, int proxy_fd, IFuseProxyLoopCallback* callback);
82
83 private:
84 FuseBuffer buffer_;
85};
86
87} // namespace android 94} // namespace android
88 95
89#endif // ANDROID_LIBAPPFUSE_FUSEBUFFER_H_ 96#endif // ANDROID_LIBAPPFUSE_FUSEBUFFER_H_