summaryrefslogtreecommitdiff
path: root/Utils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Expand virtio_block check to other virtual devicesHEADq10.0Alistair Delva2020-06-061-2/+34
| | | | | | | | | | | | | | | | | | | The Android Emulator isn't the only virtual device the virtio-block detection code is useful for, and those platforms might not set any discriminating properties to indicate that they are virtual. Rework the virtio-block major detection to use /proc/devices instead of hardcoding the assumption that any virtual platform can have virtio-block at any experimental major; the new code permits only the exact experimental major assigned to virtio-block. The new code runs everywhere, but it will only run once and could be expanded later to detect dynamic or experimental majors. Bug: 156286088 Change-Id: Ieae805d08fddd0124a397636f04d99194a9ef7e5 Merged-In: Ieae805d08fddd0124a397636f04d99194a9ef7e5 (cherry picked from commit d3c230b5c9ba6e242c0a6b290a185517f2c118e8)
* vold: add support for more filesystems for public storageDan Pasanen2020-04-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add exfat and ntfs support based off f2fs and ported to use fuse * Add support for both along with f2fs and ext4 to PublicVolume * Also attempt to mount any volume if it's been determined that the kernel supports it Change-Id: I0a83761cefd97791e3ec84a18e199dfd27a5ed0b vold: fs: Fix build errors * Migrate from base to android-base * Add missing , in Ext4 Mount function [AdrianDC] Ignore unpatched ext4 arguments [mikeioannina] Update for Pie native exfat Change-Id: I875b5763c472aa7da2976ec7c5db7cf28c913876 vold: ntfs: Use strlcat Clang now enforces length checking :/ Change-Id: I495b4cb2ee530e72b1084248f0549d63589523b0 Change-Id: I0a83761cefd97791e3ec84a18e199dfd27a5ed0b
* vold: Introduce android::vold::writeStringToFileTommy Chiu2019-03-261-0/+28
| | | | | | | | Remove static definition of writeStringToFile, and move it from KeyStorage to Utils Bug: 71810347 Change-Id: I38bfd27370ac2372e446dc699f518122e73c6877
* Ignore if the dir we are trying remove doesn't exist.Sudheer Shanka2019-02-251-1/+1
| | | | | | Fixes: 126208830 Test: manual Change-Id: I34788ebb2dd42e62ee3061f7d81dc03047048c3b
* Don't delete /mnt/user/<userId>/package on reset.Sudheer Shanka2019-02-221-11/+14
| | | | | | | | | | We need this to stay mounted at /storage. Bug: 124466384 Test: manual Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I0cc835471ced2822d83d7056bec53d62ddc682f0
* Ignore EEXIST errors when creating pkg specific dirs.Sudheer Shanka2019-02-191-1/+1
| | | | | | | | | | | Some of the pkg specific dirs could be created by zygote and vold in parallel, so ignore any EEXIST errors while creating these dirs. Bug: 118185801 Test: manual Change-Id: Ifaa9998131764304867ac027af335414dbfc291c
* Revert "Revert "Ensure necessary external storage dirs while creating ↵Sudheer Shanka2019-02-141-0/+20
| | | | | | | | | | sandboxes."" This reverts commit 88114b2a563d5bbbc68a16566e223797f4136227. Reason for revert: blocking issue in b/124345887 is resolved Change-Id: Ie34843c12b7a471d2384b64ad049ede63aed09e8
* Revert "Ensure necessary external storage dirs while creating sandboxes."Jeff Sharkey2019-02-141-20/+0
| | | | | | | | This reverts commit 083377e593429a6db7d64de69dcc9d7209f0f66d. Reason for revert: b/124345887 Change-Id: I388d45fab68b611917464a204269a48bf771ac57
* Ensure necessary external storage dirs while creating sandboxes.Sudheer Shanka2019-02-131-0/+20
| | | | | | | | | | Bug: 124058579 Test: manual Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I0e62de38e9ceff80df75e253443af69d4391a49e
* Remove sandbox specific bind mounts from root namespace.Sudheer Shanka2019-02-061-2/+25
| | | | | | | | | | | | | | | | Update vold to only create package sandboxes and not do any bind mounts. After zygote forks, all the necessary bind mounts will be setup for the process. Bug: 124009234 Test: manual Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest MediaProviderTests Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: Ia42209cb74cbc423bb09c1c51cb7a164f7c568da
* Merge "Fix search for values in blkId output" am: 0fbc5af676 am: 56715503b5Paul Crowley2019-02-051-5/+8
|\ | | | | | | | | | | am: 464ff37019 Change-Id: I5d47ddedc29cafa05424e6bfcfd6b99885614d7c
| * Fix search for values in blkId outputPaul Crowley2019-02-051-5/+8
| | | | | | | | | | | | | | Bug: 122497152 Test: atest tests/Utils_test.cpp Test: adb shell sm partition disk:7,32 private ; adb logcat -d Change-Id: Ic7d32bdbc0c55ce1d21f7f9e74c6a6fb3dcf332a
* | Merge "Utils: correctly handle read() errors in ReadRandomBytes()" am: ↵Eric Biggers2019-01-221-1/+1
|\| | | | | | | | | | | | | | | a2bd436594 am: 038a274e8a am: e5296cc04d Change-Id: I0f81be91efee4512510d9e0422b96d8e75951cd4
| * Utils: correctly handle read() errors in ReadRandomBytes()Eric Biggers2019-01-181-1/+1
| | | | | | | | | | | | | | read() returns -1 on error, so we need to use a signed type. Test: Booted device with FDE Change-Id: Ib44247c1cdfd38674a7439209e333823f2fb6cf8
* | Update VolumeManager to use UnmountTreeWithPrefix.Sudheer Shanka2019-01-171-1/+1
| | | | | | | | | | | | Bug: 122905493 Test: manual Change-Id: Ia6aa1d400277a76dfd2c1db87c613d7e692b0b5c
* | Merge "Add UnmountTreeWithPrefix util method." am: 2e9aafb620 am: 5e10de1301Sudheer Shanka2019-01-171-3/+46
|\| | | | | | | | | | | am: 8bdc5e6de8 Change-Id: I0c3a14b70c07a6b97cb429350eda653f6fb5954a
| * Add UnmountTreeWithPrefix util method.Sudheer Shanka2019-01-171-3/+46
| | | | | | | | | | | | | | | | | | Add a utility method to unmount all mountpoints that start with a prefix. Bug: 122905493 Test: manual Change-Id: I11739e40e7849c1b4ca9e0b90c5c3f243691257a
* | Merge "Fsync directories after creating files" am: a892eb154e am: 7c21f0a999Paul Crowley2019-01-071-0/+18
|\| | | | | | | | | | | am: ac6adb1763 Change-Id: I386c3d94163037e0fdb1035bba6850e15ca85183
| * Fsync directories after creating filesPaul Crowley2019-01-071-0/+18
| | | | | | | | | | | | | | Bug: 120248692 Test: adb shell locksettings set-pin 1111 && \ adb shell "echo b > /proc/sysrq-trigger" Change-Id: I53d252942c21365983b4f8b6e0948b1864f195c1
* | Merge "Check for errors in dup2" am: b1166633b6 am: 1d5d475b51Paul Crowley2018-12-071-1/+4
|\| | | | | | | | | | | am: 7748fcf911 Change-Id: Idfb0af866594647a43832d1cbc1b7a597f139144
| * Check for errors in dup2Paul Crowley2018-12-071-1/+4
| | | | | | | | | | | | Bug: 26735063 Test: adb shell sm partition disk:7,3 private && adb logcat -d Change-Id: I3aa8d1f6183dd5e77f54f422482a54ea8197d768
* | Merge "Do lazy-unmount to /storage directly" am: 53b0d95903 am: fbc24b5c8fPaul Crowley2018-12-061-21/+2
|\| | | | | | | | | | | am: 0bafc3b2c5 Change-Id: Icffe008b85b59357a743cd19f28fe5bb97722895
| * Merge "Do lazy-unmount to /storage directly"Paul Crowley2018-12-071-21/+2
| |\
| | * Do lazy-unmount to /storage directlyLongPing.WEI2018-12-061-21/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From man 2 umount: MNT_DETACH (since Linux 2.4.11) Perform a lazy unmount: make the mount point unavailable for new accesses, immediately disconnect the filesystem and all filesystems mounted below it from each other and from the mount table, and actually perform the unmount when the mount point ceases to be busy. So we don't need to unmount the filesystems under it one by one. Bug: 113796163 Test: atest android.appsecurity.cts.PermissionsHostTest#testInteractiveGrant23 Change-Id: I6a0422466a9865ff6d17122505ca73d041de9d54
* | | Merge "Clean up use of pipe" am: a33b765ca0 am: 1ca8af7badPaul Crowley2018-12-061-11/+7
|\| | | | | | | | | | | | | | | | | am: 99eb646b36 Change-Id: If084318f245412aa617aec2503308aa3b590eacb
| * | Clean up use of pipePaul Crowley2018-12-061-11/+7
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't duplicate what's already in unique_fd.h Also, code that tries to handle weird stdout condition won't work because of cloexec; just don't try that. My tests: - Ensure Marlin device boots and vold_prepare_subdirs is called successfully - Try adb shell sm set-virtual-disk true, see that eg sgdisk output is logged. Bug: 26735063 Bug: 113796163 Test: details in commit Change-Id: I5698ba0b4c8bd692a740a1bd445e677ad4815d11
* | Merge "Refactor ForkExecvp to improve locking behaviour" am: 6aaedb0dca am: ↵Paul Crowley2018-12-061-82/+70
|\| | | | | | | | | | | | | | | 12d8d6343b am: 1369936cb4 Change-Id: If1bb4a4bc0670346caf1d3909062ab70b3afe521
| * Refactor ForkExecvp to improve locking behaviourPaul Crowley2018-12-061-82/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do our own fork/exec rather than using a library. This leads to many improvements: - unite the output recording path with the other path - never concatenate arguments with spaces - never use the shell - move setexeccon after fork, so we don't need to take the lock - general code refactor while we're there My tests: - Ensure Marlin device boots and vold_prepare_subdirs is called successfully - Try adb shell sm set-virtual-disk true, see that eg sgdisk output is logged. weilongping@huawei.com's tests: - unlock a user's de and ce directory; - connect to a OTG storage device or a sdcard and ensure the mount logic be successful Bug: 26735063 Bug: 113796163 Test: details in commit Change-Id: I0976413529d7cbeebf5b8649660a385f9b036f04
* | Merge "Use setmntent with "e" option" am: 396040ca2c am: a92bdeb7f5LongPing.WEI2018-11-281-1/+1
|\| | | | | | | | | | | am: 2255cf528f Change-Id: Ibc84f3b9d2dc8ab0707b354d64529434355f36d6
| * Use setmntent with "e" optionLongPing.WEI2018-11-231-1/+1
| | | | | | | | | | | | Otherwise it will cause selinux warning in children processes sometimes Change-Id: I41239c3f9779140622076c644a5f63051d00eaa8
| * Wait for dm device to be ready before formatPaul Crowley2018-11-051-0/+19
| | | | | | | | | | | | | | | | | | | | | | It can sometimes take a moment for the dm-device to appear after creation, causing operations on it such as formatting to fail. Ensure the device exists before create_crypto_blk_dev returns. Test: adb sm set-virtual-disk true and format as adoptable. Bug: 117586466 Change-Id: Id8f571b551f50fc759e78d917e4ac3080e926722 Merged-In: Id8f571b551f50fc759e78d917e4ac3080e926722
* | Avoid double close in delete_dir_contents.Josh Gao2018-11-051-1/+2
| | | | | | | | | | | | | | | | fdopendir takes ownership of the file descriptor, leading to it being closed by both unique_fd's destructor and closedir. Test: treehugger Change-Id: Ibd193e988c77c5323720531445f334c0795c68b9
* | Wait for dm device to be ready before formatPaul Crowley2018-11-021-0/+19
| | | | | | | | | | | | | | | | | | | | It can sometimes take a moment for the dm-device to appear after creation, causing operations on it such as formatting to fail. Ensure the device exists before create_crypto_blk_dev returns. Test: adb sm set-virtual-disk true and format as adoptable. Bug: 117586466 Change-Id: Id8f571b551f50fc759e78d917e4ac3080e926722
* | Bind mount pkg specific dirs in the zygote child namespaces.Sudheer Shanka2018-09-271-0/+70
|/ | | | | | | | | | | | | | | - Also update vold to create sandboxes for secondary storage devices. - Since bind mounts are created in the process specific namespaces, we don't need /mnt/storage anymore which we were using it to prevent some bind mounts from propagating onto /mnt/runtime/write. - Create bind mounts for {media,obb} dirs similar to data dir in per process namespace. - Also fix a bug where we are not passing correct packages to vold when a new user starts. Bug: 111890351 Test: manual Change-Id: I7849efc4fbf3c654606fa30de7ab2de0236d766f
* Add unmountTree to utils.Sudheer Shanka2018-09-271-0/+30
| | | | | | Bug: 111890351 Test: builds without any errors Change-Id: I62a94c9e8d101756b686b402774f08a1d71cf875
* Merge changes from topic "exfat-update"Treehugger Robot2018-09-241-6/+38
|\ | | | | | | | | | | * changes: Use exFAT for SDXC cards Add GetBlockDevSize, GetBlockDevSectors helpers
| * Add GetBlockDevSize, GetBlockDevSectors helpersOleksiy Avramchenko2018-09-241-6/+38
| | | | | | | | | | | | | | | | | | | | | | Helpers to get a block device size in bytes or 512 byte sectors, using BLKGETSIZE64 and returning value of uint64_t type. This also removes get_blkdev_size(). Test: build, manual, mount exFAT volume Bug: 80202067 Change-Id: Ib07e8ac6ef7ff49de0ed570d1fa202e8b558b80c
* | Update vold to log only debug or higher level messages.Sudheer Shanka2018-09-211-9/+9
|/ | | | | | | | | | This will allow adding lots of verbose logs which can be enabled only during local testing/debugging. Update the existing verbose level logs to debug level since we want those to be logged by default. Test: manual Change-Id: Ib05e2b6efa71308458d49affb6ed81d3975b28ab
* clang-format many files.Paul Crowley2018-09-181-58/+55
| | | | | Test: Format-only changes; treehugger suffices. Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
* Merge "Fix double close in GetTreeBytes."Josh Gao2018-06-081-3/+1
|\ | | | | | | | | | | am: 142702dc82 Change-Id: I1c9f259d4d372ef1a3c36a9f884e39b8003f7ff0
| * Fix double close in GetTreeBytes.Josh Gao2018-05-301-3/+1
| | | | | | | | | | | | | | | | calculate_dir_size closes the fd that it receives. Bug: http://b/80446935 Test: treehugger Change-Id: I56a428cd7eb78e56c55434628c1c7b2b87637c81
* | Fingerprint data is now stored in one of two ways depending on theAndreas Huber2018-01-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | shipping API version: For devices shipped before Android P nothing changes, data is stored under /data/system/users/<user-id>/fpdata/... Devices shipped from now on will instead store fingerprint data under /data/vendor_de/<user-id>/fpdata. Support for /data/vendor_de and /data/vendor_ce has been added to vold. Bug: 36997597 Change-Id: I615e90d1c9ab08e768a8713968fa043598a0a526 Test: manually
* | Convert vold_prepare_subdirs to C++Paul Crowley2017-10-241-12/+20
| | | | | | | | | | | | | | | | | | | | Minimize overhead in boot by replacing shell script invoked multiple times with a C++ program invoked once. Bug: 67901036 Test: create user, run adb shell ls -laZ /data/misc_ce/10; delete user and check logs. Change-Id: I886cfd6505cca1f5b5902f2071e13f48e612214d
* | Undo Utils dependency on VolumeManagerPaul Crowley2017-10-201-9/+11
| | | | | | | | | | | | | | | | I want to use Utils in another executable, so breaking this link. Bug: 25861755 Test: compiles (and boots, though that doesn't exercise changed code) Change-Id: I6bb447453bb370fefb7f2f3aceb459428bdee6a7
* | Introduce lock for SELinux process-level changes.Jeff Sharkey2017-10-181-0/+8
| | | | | | | | | | | | | | | | | | Used to protect process-level SELinux changes from racing with each other between multiple threads. Test: builds, boots Bug: 67041047 Change-Id: I242afed3c3eb7fba282f1f6b3bdb2d957417c7e8
* | Move to modern utility methods from android::base.Jeff Sharkey2017-10-171-42/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moves away from crufty char* operations to std::string utility methods, including android::base methods for splitting/parsing. Rewrite of how Process handles scanning procfs for filesystem references; now uses fts(3) for more sane traversal. Replace sscanf() with new FindValue() method, also has unit tests. Remove some unused methods. Switch almost everyone over to using modern logging library. Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.storage.cts.StorageManagerTest Test: cts-tradefed run commandAndExit cts-dev --abi armeabi-v7a -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AdoptableHostTest Bug: 67041047 Change-Id: I70dc512f21459d1e25b187f24289002b2c7bc7af
* | Be more C++. volume UUID should always be std::string.Paul Crowley2017-10-091-14/+14
|/ | | | | | Test: boots Bug: 67041047 Change-Id: I36d3944ae8de192703b9ee359900841b833fe3a1
* Zero memory used for encryuption keys.Pavel Grafov2017-08-101-4/+15
| | | | | | | | | | std::vector with custom zeroing allocator is used instead of std::string for data that can contain encryption keys. Bug: 64201177 Test: manually created a managed profile, changed it's credentials Test: manually upgraded a phone with profile from O to MR1. Change-Id: Ic31877049f69eba9f8ea64fd99acaaca5a01d3dd
* do not sleep if it is shutting downKeun-young Park2017-08-031-7/+8
|\ | | | | | | | | | | am: 375ac25773 Change-Id: I576040b0068c27b9c7abd880e390841ce80f9906
| * do not sleep if it is shutting downKeun-young Park2017-08-021-7/+8
| | | | | | | | | | | | | | | | | | | | - Various sleep(5) for vold shutdown can increase shutdown time a lot. - If it is shutting down, do not sleep at all. init will take care of active partitions if not unmounted. bug: 64143519 Test: reboot and check logs from vold, check if "ShutdownThread: Shutdown wait timed out" happens. Change-Id: I7cb91427ad2205fe23a054d255caf7ffdfd9f6c3