Commit graph

16 commits

Author SHA1 Message Date
Ryo Hashimoto
3d95d88b14 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
2018-03-15 14:22:27 +09:00
Daichi Hirono
a6dee5e279 Add volatile to temporary variable.
FuseBuffer::HandleNotImpl save the value of |request.header.unique| to the
temporary variable, clear the buffer which is a union of |request| and
|response|, then write back the unique value to response.header.unique.

Before the CL, the temporary variable was wrongly removed by the compiler
optimization, and response.header.unique was always 0. The CL adds
volatile modifier as workaround to prevent the compiler optimization
from removing the temporary value.

Bug: 62429763
Test: libappfuse_tests
Change-Id: Ia853f805633f646f316f585a35c7b018000b6eb3
2017-06-23 11:23:12 +09:00
Daichi Hirono
e5a1556d40 Add more logs for writing failures.
Bug: 62429763
Test: libappfuse_test
Change-Id: Ie0eabd09ae9ad3f8ba8c4f38f871dad16b5c58ff
2017-06-12 10:37:08 +09:00
TreeHugger Robot
bf6e949727 Merge "Change the CHECK failure into function failure." into oc-dev 2017-05-17 03:22:27 +00:00
Daichi Hirono
3df060d6d0 Change the CHECK failure into function failure.
Previously we have CHECK in WriteInternal function to observe short
writing. However it turns out short write can happen according to the
bug report.

To prevent app from crashing due to CHECK failure, the CL removes the
CHECK and let WriteInternal return a failure value.

Bug: 37561460
Test: libappfuse_tests, manually re-wrote the return value of write()
      and checked logcat.
Change-Id: I6a1e233c3ddb8eb68f59e7c606ad0459b5ca2c6e
2017-05-17 10:30:02 +09:00
Daichi Hirono
287776ddf4 Use SO_SNDBUFFORCE instead of SO_SNDBUF
When /proc/sys/net/core/wmem_max is smaller than kMaxMessageSize, we
need to override the limitation.

Bug: 37561460
Test: libappfuse_tests

Change-Id: Ibaac8db61290d661459fdc46f0ae8416f7db1d9e
2017-04-28 17:03:06 +09:00
Daichi Hirono
6f6210dd5c Retry write operation when getting ENOBUFS.
Previously libappfuse set SO_SNDBUF to the maximum message size. However
it does not prevent ENOBUF and it made AppFusePerfTest#testReadWriteFile
flaky.

The CL let FuseBuffer retry write operation when getting ENOBUFS.

Bug: 34903085
Test: libappfuse
Change-Id: I1602474d852e1599f6e69103bcf6f18277a5644b
2017-03-31 01:50:50 +00:00
Daichi Hirono
0bb22bd50e 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
2017-03-23 01:04:15 +00:00
Daichi Hirono
57b780fbc3 Add ReadOrAgain and WriteOrAgain methods to FuseMessage.
These methods return kAgain if operation cannot be done without blocking
the current thread.

The CL also introduecs new helper function SetupMessageSockets so that
FuseMessages are always transfered via sockets that save message
boundaries.

Bug: 34903085
Test: libappfuse_test
Change-Id: I34544372cc1b0c7bc9622e581ae16c018a123fa9
2017-03-14 09:09:29 +09:00
Daichi Hirono
cb9153bf43 Support SOCK_STREAM for bridge between system and app
Previously AppFuse use SOCK_SEQPACKET for sockets communicating system
and app. However SOCK_SEQPACKET requires the buffer of message size in
the kernel and sometimes failed to write with ENOBUF.

The CL updates libappfuse so that it can use SOCK_STREAM instead of
SOCK_SEQPACKET.

Bug: 33279206
Test: libappfuse_test
Change-Id: I622ada9ac1d71d0c57b6cfff0904c7829cea7995
2016-12-12 14:53:03 +09:00
Daichi Hirono
a6373ec1d4 Fix checks for reading and writing FuseMessage.
Previously FuseMessage were checking result of read/write operation
after checking header.len value is valid. This was wrong because
header.len does not contain correct value when read function does not
read any bytes and returns zero.

Bug: 33278098
Test: libappfuse_test
Change-Id: Icf998ca6c3eeee20cbc4aa2f65195a87e59ffc27
2016-12-12 14:34:29 +09:00
Treehugger Robot
c884f80755 Merge "Use FUSE_COMPAT_22_INIT_OUT_SIZE always if available." 2016-11-16 03:57:46 +00:00
Daichi Hirono
471ad6a59d 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
2016-11-16 01:56:00 +00:00
Daichi Hirono
0d97be4d7d Add static assert to check if FuseBuffer is standard layout union.
Bug: 32260320
Test: libappfuse_test
Change-Id: I6430c11fdeb2405996410c97044b4260c25209b8
2016-11-15 10:18:37 +09:00
Daichi Hirono
a0aecda12b 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
2016-11-15 09:47:31 +09:00
Daichi Hirono
c613476297 Add FuseBridgeLoop to libappfuse.
The CL adds FuseBridgeLoop class to libappfuse, which is used in the
system service to proxy fuse commands to applications.

Bug: 29970149
Test: libappfuse_test
Change-Id: I0708f608b3868721ab16ba4028fd2c17a6735af7
2016-10-27 15:04:15 +09:00
Renamed from libappfuse/AppFuse.cc (Browse further)