summaryrefslogtreecommitdiff
path: root/jni
AgeCommit message (Collapse)Author
2025-03-21Guard against race condition in CheckFdAccess Omar Eissa
We have been seeing reports where race condition was happening as a result of node deletion, while trying to check if an app has access to it. With this fix, we are making sure that the node won't be deleted after it was looked up and before checking the needed info on it. Bug: 374685576 Bug: 339567926 Bug: 396594195 Test: atest CtsMediaProviderTranscodeTests Flag: EXEMPT bugfix Change-Id: I91caba1ee65f7b6a9827253e9256f88bf16fb854
2025-02-26Merge "Fix C++23 build." into main am: cbf0c55236 am: 27239ab161 Elliott Hughes
Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/3499291 Change-Id: Ic7e50632f7e42a990124a5011f2cf049daf1c558 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2025-02-18Fix C++23 build. Elliott Hughes
libc++ is stricter about transitive includes for C++23. Change-Id: Ifd53f1f193c02aa71cfd9d73c8f06b40eccbf249
2025-02-14Merge "Check for modified upstream passthrough before using" into main Daniel Rosenberg
2025-02-13Make sure .picker_transcoded don't show to users Omar Eissa
Users were able to see .picker_transcoded directory when they show hidden files in Files app. Put checks in FuseDaemon to make sure that no operations are allowed on this directory. We only allowed access to MediaProvider which bypass fuse for such files access. Bug: 393979202 Test: Manual Flag: EXEMPT bugfix Change-Id: I8fd05894c0eef72e6545577a353880da75ffdd21
2025-02-11Check for modified upstream passthrough before using Daniel Rosenberg
Android requires changes to upstream passthrough to be able to use it successfully. If these changes are not present, do not use it. Bug: 376007121 Flag: EXEMPT bugfix Test: Boot mainline kernel without fuse_passthrough sysfs entry Device should not use upstream passthrough Change-Id: I051cf898bcc8825c43e36012c9baaaf248ca66d5
2025-01-07Revert^2 "Use Upstream Passthrough if available" Dipankar Bhardwaj
This reverts commit 685a81435ee1bfd8f7952deb1e39cdc14f65fd7e. Reason for revert: Putting back the changes after removal from M-11 Change-Id: I98d931ea94c784a1296942e05b9d8313301d3892
2025-01-02Revert "Use Upstream Passthrough if available" Dipankar Bhardwaj
This reverts commit e3a6f0d1940c3103da7d31ce9eb4d8c96d7c3390. Reason for revert: b/386302885 Change-Id: Ia5ab2c8b335318d1d7928c2a068f139b7bf1ac43
2024-12-05Merge "Modify FuseDaemon#DeriveVolumeName to better handle invalid paths." ↵ Riya Ghai
into main
2024-12-03Modify FuseDaemon#DeriveVolumeName to better handle invalid paths. “riyaghai”
Test: atest FuseUtilsTest.cpp Bug: 378021978 Flag: EXEMPT, bug fix Change-Id: I66c05397a1350c3fd1af52218f803e1202ed9b3d
2024-10-14Merge "Restrict invalid characters in file name" into main Darshil Shah
2024-10-11Restrict invalid characters in file name darshilshah
Certain unicodes are not getting correctly encoded and decoded by UTF-8 encoding. Adding a check to avoid filenames containing these characters. Bug: 263914218 Test: NA Flag: com.android.providers.media.flags.enable_unicode_check Change-Id: I67828d34adfbe3c8f3888f6cf265249e0715c974
2024-10-10Use Upstream Passthrough if available Daniel Rosenberg
The upstream kernel has merged in a version of Passthrough with a differing interface. If we detect that, use it, as Android's version of Passthrough will be unavailable. Change-Id: Ib6b0da7a8b4a7ddeadc4dcae0e26801947670a11 Test: atest android.scopedstorage.cts.general.ScopedStorageDeviceTest using mainline kernel Flag: EXEMPT (Controlled by flag supplied by fuse kernel module) Bug: 333497409
2024-10-01Add check on inode number before do_forget call Dipankar Bhardwaj
Some code flow with fuse bpf enabled can set inode number to 0. Adding a check to skip any crash in that case. Change-Id: I649b24ca95d7f5a9810f1247d30b0fadc1d4fba5 Test: n/a Bug: 367845222 Flag: EXEMPT bug fix
2024-09-19Merge "Add restore logic" into main Dipankar Bhardwaj
2024-09-18Add restore logic Dipankar Bhardwaj
Added restore code for restoring file metadata after restore operation of B&R. Any file scan after restore will check for presence of file in the leveldb backup file for metadata restore. A file metadata will be restored only if it has same size as the actual file. Test: atest RestoreExecutorTest Bug: 336793178 Flag: com.android.providers.media.flags.enable_backup_and_restore Change-Id: Iec6669f7b7d9afb92b2bd7c0b46d18914314d321
2024-09-09FuseDaemon: support RENAME_NOREPLACE rename Hobin Woo
Current FuseDaemon is incompatible with renaming a file with RENAME_NOREPLACE which does not allow a file to be renamed if newpath already exists. However, there's no reason to disallow this because checking EEXIST is already done in upper vfs kernel and thus it does not affect the behavior of FuseDaemon. Co-developed-by: Yoonho Shin <yoonho.shin@samsung.corp-partner.google.com> Signed-off-by: Hobin Woo <hobin.woo@samsung.corp-partner.google.com> (cherry picked from https://partner-android-review.googlesource.com/q/commit:af401d1ec047186dec7d0977069df8c02adde1d6) Merged-In: I0eed8a58efb6f61d916adc3f2596c63220ceb8ff Change-Id: I0eed8a58efb6f61d916adc3f2596c63220ceb8ff Flag: EXEMPT bug fix
2024-08-09FuseDaemon: don't fail on EINVAL when reading directory entries Martijn Coenen
This can happen when the filesystem is in a bad state, and we don't want to fail the entire directory listing. Bug: 314054393 Change-Id: I8da411e37cbb323c6080c498fb44cb76701e609d Test: N/A Flag: EXEMPT bugfix
2024-06-14Build fuse-related tests with static libc++ and version script Stephen Hines
Bug: http://b/344654921 Test: m fuse_node_test FuseUtilsTest RedactionInfoTest pdfClient_test Change-Id: I5e38d6bbeacb31cc36a104908a4f02d2f4566042
2024-06-10Merge "Move Stable Uris public volume to it's own FuseDaemon" into ↵ Aleksandr Lukin
udc-mainline-prod am: 9c2cf98d8c Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/27518620 Change-Id: I296ec605ba450815a3f8c1757632cec4dfcfc59c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-06-10Merge "Move Stable Uris public volume to it's own FuseDaemon" into ↵ Aleksandr Lukin
udc-mainline-prod
2024-06-06Move Stable Uris public volume to it's own FuseDaemon alukin
Moving the backing up of public volume data to it's own fuse daemon thread. This will reduce the load on the EXTERNAL_PRIMARY fuse daemon thread. Bug: 294741698 Test: manual + atest StableUriIdleMaintenanceServiceTest#testDataMigrationForPublicVolume Change-Id: I1e308914349b034a4824f1a24bce552d074a1687
2024-05-24Merge changes I7fd556a3,Ied969d3f into udc-mainline-prod am: efd429552f Omar Eissa
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/27384514 Change-Id: Ie2fa2b129a5115dd1bd2d1da7aacb1696ad0ba0d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-24Merge changes I7fd556a3,Ied969d3f into udc-mainline-prod Omar Eissa
* changes: Increase fuse daemon readdir buffer size to 32KB Optimize Fuse readdir performance
2024-05-23Merge changes I16f4814f,I1aba0c71,Ibfbcb0f6 into main am: 6d8fc99bfc am: ↵ Maciej Żenczykowski
20a5188ab9 Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/3098180 Change-Id: I03602165b6e388b789d2cb6ab960e7e64ea76fff Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-23Increase fuse daemon readdir buffer size to 32KB Omar Eissa
Bug: 171935194 Test: atest PerformanceTest#testDirOperations_1000 Change-Id: I7fd556a3476228509bc43f53ca55bc901d39bbc3
2024-05-23Optimize Fuse readdir performance yoonho.shin
do_lookup() executes cross-user check everytime which could be unnecessarily repeated over and over again in a readdir operation. We move the cross-user check to is_user_accessible_path(), and make it called once for a readdir operation. We can see 5% improvements in a readdir operation. Bug: 171935194 Test: atest PerformanceTest#testDirOperations_1000 Change-Id: Ied969d3f93a2647ab6ff341b3e8fa19ad6e2628e
2024-05-22Change BpfFd::REMOVE to -2 Patrick Rohr
Previously BpfFd::REMOVE conflicted with the "invalid value" of bpf_fd (which is initialized to -1 and set to -1 if retrieving the bpf program fails), so the else branch in fuse_bpf_fill_entries was effectively unreachable. Test: atest MediaProviderTests. This is obviously not covered by any tests. Can the owner team add test coverage? Change-Id: I16f4814f2a398613725d7db617f5f417e7d693f9
2024-05-22Update comment to explicitly mention backing_fd Patrick Rohr
This comment was confusing as both bpf_fd and backing_fd are used in this function. Test: n/a Change-Id: I1aba0c71d34af7346b9b977c08cd49bc2b144ddb
2024-05-22Use unique_fd version of BpfSyscallWrappers.h Patrick Rohr
We are trying to get rid of the int-based version, so convert FuseDaemon to using unique_fd. A few things that stuck out: - in the previous iteration, bpf_fd was never closed. - the else branch in fuse_bpf_fill_entries is never reachable. - if bpfFdGet() failed, the old code logged the fd (always -1) instead of the errno. - BpfFd::REMOVE (-1) happens to coincide with both the default value of bpf_fd if bpf_enabled is false, and the return value of bpfFdGet() if that call fails. This leads to an unreachable branch inside fuse_bpf_fill_entries(). Test: atest MediaProviderTests Change-Id: Ibfbcb0f6185c90ab8bae471571319902b4a3ecb4
2024-05-22Merge "Revert "Enable FUSE_CAP_PARALLEL_DIROPS"" into main Sahana Rao
2024-05-22FuseDaemon: return EXDEV when fuse files are renamed into fuse-bpf root Hobin Woo
It is allowed to rename from the fuse path to the root, data or obb, of the fuse-bpf path, however, it finally returns EBADF from the kernel since the file belongs to a fuse-bpf path not having any backing information. For the sake of compatibility, we just return EXDEV, the same as the case with renaming a file to a sub-directories within the fuse-bpf path (i.e., copy & unlink). Bug: 336656707 Test: N.A. Change-Id: I38a4968de0997f53a06d83594e85eb8fe94d2681 Merged-In: I38a4968de0997f53a06d83594e85eb8fe94d2681
2024-05-21Revert "Enable FUSE_CAP_PARALLEL_DIROPS" Sahana Rao
This reverts commit db5422b1ea8dab3bd86bb902a836cca99ca9cb66. Reason for revert: 319271902 Test: N.A. Change-Id: I50d7bdf6636fb693795eb42960b3da22aa954201
2024-05-21FuseDaemon: return EXDEV when fuse files are renamed into fuse-bpf root Hobin Woo
It is allowed to rename from the fuse path to the root, data or obb, of the fuse-bpf path, however, it finally returns EBADF from the kernel since the file belongs to a fuse-bpf path not having any backing information. For the sake of compatibility, we just return EXDEV, the same as the case with renaming a file to a sub-directories within the fuse-bpf path (i.e., copy & unlink). Bug: 336656707 Test: N.A. Change-Id: I38a4968de0997f53a06d83594e85eb8fe94d2681
2024-05-10Merge "Create leveldb manager code" into udc-mainline-prod am: 4045c284c1 Dipankar Bhardwaj
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/26818307 Change-Id: I6192aa4e95d71f406bdaac645b337e49f651a2b6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-10Create leveldb manager code Dipankar Bhardwaj
Added jni code to perform leveldb operations. Test is executed in fake mediaprovider and leveldb library is loaded for the same. Test: atest com.android.providers.media.leveldb.LevelDBProxyTest Bug: 336793168 Change-Id: Ib9821430d7494118ab3328efc317cb7f33082491
2024-05-02Merge "Connect to leveldb in lower fs" into udc-mainline-prod am: f2eab37361 Dipankar Bhardwaj
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/27053415 Change-Id: I1879aa41039bc84ec04abcd95601a6722ad76005 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02Merge "Connect to leveldb in lower fs" into udc-mainline-prod Dipankar Bhardwaj
2024-05-01Connect to leveldb in lower fs Dipankar Bhardwaj
Connecting to leveldb in upper fs results in delay in unmount due to existing nature of vold code. Unmount gets re-attempted in some scenarios causing a latency increase. Test: atest StableUriIdleMaintenanceServiceTest Bug: 335053149 Change-Id: I05549bd8cc11e3acbb14b6a1f2391bd2484820b5
2024-04-23Merge "Fix deadlock on reading file paths" into udc-mainline-prod am: 0c3347ef96 Dipankar Bhardwaj
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/26900868 Change-Id: I68a8910dd7ea6149eec8981462669cb3d44e3163 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-22Fix deadlock on reading file paths Dipankar Bhardwaj
On rollback, while recovering data from leveldb, we can end up in a deadlock when a thread tries to lock a mutex twice. Updating recover data logic to wait for external primary setup to complete before recovering. Also changing lock to re-entrant lock. Test: locally by triggering rollback Bug: 333528476 Change-Id: Ie7fcf01e5c2f5d50f851710f86377b2ff8a900bc
2024-04-03Merge "Disable attr cache and writeback cache on StubVolume and ARC ↵ Momoko Hattori
Downloads" into main
2024-03-22Disable attr cache and writeback cache on StubVolume and ARC Downloads Momoko Hattori
This patch does the following two things: - Set attribute timeout to 0 on paths for which ShouldNotCache is true. ShouldNotCache was introduced in ag/16386050 to disable cache on certain paths, and currently returns true if the path is on StubVolume or it's under /storage/emulated/0/Download (only in ARC). - Unset FUSE_CAP_WRITEBACK_CACHE if it's externally managed (`uncached_mode` is true) or if it's ARC. The `uncached_mode` paramter was introduced in ag/16386051 and is true only on StubVolumes. Because ARC's /data/media/0/Download is a bind-mount from /var/run/arc/media/MyFiles/Downloads (in StubVolume), ARC needs to disable it not only on StubVolume but also on EmulatedVolume. Bug: 304369618 Test: The test ag/16622273 shows the correct result on both MyFiles and Download(s). Change-Id: Iaefa204858f31b17d65d4bb106debea1534e8ca6
2024-03-13Merge "Fix stable uris unmount race condition" into udc-mainline-prod am: ↵ Aleksandr Lukin
c45dd99e93 Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/26460928 Change-Id: Ib54a096774d9bcc068b1e1787e929eb388e2d303 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-12Fix stable uris unmount race condition alukin
Currently when vold unmounts a volume, we remove the level db connection pointers from fuse. It causes the methods that were already in execution to fail. Adding a lock to all methods that interact with connections map to prevent such failures. Bug: 327604826 Test: atest StableUriIdleMaintenanceServiceTest Change-Id: I45da84ae30b4f98190f2c15900d72ccf480f5193
2024-03-04Handle case of fully redacted readdir request am: be11b14a78 Daniel Rosenberg
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/26422491 Change-Id: Iac3ed7c0016e480d3b2b15587b2b4a2df4ec220e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-29Handle case of fully redacted readdir request Daniel Rosenberg
If a readdir comes in where each entry is redacted, we must signal that there may be more to come by setting 'again'. Test: Create many redacted folders, and a single unredacted Observe output of ls Bug: 325550828 Change-Id: Ie55c782a1dd95a625cf52f64786d8fdded5ceb70
2024-02-29Use updated headers in libfuse Paul Lawrence
Size field is no longer needed by the kernel Bug: 316860292 Test: Can create 200 dirs in /storage/emulated/0/Android/data atest ScopedStorageDeviceTest passes Change-Id: I097493bd8ce5c4fbff535922844a9416fad16466 Merged-In: I097493bd8ce5c4fbff535922844a9416fad16466
2024-02-23Merge changes from topic "dir_fix" into main am: e2a69a047e Treehugger Robot
Original change: https://android-review.googlesource.com/c/platform/packages/providers/MediaProvider/+/2886331 Change-Id: I976a4f1b0924d28f70e103d327dc8921ec1115b4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-23Use updated headers in libfuse Paul Lawrence
Size field is no longer needed by the kernel Bug: 316860292 Test: Can create 200 dirs in /storage/emulated/0/Android/data atest ScopedStorageDeviceTest passes Change-Id: I097493bd8ce5c4fbff535922844a9416fad16466 Merged-In: I097493bd8ce5c4fbff535922844a9416fad16466