Commit graph

52 commits

Author SHA1 Message Date
Eric Biggers
a6957c0f7a Rename fscrypt_is_native() to IsFbeEnabled()
Now that emulated FBE is no longer supported, there is no longer any
distinction between native FBE and emulated FBE.  There is just FBE.

Referring to FBE as "fscrypt" is also poor practice, as fscrypt (the
Linux kernel support for filesystem-level encryption) is just one part
of FBE, the Android feature.

Therefore, rename fscrypt_is_native() to IsFbeEnabled().

Bug: 232458753
Change-Id: Idf4cb25d37bc3e81836fcc5a1d96f79ccfa443b7
2022-06-15 18:52:18 +00:00
Jaegeuk Kim
f6151b434c Support zoned device with dm-default-key
Note that, encrypt_inplace cannot support zoned device, since it
doesn't support in-place updates. And, dm-default-key will have
a different key.

Bug: 172378121
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I34cb1e747e0f3faa07c5a4bfeded11fb789a033c
2022-06-07 18:43:54 -07:00
Jaegeuk Kim
2b8957dce6 Use make_f2fs -g android by default
It enables encrypt, proejct_quota, verity by default.

Bug: 225401790
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I6c6dc81b8e62b20b0107d40a9ed5b645cdafbda1
2022-03-22 17:54:40 -07:00
Shikha Malhotra
8acf8298f9 Merge "Enable ProjectID for the file systems by default." 2022-03-22 16:32:40 +00:00
Eric Biggers
0d12fd668d Stop using -Wno-unused-variable
This is a useful warning, so remove two unused variables and stop
disabling this warning.

Change-Id: I3efe0b300ea139ea11d645dec6fb2613acc0e51b
2022-03-10 20:17:23 +00:00
Shikha Malhotra
f7bc4958c4 Enable ProjectID for the file systems by default.
This is in conjunction with enabling the project id for internal directories. The check whether project ids should be used or not, is done in installd process. If they cannot be used, then the installd process falls back to previous approaches.

Bug: b/215154615
Test: atest installd/StorageHostTest
Test: atest installd/installd_service_test.cpp
Change-Id: I2c6672640295ebbc5ec78075290fc8e8703384ef
2022-02-04 15:32:31 +00:00
Treehugger Robot
313e8556a6 Merge "Add timeout for fsck on untrusted media" 2022-01-26 08:55:08 +00:00
Daniel Rosenberg
d9261b1f0b Add timeout for fsck on untrusted media
Certain setups of cards can take a long time to fsck.
This adds a timeout to avoid angering the watchdog

Bug: 195615825
Test: Mount removable storage with ~30K folders,
      obeserve timeout in logs
Change-Id: I8b6e2658cf7024645f976599851bbee0557745ca
2021-09-22 18:08:28 -07:00
lin.gui
3101ac01ac Fix the incorrect parameter quota when userdata is formatted with EXT4
The userdata will be formatted by VOLD during bootup when the userdata
is not completed file system(EXT4 or F2FS).
For EXT4 on userdata and quota feature is enabled. the parameter quota
is incorrect in ext4::Format(). Change the parameter from
quotatype=prjquota to quotatype=usrquota:grpquota:prjquota.

Bug: 199802158
Test: run cts-on-gsi -m CtsAppSecurityHostTestCases -t
      android.appsecurity.cts.StorageHostTest

Change-Id: Ibff10e8e67b4e6ffabea97f534ff6551aed91963
2021-09-14 02:05:27 +00:00
Jaegeuk Kim
2c1380f1ab mkfs_f2fs: give the log in kernel
It's very useful to see the mkfs log in console to debug any issues.

Bug: 172378121
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Icdac3609860cf0bba3fa758cead885bd4960f2c0
2021-04-15 20:24:04 -07:00
LuK1337
b8e07b20ad Switch to exfatprogs compatible fsck parameter
exfatprogs accepts 'y' for no interaction repair.

Change-Id: I2c436816a293a36fc9f0cd635cdb9ca3b5f88bfc
2020-11-11 19:45:05 +01:00
Martijn Coenen
c41ac2f3d7 Rename casefold/projectid properties (for f2fs). am: e9239f757e
Change-Id: Ib895adcd495dd3dc4e9d675d1990d04b173a1b14
2020-04-17 14:41:07 +00:00
Martijn Coenen
729c26033e Merge "Rename casefold/projectid properties." am: 9d0508a854 am: 5901d6f492
Change-Id: Ic9982c15351008ff686f9bf395ae8f3b4adcdb30
2020-04-16 08:35:08 +00:00
Martijn Coenen
e9239f757e Rename casefold/projectid properties (for f2fs).
According to property naming guidelines.

