summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaichi Hirono2017-03-22 02:41:46 -0500
committerDaichi Hirono2017-03-22 20:04:15 -0500
commit0bb22bd50ea7264684fa8c35b34fcc380e9d2cdc (patch)
treedc8ee89f3beba20ceda8e075554427c8709b3f37 /libappfuse/include/libappfuse
parentce009490fbf3fffc7aa2d1cd91b1485d6e98eaf8 (diff)
downloadplatform-system-core-0bb22bd50ea7264684fa8c35b34fcc380e9d2cdc.tar.gz
platform-system-core-0bb22bd50ea7264684fa8c35b34fcc380e9d2cdc.tar.xz
platform-system-core-0bb22bd50ea7264684fa8c35b34fcc380e9d2cdc.zip
Add FuseMessage::WriteWithBody function
The funciton is going to be used to write FUSE header with external body. Bug: 35229514 Test: libappfuse_tests Change-Id: I303022b555deca960b8e08f26140a5ef10133efe
Diffstat (limited to 'libappfuse/include/libappfuse')
-rw-r--r--libappfuse/include/libappfuse/FuseBuffer.h44
1 files changed, 23 insertions, 21 deletions
diff --git a/libappfuse/include/libappfuse/FuseBuffer.h b/libappfuse/include/libappfuse/FuseBuffer.h
index fbb05d633..7a70bf3b4 100644
--- a/libappfuse/include/libappfuse/FuseBuffer.h
+++ b/libappfuse/include/libappfuse/FuseBuffer.h
@@ -43,11 +43,9 @@ class FuseMessage {
43 public: 43 public:
44 bool Read(int fd); 44 bool Read(int fd);
45 bool Write(int fd) const; 45 bool Write(int fd) const;
46 bool WriteWithBody(int fd, size_t max_size, const void* data) const;
46 ResultOrAgain ReadOrAgain(int fd); 47 ResultOrAgain ReadOrAgain(int fd);
47 ResultOrAgain WriteOrAgain(int fd) const; 48 ResultOrAgain WriteOrAgain(int fd) const;
48
49private:
50 bool CheckHeaderLength(const char* name) const;
51}; 49};
52 50
53// FuseRequest represents file operation requests from /dev/fuse. It starts 51// FuseRequest represents file operation requests from /dev/fuse. It starts
@@ -74,26 +72,30 @@ struct FuseRequest : public FuseMessage<FuseRequest> {
74 72
75// FuseResponse represents file operation responses to /dev/fuse. It starts 73// FuseResponse represents file operation responses to /dev/fuse. It starts
76// from fuse_out_header. The body layout depends on the operation code. 74// from fuse_out_header. The body layout depends on the operation code.
77struct FuseResponse : public FuseMessage<FuseResponse> { 75template <size_t N>
78 fuse_out_header header; 76struct FuseResponseBase : public FuseMessage<FuseResponseBase<N>> {
79 union { 77 fuse_out_header header;
80 // for FUSE_INIT 78 union {
81 fuse_init_out init_out; 79 // for FUSE_INIT
82 // for FUSE_LOOKUP 80 fuse_init_out init_out;
83 fuse_entry_out entry_out; 81 // for FUSE_LOOKUP
84 // for FUSE_GETATTR 82 fuse_entry_out entry_out;
85 fuse_attr_out attr_out; 83 // for FUSE_GETATTR
86 // for FUSE_OPEN 84 fuse_attr_out attr_out;
87 fuse_open_out open_out; 85 // for FUSE_OPEN
88 // for FUSE_READ 86 fuse_open_out open_out;
89 char read_data[kFuseMaxRead]; 87 // for FUSE_READ
90 // for FUSE_WRITE 88 char read_data[N];
91 fuse_write_out write_out; 89 // for FUSE_WRITE
92 }; 90 fuse_write_out write_out;
93 void Reset(uint32_t data_length, int32_t error, uint64_t unique); 91 };
94 void ResetHeader(uint32_t data_length, int32_t error, uint64_t unique); 92 void Reset(uint32_t data_length, int32_t error, uint64_t unique);
93 void ResetHeader(uint32_t data_length, int32_t error, uint64_t unique);
95}; 94};
96 95
96using FuseResponse = FuseResponseBase<kFuseMaxRead>;
97using FuseSimpleResponse = FuseResponseBase<0u>;
98
97// To reduce memory usage, FuseBuffer shares the memory region for request and 99// To reduce memory usage, FuseBuffer shares the memory region for request and
98// response. 100// response.
99union FuseBuffer final { 101union FuseBuffer final {