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/FuseBuffer.cc
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/FuseBuffer.cc')
-rw-r--r--libappfuse/FuseBuffer.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/libappfuse/FuseBuffer.cc b/libappfuse/FuseBuffer.cc
index 45280a5cf..ca47aa8c7 100644
--- a/libappfuse/FuseBuffer.cc
+++ b/libappfuse/FuseBuffer.cc
@@ -26,6 +26,7 @@
26#include <android-base/macros.h> 26#include <android-base/macros.h>
27 27
28namespace android { 28namespace android {
29namespace fuse {
29 30
30template <typename T, typename Header> 31template <typename T, typename Header>
31bool FuseMessage<T, Header>::CheckHeaderLength() const { 32bool FuseMessage<T, Header>::CheckHeaderLength() const {
@@ -44,7 +45,7 @@ bool FuseMessage<T, Header>::CheckResult(
44 return true; 45 return true;
45 } else { 46 } else {
46 PLOG(ERROR) << "Failed to " << operation_name 47 PLOG(ERROR) << "Failed to " << operation_name
47 << " a packet from FD. result=" << result << " header.len=" 48 << " a packet. result=" << result << " header.len="
48 << header.len; 49 << header.len;
49 return false; 50 return false;
50 } 51 }
@@ -68,6 +69,14 @@ bool FuseMessage<T, Header>::Write(int fd) const {
68template struct FuseMessage<FuseRequest, fuse_in_header>; 69template struct FuseMessage<FuseRequest, fuse_in_header>;
69template struct FuseMessage<FuseResponse, fuse_out_header>; 70template struct FuseMessage<FuseResponse, fuse_out_header>;
70 71
72void FuseRequest::Reset(
73 uint32_t data_length, uint32_t opcode, uint64_t unique) {
74 memset(this, 0, sizeof(fuse_in_header) + data_length);
75 header.len = sizeof(fuse_in_header) + data_length;
76 header.opcode = opcode;
77 header.unique = unique;
78}
79
71void FuseResponse::ResetHeader( 80void FuseResponse::ResetHeader(
72 uint32_t data_length, int32_t error, uint64_t unique) { 81 uint32_t data_length, int32_t error, uint64_t unique) {
73 CHECK_LE(error, 0) << "error should be zero or negative."; 82 CHECK_LE(error, 0) << "error should be zero or negative.";
@@ -133,4 +142,5 @@ void FuseBuffer::HandleNotImpl() {
133 response.Reset(0, -ENOSYS, unique); 142 response.Reset(0, -ENOSYS, unique);
134} 143}
135 144
145} // namespace fuse
136} // namespace android 146} // namespace android