Ignore Permissions / Different mtimes on Android Sdcard

Hi,

That seem to fix the issue! I wasn’t aware of the setting - sorry.

Preliminary tests seem very positive. I will test again, more extensively, later, but, for now, the fix seems good (for me)!

Thank you!

===R

Good to know, thanks for reporting. That setting it to 2 has an effect also means there’s something not working as expected with the FS auto-detection (if @Catfriend1’s apk is up-to-date, which I think it is, right?).

@imsodin what line do I need to throw in to see if fs auto detect is working? Maybe you could add the log line to your PR as this would give us a lot of info what different Android OS report via gopsutil.

Done. Enable config debug logging and there will be lines about detecting FS at ... on android ... with the relevant information. Thanks!

1 Like

Thanks for all your efforts on this, @imsodin. Unfortunately I have to report back with no good news. We’re almost game over with SDcards I think… details are on Override/Revert showing up with no changes on extSdCard synced folders · Issue #454 · Catfriend1/syncthing-android · GitHub .

Short summary:

  • I’ve synced a file (like in my previous test scenario from PR #5852) from PC to phone. The file is created on the phone with the correct “original” mtime on sdcard. I exit the app, verify the original mtime is still there and reboot the phone. I ensure to NOT start the Syncthing App and directly go to my file manager app. I see for about 10 seconds (if I’m fast getting there after bootup) the mtime is still correct and then - poof - it is the “original mtime +4 hours” magically.

I suspect this is some Android OS service doing anything to it, but I’m currently trying to find out which one it might be. Btw I ran the tests on SDCARDFS (which is used in Android 8+) - here using an emulator with the recent Android 10 image from Google.

What makes me double confused is, when I hit the “override change” button on PC and the phone is “sendreceive”, I get the original timestamp back and then - magically - it stays like this even after reboot.

EDIT: This even occurs if the Syncthing app is NOT used and can be reproduced.

Here’s a good reproducer for the “sdcardfs - Android OS modifies mtime after reboot silently” problem:

  • push a test file to phone using

adb push baseconv2.exe /storage/10F1-1918/Android/data/com.github.catfriend1.syncthingandroid.debug/files/baseconv2.exe

  • Open your favorite file manager app and note the mtime (which is “original”)
  • Reboot phone.
  • Open your favorite file manager app and note the mtime has CHANGED silently (without running Syncthing) and is now “+4 hours”

New test scenario - without the Syncthing App:

  • Disabled system app “Media storage” (Media Scanner?)
  • adb push’ing test file … original mtime is there
  • Rebooted phone.
  • mtime changed, very suprising is, that the mtime now changed to “now - 2 hours” instead of “original + 4 hours”.

Damn! It’s even done by Android OS in the SDCARD root folder, see logs:

+0000  1836  1836 D vold    : Recognized experimental block major ID 253 as virtio-blk (emulator's virtual SD card device)
+0000  1836  1836 D vold    : /dev/block/vold/disk:253,80: LABEL="SDCARD" UUID="10F1-1918" TYPE="vfat"
+0000  1836  1836 D vold    : /dev/block/vold/public:253,80: LABEL="SDCARD" UUID="10F1-1918" TYPE="vfat"
+0000  1836  1836 D vold    : /system/bin/fsck_msdos
+0000  2654  2654 W sdcard  : Device explicitly enabled sdcardfs

adb shell ls /storage/10F1-1918 -l
-rwxrwx--x 1 root sdcard_rw 104960 1995-10-14 17:51 baseconv2.exe

+0000  4969  5729 I SDCardScannerService: getExternalFilesDirs /storage/emulated/0/Android/data/org.fdroid.fdroid/files
+0000  4969  5729 I SDCardScannerService: getExternalFilesDirs /storage/emulated/0/Android/data/org.fdroid.fdroid/files
+0000  4969  5729 I SDCardScannerService: getExternalFilesDirs /storage/10F1-1918/Android/data/org.fdroid.fdroid/files
+0000  4969  5729 I SDCardScannerService: getExternalFilesDirs /storage/10F1-1918/Android/data/org.fdroid.fdroid/files
+0000  4969  5729 I SDCardScannerService: sdcard files []

adb shell ls /storage/10F1-1918 -l
-rwxrwx--x 1 root sdcard_rw 104960 1995-10-14 21:51 baseconv2.exe

Tried to workaround by creating the .nomedia file in the test folders on the phone - no luck, mtime still being changed shortly after reboot when sdcard is mounted by android. :frowning:

I am not sure if emulator is a sensible test bed, as things that provide time (bios etc) are emulated, so time can go anywhere it wants as it reboots.

1 Like

Huh… Nice Point, I’ll do more tests as I find real devices :slight_smile:

Wow, good work! It is indeed solved according to my most recent test on a Motorola X Play (lux) running on Android 8.0 (LineAgeOS without root).

I noticed one problem, as @rahrah said , the file system auto-detection doesn’t work properly on Android 8.0 (I mean the tested device with this).

Immediately on startup, even before the “Syncthing version XX” line comes up, it logs this:

DEBUG: Detecting FS at /storage/D9D0-1BFD/Android/media/com.github.catfriend1.syncthingandroid.debug/extsdtest on android, found , thus leaving mtime window at 0

If this is not a problem with PR #5852 's code, I suggest setting mtimeWindow to 2 secs from the wrapper. Tested this and it worked fine. I also learned that the problem only can be reproduced with a REAL device using SDCARD and syncing a file with an UNEVEN-second timestamp to it.

Just to update the topic in case someone finds it via Google: The mtime bug on sdcardfs (FAT file systems) is fixed since v1.2.2-rc3

2 Likes

Yes, it’s most definitely fixed for me. Big THANK YOU to all for all the hard work and patience with this!

1 Like

Luckily I searched today about the issue state, since the changelog wasn’t clearly describing that the fat32 mtime issue got fixed, in my opinion.

Now I seems can happily thank you for resolving this issue. <3

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.