summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaichi Hirono2016-11-09 18:41:54 -0600
committerDaichi Hirono2016-11-15 19:56:00 -0600
commit471ad6a59d4ab765a5e93d5dd557057e88858974 (patch)
tree2cba6ec0c0772b8ebb049df9e2383cc55f90d5cc /libappfuse/FuseBuffer.cc
parentb5ce6f02dd11b42c03884dd9531c6c8a80bcecda (diff)
downloadplatform-system-core-471ad6a59d4ab765a5e93d5dd557057e88858974.tar.gz
platform-system-core-471ad6a59d4ab765a5e93d5dd557057e88858974.tar.xz
platform-system-core-471ad6a59d4ab765a5e93d5dd557057e88858974.zip
Use FUSE_COMPAT_22_INIT_OUT_SIZE always if available.
We return the minor version number 15 to FUSE_INIT since we don't handle BATCH_FORGET. Thus the kernel does not accept the latest size of fuse_init_out. Instead we need to use FUSE_COMPAT_22_INIT_OUT_SIZE. Bug: 32779923 Test: libappfuse_test Change-Id: I5c979d0e45344ca8adfe3ad3f4a9561442abcb3a
Diffstat (limited to 'libappfuse/FuseBuffer.cc')
-rw-r--r--libappfuse/FuseBuffer.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/libappfuse/FuseBuffer.cc b/libappfuse/FuseBuffer.cc
index 45280a5cf..5f4c1f843 100644
--- a/libappfuse/FuseBuffer.cc
+++ b/libappfuse/FuseBuffer.cc
@@ -101,23 +101,18 @@ void FuseBuffer::HandleInit() {
101 return; 101 return;
102 } 102 }
103 103
104 // We limit ourselves to 15 because we don't handle BATCH_FORGET yet 104 // We limit ourselves to minor=15 because we don't handle BATCH_FORGET yet.
105 size_t response_size = sizeof(fuse_init_out); 105 // Thus we need to use FUSE_COMPAT_22_INIT_OUT_SIZE.
106#if defined(FUSE_COMPAT_22_INIT_OUT_SIZE) 106#if defined(FUSE_COMPAT_22_INIT_OUT_SIZE)
107 // FUSE_KERNEL_VERSION >= 23. 107 // FUSE_KERNEL_VERSION >= 23.
108 108 const size_t response_size = FUSE_COMPAT_22_INIT_OUT_SIZE;
109 // If the kernel only works on minor revs older than or equal to 22, 109#else
110 // then use the older structure size since this code only uses the 7.22 110 const size_t response_size = sizeof(fuse_init_out);
111 // version of the structure.
112 if (minor <= 22) {
113 response_size = FUSE_COMPAT_22_INIT_OUT_SIZE;
114 }
115#endif 111#endif
116 112
117 response.Reset(response_size, kFuseSuccess, unique); 113 response.Reset(response_size, kFuseSuccess, unique);
118 fuse_init_out* const out = &response.init_out; 114 fuse_init_out* const out = &response.init_out;
119 out->major = FUSE_KERNEL_VERSION; 115 out->major = FUSE_KERNEL_VERSION;
120 // We limit ourselves to 15 because we don't handle BATCH_FORGET yet.
121 out->minor = std::min(minor, 15u); 116 out->minor = std::min(minor, 15u);
122 out->max_readahead = max_readahead; 117 out->max_readahead = max_readahead;
123 out->flags = FUSE_ATOMIC_O_TRUNC | FUSE_BIG_WRITES; 118 out->flags = FUSE_ATOMIC_O_TRUNC | FUSE_BIG_WRITES;