Bug: 152170470
Bug: 153525566
Test: N/A
Change-Id: Iad1caff6e5cfb7f6a09b77532d64a24de9b0b3c6
2020-04-16 10:18:36 +02:00
Martijn Coenen
aee6b6fccd Rename casefold/projectid properties.
According to property naming guidelines.

Bug: 152170470
Bug: 153525566
Test: N/A
Change-Id: Iaebff2a835288839a2faf0edbe0e47ceb96b4458
Merged-In: Iaebff2a835288839a2faf0edbe0e47ceb96b4458
2020-04-16 10:18:30 +02:00
Martijn Coenen
97ff0845e2 Rename casefold/projectid properties.
According to property naming guidelines.

Bug: 152170470
Bug: 153525566
Test: N/A
Change-Id: Iaebff2a835288839a2faf0edbe0e47ceb96b4458
2020-04-15 17:29:21 +02:00
Jaegeuk Kim
d6cf8998e2 vold: support F2FS compression am: f64d30aa82 am: 0770085201
Change-Id: I3bef3bef7704f7ef12a8774064ec1382fa4801d1
2020-04-14 16:09:24 +00:00
Jaegeuk Kim
f64d30aa82 vold: support F2FS compression
Bug: 134580167
Change-Id: Iadd001dc5ce0f91a4337f5b27ea8cc54f9760b0d
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-04-03 14:02:14 -07:00
Martijn Coenen
2f1c983240 Add quota / casefold options to f2fs if needed.
These were only added for ext4.

Bug: 150935323
Test: when creating a private f2fs volume, things work as expected.
Change-Id: I11ee04bfddecb6c95e223e66c9bf532c425e6fac
2020-03-11 15:36:14 +01:00
Daniel Rosenberg
477f3e5f4a Add support for casefolding and project quotas
This enables ext4 casefolding and project quotas for adopted storage
cards.

Test: Enable virtual sdcard, adopt, check options on formatted disk
Bug: 138321217
Bug: 138322712
Change-Id: I99c09283cd78c30237cf18ad9ae9384ba0c05396
2020-01-14 18:11:56 -08:00
shaozhongqi
081cf8efdb Exfat Need to add automatic repair function when exfat fsck device
bug:143229109

Test: Manual

Change-Id: Ibf650bdcb378dd9c07f904bdd18b36f376b45b61
Signed-off-by: shaozhongqi <shaozhongqi@xiaomi.com>
2019-10-31 06:37:50 +00:00
Xin Li
3d3a9a7f1c Restore historical behavior with fsck_msdos (always accept fixes).
Bug: 133725065
Change-Id: I1d50a7e52fda34e59eb6f051c7fde115a6cd5255
2019-06-06 11:33:51 -07:00
Paul Crowley
de2d6201ab Refactor ForkExecvp to improve locking behaviour
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
2018-12-06 09:37:02 -08:00
Eric Biggers
a701c458ca vold: rename from "ext4 encryption" to fscrypt
We support file-based encryption on both ext4 and f2fs now, and the
kernel API is the same.  So rename things appropriately in vold:

    e4crypt => fscrypt
    ext4enc => fscrypt
    Ext4Crypt => FsCrypt
    EXT4_* => FS_*
    ext4_encryption_key => fscrypt_key

Additionally, the common functions shared by 'vold' and 'init' are now
in libfscrypt rather than ext4_utils.  So update vold to link to
libfscrypt and include the renamed headers.

Note: there's a chance of 'fscrypt' being confused with the dm-crypt
based encryption code in vold which is called 'cryptfs'.  However,
fscrypt is the name used in the kernel for ext4/f2fs/ubifs encryption,
and it's preferable to use the same name in userspace.

Test: built, booted device with f2fs encryption
Change-Id: I2a46a49f30d9c0b73d6f6fe09e4a4904d4138ff6
2018-10-25 17:12:32 -07:00
Paul Crowley
14c8c0765a clang-format many files.
Test: Format-only changes; treehugger suffices.
Change-Id: I23cde3f0bbcac13bef555d13514e922c79d5ad48
2018-09-18 15:41:22 -07:00
Jeff Sharkey
c1e10dc348 Merge "Rely on updated newfs_msdos for parameter tuning."
am: 7d557e98be

