Add time_offset=<UTC offset> to mount arguments for the vfat driver.
This is not being release flagged as it's a fix for a regression but is
a cosmetic fix that shouldn't affect anything besides reported file
timestamps.
Changes for issue 246256335 in Android U stopped Android syncing the
current time zone UTC offset to the kernel because doing so is
discouraged. It is discouraged because the current offset alone is not
very useful - it tells the kernel nothing of DST or historic UTC
offsets. Converting to and from local times are are best left to
userspace where time zone rules information is available, and different
users can use different time zones.
However, because FAT32 is poorly designed WRT timestamps, the kernel
FAT32 driver, vfat, does use the kernel offset when available and when
it isn't given a fixed offset to use at volume mount time. This means
that Android devices after the change from issue 246256335 displayed
more obviously incorrect times.
This change adds the argument necessary to vold when mounting a FAT32
volume to set a fixed UTC offset to adjust FAT32 local times
to a UTC-like time ("UTC time" from now on). Userspace then uses the UTC
offset for that UTC time, calculated using TZDB rules, to convert back
to a local time. This is still prone to generating some incorrect times,
e.g. due to DST or other historic offset changes, or a user time zone
change on device after mounting the volume. FAT32 lacks the information
about "what was the UTC offset at file time X?" (unlike exFAT) AND the
vfat driver has no way to look up the time zone rules itself. This
change is a reasonable "better than nothing" change to address times
being obviously wrong after the change from issue 246256335, especially
when a user copies a file from a desktop computer to USB / sd card
storage and immediately plugs the device into an Android device. It does
this without reverting to kernel UTC offset syncing, which is flawed
(i.e. it would never work completely), discouraged, and more effort/code
to improve, e.g. because userspace would have to schedule alarms for
offset changes.
Testing:
1) Obtain a USB FAT32 formatted USB storage device that can be plugged into
a pixel device, e.g. with an OTG USB adapter.
2) On a desktop computer, mount the device and write some files / note
times associated with existing files. These times will already be
adjusted by this OS to be "local time" based on its own logic, but if
it's working correctly that time will be exactly the local time value
stored in the FAT32 volume itself.
3) On a rooted Android device where you can use adb via Wifi (adb tcpip
/ adb connect), leaving the USB port free for external USB devices....
a) $ adb root
b) Insert the USB storage
c) $ mount | grep 'fat'
d) For the USB storage drive, observe the time_offset argument (or
tz=UTC when time_offset == 0) reported (this would not be reported
without this patch)
e) ls -l /mnt/<mount location from (3c)>
f) Confirm the local time displayed is as expected. e.g. the time
should be the same as shown in (2), regardless of the device's time
zone.
4) To observe the "fixed offset behavior" at mount time, alter the time
zone setting on the device via Settings -> System -> Date & Time
a) Repeat 3c-3e.
b) The times shown will have changed by the difference between
the original and new time zone chosen.
c) Extract / re-insert the USB storage device.
d) Repeat 3c-3e
e) The times shown should match the times from (2) again
5) Confirm the write behavior:
a) $ touch /mnt/<mount location from (3c)>/foobar
b) $ ls -l /mnt/<mount location from (3c)>
c) The time should match the device's displayed local time (status
bar)
d) Unmount the USB device and insert the USB device into a desktop computer
e) Confirm the timestamp matches the Android device's local time when
(5a) took place, e.g. using "ls -lT" on MacOS.
Testing was done with numerous zones with positive, negative and zero offsets.
Interesting zones like India (UTC+5:30), Kiribati (UTC+14), Wake Island
(UTC-11), the various fixed offset zones like Etc/GMT+12, Etc/GMT-14
were tried.
Note: Depending on the time zones being used on devices (Android and
desktop) and when the files were written / testing took place during the
year, you may see file times shifting by 1 hour from the "ls -l" step
depending on whether they were written in summer or winter time. This
is because the userspace code for rendering times knows about DST but
the kernel driver is applying a fixed offset and does not. This is
expected and illustrates the points at the top of this comment about
FAT32 integration never being perfect.
See https://www.google.com/search?q=fat32+dst for other examples.
Bug: 319417938
Bug: 315058275
Bug: 246256335
Test: See above
Change-Id: Ic7ce159d88db5d5cf5894bcc26ea60bd7c44917d
Currently F2FS block size must match page size, so this just does that.
If we support page size != block size for F2FS, this should be
revisited.
Bug: 279820706
Test: Boot 16K device
Change-Id: I6b3b367cdf76ccf5b2c5d309499027a5e7383a44
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Properly handle the exit status 1, which shows filesystem errors
corrected, returned by fsck.
Test: manually hot-plugs SD card and check logcat logs
Change-Id: Iacaa8b1d1a7b59931014c1ab6a4708ffc3cd0c06
This reverts commit 564f6c649a.
Reason for revert: Un-backporting.
Note: This is not a direct revert. We should keep the minor refactoring
in PublicVolume.cpp; no point making the code worse.
Test: Revert.
Change-Id: Ic03ed25ad15a2da974921542a20cd27224347f68
This CR, when paired with a functional NTFS implementation and the
corresponding SEPolicy updates, will allow NTFS USB drives to be mounted
on Android.
Bug: 254407246
Test: Extensive testing with an ADT-4 and NTFS USB drives.
Merged-In: If4197c4c588866c611cd6ba3483707d3cb0e0cf8
Change-Id: If4197c4c588866c611cd6ba3483707d3cb0e0cf8
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
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
It enables encrypt, proejct_quota, verity by default.
Bug: 225401790
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I6c6dc81b8e62b20b0107d40a9ed5b645cdafbda1
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
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
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
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
These were only added for ext4.
Bug: 150935323
Test: when creating a private f2fs volume, things work as expected.
Change-Id: I11ee04bfddecb6c95e223e66c9bf532c425e6fac
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
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
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
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
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
This patch formats f2fs paritition with proper flags.
Change-Id: Ie5ded1f2ceb3869771b2eaf9bea3b0966cab18c5
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
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
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
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
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
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
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