No description
Find a file
Neil Fuller 6eea031719 Add time_offset=<UTC offset> to mount arguments
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
2024-01-19 16:51:20 +00:00
bench [LSC] Add LOCAL_LICENSE_KINDS to system/vold 2021-02-14 10:37:25 -08:00
binder/android/os Remove userSerial param from vold methods that don't use it 2024-01-04 22:39:43 +00:00
fs Add time_offset=<UTC offset> to mount arguments 2024-01-19 16:51:20 +00:00
model Adding public volume mounts for clone user. 2023-08-29 10:38:43 +00:00
tests Adding corpus for vold fuzzer 2023-09-06 21:20:16 +00:00
.clang-format vold: use system-clang-format 2019-09-16 12:00:40 -07:00
Android.bp vold: remove session keyring workaround for old kernels 2023-12-05 19:39:33 +00:00
AppFuseUtil.cpp AppFuseUtil: Call ForceUnmount before PrepareDir. 2019-04-09 18:45:32 +01:00
AppFuseUtil.h Extract AppFuse as a util 2018-11-14 07:28:06 +00:00
Benchmark.cpp vold: Use Wakelock::tryGet() 2021-02-22 17:24:51 -05:00
Benchmark.h clang-format many files. 2018-09-18 15:41:22 -07:00
BenchmarkGen.h Abort long-running benchmarks, report progress. 2017-11-07 09:57:12 -07:00
Checkpoint.cpp Check bounds on dm-bow checkpoint restore 2023-02-06 09:40:51 -08:00
Checkpoint.h Add an isCheckpointing() binder call for adb remount. 2020-06-10 23:52:25 -07:00
CleanSpec.mk Add an empty CleanSpec.mk 2010-03-08 18:05:25 -08:00
cryptfs.cpp cryptfs: Update the size of dm-crypt device according to sector size 2022-09-28 17:44:44 +08:00
cryptfs.h Remove CRYPT_FOOTER_OFFSET 2021-11-10 14:03:48 -08:00
CryptoType.cpp Generalize CryptoType infrastructure 2020-02-14 00:48:27 -08:00
CryptoType.h Generalize CryptoType infrastructure 2020-02-14 00:48:27 -08:00
EncryptInplace.cpp Remove progress property support from encrypt_inplace() 2022-03-09 21:03:52 +00:00
EncryptInplace.h Remove progress property support from encrypt_inplace() 2022-03-09 21:03:52 +00:00
FileDeviceUtils.cpp Remove excess logging in secdiscard 2019-03-21 19:13:51 +00:00
FileDeviceUtils.h clang-format many files. 2018-09-18 15:41:22 -07:00
FsCrypt.cpp Remove userSerial param from vold methods that don't use it 2024-01-04 22:39:43 +00:00
FsCrypt.h Remove userSerial param from vold methods that don't use it 2024-01-04 22:39:43 +00:00
IdleMaint.cpp Correct reserved blocks to segments 2023-08-31 12:54:01 -07:00
IdleMaint.h Introduce target dirty segment ratio tunable parameter 2022-07-04 21:23:46 +00:00
KeyBuffer.cpp clang-format many files. 2018-09-18 15:41:22 -07:00
KeyBuffer.h Add a ZeroingAllocator::rebind<Other> for Other==char 2023-07-24 21:36:32 -07:00
KeyStorage.cpp Merge "Avoid error message when destroying key w/o secdiscardable file" am: dc262c27f0 am: 60c71b9950 am: 2ef1832ac4 2023-03-04 07:49:59 +00:00
KeyStorage.h Defer CE key fixations to checkpoint commit 2022-11-14 17:45:32 +00:00
Keystore.cpp Switch to C23's memset_explicit(). 2022-08-15 23:10:28 +00:00
Keystore.h Detect factory reset and deleteAllKeys 2021-08-11 10:29:59 -07:00
KeyUtil.cpp vold: remove session keyring workaround for old kernels 2023-12-05 19:39:33 +00:00
KeyUtil.h vold: remove session keyring workaround for old kernels 2023-12-05 19:39:33 +00:00
Loop.cpp Remove vold logs related to block devices 2021-07-28 02:58:57 +01:00
Loop.h clang-format many files. 2018-09-18 15:41:22 -07:00
main.cpp Check for SELinux labelling errors 2023-03-01 22:11:29 +00:00
MetadataCrypt.cpp Use logical path to handle different dm target per boot 2023-11-13 16:59:56 -08:00
MetadataCrypt.h Support zoned device with dm-default-key 2022-06-07 18:43:54 -07:00
MoveStorage.cpp vold: Use Wakelock::tryGet() 2021-02-22 17:24:51 -05:00
MoveStorage.h clang-format many files. 2018-09-18 15:41:22 -07:00
NetlinkHandler.cpp vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
NetlinkHandler.h vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
NetlinkManager.cpp vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
NetlinkManager.h vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
OWNERS OWNERS: add alan and jeff, alphabetize 2020-12-10 13:08:28 +01:00
PREUPLOAD.cfg vold should be fully developed in AOSP. 2018-09-11 12:08:43 -06:00
Process.cpp Verify if pid actually killed for processes with open files 2023-10-30 09:50:48 -07:00
Process.h Only kill apps with storage app data isolation enabled 2021-04-30 13:58:07 +00:00
secdiscard.cpp Don't use a secdiscardable file for keys encrypted by SP 2022-10-07 16:26:29 +00:00
sehandle.h clang-format many files. 2018-09-18 15:41:22 -07:00
TEST_MAPPING Add vold to hwasan-postsubmit 2022-03-18 14:25:02 -07:00
Utils.cpp Log reason for fuse-bpf being enabled/disabled 2023-04-14 21:59:05 +00:00
Utils.h Merge changes from topic "deny-create-user-dirs" am: 9fb8825578 am: 65f0713d14 2022-05-12 19:57:49 +00:00
vdc.cpp Merge "Add vdc volume getStorageSize" into main 2023-08-15 14:51:08 +00:00
vold.rc Explicit init .rc user. 2023-04-10 20:54:26 +00:00
vold_prepare_subdirs.cpp Use /data/misc/apexdata for the list of APEXes 2023-08-12 01:05:53 +09:00
VoldNativeService.cpp Remove userSerial param from vold methods that don't use it 2024-01-04 22:39:43 +00:00
VoldNativeService.h Remove userSerial param from vold methods that don't use it 2024-01-04 22:39:43 +00:00
VoldNativeServiceValidation.cpp [vold] Check incremental paths before mounting 2022-01-31 22:13:14 +00:00
VoldNativeServiceValidation.h [vold] Check incremental paths before mounting 2022-01-31 22:13:14 +00:00
VoldUtil.cpp Move over to the C++ Fstab class 2019-01-31 12:34:39 -08:00
VoldUtil.h Remove unused code in VoldUtil.h 2020-02-18 10:48:16 -08:00
VolumeManager.cpp Call fscrypt_destroy_volume_keys() under mCryptLock 2023-10-06 15:30:13 +00:00
VolumeManager.h Call fscrypt_destroy_volume_keys() under mCryptLock 2023-10-06 15:30:13 +00:00