Change-Id: I20d1a2c9dd402aa85d61c4cf3d765c487ca697f9
2018-06-19 16:34:37 -07:00
Jeff Sharkey
a76f149f12 Rely on updated newfs_msdos for parameter tuning.
The recently updated newfs_msdos tool has robust tuning logic
internally to pick balanced values for parameters like sectors-per-
cluster, so rely on it instead of trying to force invalid
configurations.

If stakeholders want to tune these parameters even further, they
should contribute to upstream newfs_msdos, where it will benefit
more than just Android devices.

Bug: 29899852
Test: manual with 512MB, 2GB and 34GB devices
Change-Id: I23ab3699f37fc428c2bd7dcbd84f825412d916e6
2018-06-19 15:35:05 -06:00
Logan Chien
188b0ab7b3 Deprecate <cutils/log.h> and <utils/Log.h>
This commit replaces <cutils/log.h> and <utils/Log.h> with <log/log.h>.

Background:
<cutils/log.h> has been moved to <log/log.h> for a while.  Both
<cutils/log.h> and <utils/Log.h> simply includes <log/log.h> for
backward compatibility.  This commit is a part of the effort to remove
<cutils/log.h> and <utils/Log.h> from the source tree eventually.

Bug: 78370064
Test: lunch aosp_walleye-userdebug && cd system/vold && mma
Change-Id: I1f9b7b132f9c35469e97556a30b521cc47e829d7
2018-05-02 12:10:19 +08:00
Jaegeuk Kim
7db02ab5d1 vold: set f2fs feature bit
Bug: 74604441
Bug: 67380979
Change-Id: Ifcb43fb4f8fbdf79e70cfa208af73073d815e254
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-04-06 11:54:31 -07:00
Jeff Sharkey
37ba125205 Add basic exFAT support.
Several partners have been requesting exFAT support.  Android doesn't
natively support exFAT, but we're at least willing to try mounting an
exFAT filesystem if we detect the Linux kernel supports it, and if
helper binaries are present.

This CL is simple scaffolding, and it provides no actual
implementation of exFAT.

Test: builds, boots
Bug: 67822822
Change-Id: Id4f8ec3967b32de6e1c0e3c4b47fe6e43a6291ab
2018-01-19 11:58:43 +09:00
Jaegeuk Kim
c7c477b8fb Vold: format f2fs partition
This patch formats f2fs paritition with proper flags.

Change-Id: Ie5ded1f2ceb3869771b2eaf9bea3b0966cab18c5
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-14 17:52:16 -08:00
Jeff Sharkey
3472e52fc2 Move to modern utility methods from android::base.
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
2017-10-17 12:40:51 -06:00
Paul Crowley
3b71fc5100 Be more C++. volume UUID should always be std::string.
Test: boots
Bug: 67041047
Change-Id: I36d3944ae8de192703b9ee359900841b833fe3a1
2017-10-09 13:36:35 -07:00
Ravisankar Reddy
4cc6baf616 Add noatime to vfat and exfat
testNoAtime is new cts testcase, which verifies all writable
block filesystems are mounted "noatime" toavoid unnecessary
flash churn. So add noatime for vfat.

Bug: 64137815
Test: run cts -m m CtsOsTestCases -t android.os.cts.EnvironmentTest#testNoAtime
Change-Id: I4f42b54ed0d66e09964351da26d0d3bf38d573d6
2017-07-31 18:12:30 +08:00
Jeff Sharkey
95a92f9203 Only enable quotas when supported by device.
Otherwise we might end up creating ext4 partitions that the device
can't mount.

Bug: 63763609
Test: builds, boots
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I5f6cf73f23a55bc0dea9480523f19049313c3dd1
2017-07-17 13:58:45 -06:00
Jeff Sharkey
d794526962 Fully switch to mke2fs; set policies everywhere.
Older make_ext4fs doesn't support enabling quotas, so switch everyone
over to using mke2fs for adoptable storage.

Remove UUID check so that we start setting ext4-crypto policies on
adoptable storage devices; a future change will handle the actual
key management.

Bug: 30230655, 36757864
Test: cts-tradefed run commandAndExit cts-dev --abi armeabi-v7a -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AdoptableHostTest
Change-Id: I021f85b1be8431044c239521c37be96534682746
2017-06-26 16:09:14 -06:00
Jeff Sharkey
46bb69f49a Progress towards FBE and adoptable storage.
Offer to adopt storage devices on FBE devices, but keep it guarded
behind a system property for now, since we still need to work out key
storage details.

When migrating shared storage, leave user-specific /data/media
directories in place, since they already have the needed crypto
policies defined.

Enable journaling, quotas, and encrypt options when formatting
newly adopted devices.  installd already gracefully handles older
partitions without quota enabled.

