From 3d95d88b14ce1272202a866296258dcd3a1a85ce Mon Sep 17 00:00:00 2001 From: Ryo Hashimoto Date: Wed, 14 Mar 2018 19:24:47 +0900 Subject: [PATCH] Stop using SO_SNDBUFFORCE Use SO_SNDBUF which doesn't require CAP_NET_ADMIN instead. Change the value of kFuseMaxWrite to 128KB. In the kernel code, there is a constant FUSE_MAX_PAGES_PER_REQ which limits the size of requests to 128KB. Bug: 74725300 Test: atest android.os.storage.cts.StorageManagerTest Change-Id: Ic3a8f1a7378d027a6c0ee054cedc2c9f4b7509ad --- libappfuse/FuseBuffer.cc | 4 ++-- libappfuse/include/libappfuse/FuseBuffer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libappfuse/FuseBuffer.cc b/libappfuse/FuseBuffer.cc index 1eab46cb4..1915f22ba 100644 --- a/libappfuse/FuseBuffer.cc +++ b/libappfuse/FuseBuffer.cc @@ -149,8 +149,8 @@ bool SetupMessageSockets(base::unique_fd (*result)[2]) { } constexpr int kMaxMessageSize = sizeof(FuseBuffer); - if (setsockopt(fds[0], SOL_SOCKET, SO_SNDBUFFORCE, &kMaxMessageSize, sizeof(int)) != 0 || - setsockopt(fds[1], SOL_SOCKET, SO_SNDBUFFORCE, &kMaxMessageSize, sizeof(int)) != 0) { + if (setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, &kMaxMessageSize, sizeof(int)) != 0 || + setsockopt(fds[1], SOL_SOCKET, SO_SNDBUF, &kMaxMessageSize, sizeof(int)) != 0) { PLOG(ERROR) << "Failed to update buffer size for socket"; return false; } diff --git a/libappfuse/include/libappfuse/FuseBuffer.h b/libappfuse/include/libappfuse/FuseBuffer.h index 7a70bf3b4..30638155f 100644 --- a/libappfuse/include/libappfuse/FuseBuffer.h +++ b/libappfuse/include/libappfuse/FuseBuffer.h @@ -25,7 +25,7 @@ namespace fuse { // The numbers came from sdcard.c. // Maximum number of bytes to write/read in one request/one reply. -constexpr size_t kFuseMaxWrite = 256 * 1024; +constexpr size_t kFuseMaxWrite = 128 * 1024; constexpr size_t kFuseMaxRead = 128 * 1024; constexpr int32_t kFuseSuccess = 0;