Test: cts-tradefed run commandAndExit cts-dev --abi armeabi-v7a -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AdoptableHostTest
Bug: 62290006, 36757864, 29117062, 37395736
Bug: 29923055, 25861755, 30230655, 37436961
Change-Id: Ibbeb6ec9db2394a279bbac221a2b20711d65494e
2017-06-26 09:53:10 -06:00
Adrien Schildknecht
6218c51e4b Manually merge commit 'b406ffa' into stage-aosp-master am: 04c55e6ed7 am: 93722ead06
am: 43100e580f

Change-Id: I8a74fd730f0aa5a1f94c04c12286e96ac299b463
2016-12-03 04:20:13 +00:00
Adrien Schildknecht
e0f409ca32 Add support for creating ext4 images with mke2fs
We are investigating replacing make_ext4fs with the upstream tool mke2fs.
See b/23686092 for more informations.

To mitigate the trouble that may arise if the new tool behave differently
compared to the old one, there will be a transition period where both mke2fs
and make_ext4fs will be supported.

This patch does 3 things:
  - add the necessary code to use mke2fs to format an ext4 partition;
  - add a dependency to the binary used by vold.

Test: m -j32 with TARGET_USES_MKE2FS={,false,true}
                  TARGET_USERIMAGES_USE_EXT4={,true}

Change-Id: I89222642fe1d11a035155c8224b84b2e3719938b
2016-11-22 18:46:37 -08:00
George Burgess IV
605d7ae18d Cleanup uses of sprintf, add modes to open() with O_CREAT.
Change-Id: Iaed2538831b19ada26005bbef33cff28209c6512
2016-03-02 22:42:22 +00:00
Elliott Hughes
6bf0547ccc resolve merge conflicts of b7d5a47cec to master.
Change-Id: I0c5211a00d92d0ee796bb9c77d2e13675a2a3e8d
2015-12-04 17:55:33 -08:00
Jeff Sharkey
51c6b9876a Merge "Handle non-format partition in Vold" am: 385ca5d236 am: 63b7774894
am: 971ecb40ee

* commit '971ecb40ee9bc3c729091667b5192dbae996c1d2':
  Handle non-format partition in Vold
2015-12-05 00:54:30 +00:00
Jeff Sharkey
20826a1574 Merge "vold: fix 64 bit ioctl error" am: 3e6c59dc16 am: bf6acf44a9
am: a619c191cc

* commit 'a619c191cc06c08fb19e1bdd486a41da65f6c0af':
  vold: fix 64 bit ioctl error
2015-12-05 00:54:22 +00:00
Elliott Hughes
7e128fbe21 Track rename from base/ to android-base/.
Change-Id: I3096cfa50afa395d8e9a8043ab69c1e390f86ccb
2015-12-04 15:50:53 -08:00
Jeff Sharkey
385ca5d236 Merge "Handle non-format partition in Vold" 2015-12-03 17:40:21 +00:00
Mateusz Nowak
a4f48d0f44 vold: fix 64 bit ioctl error
Changing the num_sectors used in ioctl with BLKGETSIZE because
the kernel expects an unsigned long type and then changes 64 bits
with a 64 bits userspace. This overwrites what's located close to
the parameter location if any.

Change-Id: I78fd61a1084de2741f39b926aa436462518709a0
Signed-off-by: Mateusz Nowak <mateusz.nowak@intel.com>
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>
2015-10-21 11:16:19 +08:00
Mateusz Nowak
3dd39309d0 Handle non-format partition in Vold
fsck_msdos will retun error code 8 when the partition is non-format.
Handle this error code and continue next partition in Vold.

Change-Id: I31499ccb16945ffbc67bdc92dfbc3ea71e82573a
Signed-off-by: Mateusz Nowak <mateusz.nowak@intel.com>
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>
2015-10-21 11:14:47 +08:00
Elliott Hughes
3d83948032 am 5e7f772d: am 6d24e086: Merge "Remove dead code."
* commit '5e7f772dbd27d5d93b15f004991749d321b6d62d':
  Remove dead code.
2015-08-15 02:24:13 +00:00
Elliott Hughes
5e7f772dbd am 6d24e086: Merge "Remove dead code."
* commit '6d24e0866f61aba0ac3023408ead083ad9b6cdab':
  Remove dead code.
2015-08-15 02:19:16 +00:00
Elliott Hughes
3097d0e151 am 6d24e086: Merge "Remove dead code."
* commit '6d24e0866f61aba0ac3023408ead083ad9b6cdab':
  Remove dead code.
2015-08-15 02:19:04 +00:00