[GUIDE][HOW-TO]Keep timestamp and attributes correct

Search This thread

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
1. What is the problem?
The implementation of FUSE by Google runs using the root-account. The disadvantage is that the standard user is not capable of changing any attribute including timestamp. A copy or move file operation usually keeps all attributes including date and time on all known operating system - except Android if FUSE is involved. This can complicate management of backups or syncing - and sorting or filtering by date is not helpful anymore.


2. What is concerned?
The problem exists at least on all file systems which are emulated by Android using FUSE. Android 8 and later uses SDCardFS and therefore is not concerned.

Concerned from Android 4.0: ext4, exFAT
Not Concerned on 4.0: FAT32
It seems FAT32 is done via FUSE in later Android versions also, so it seems every file system is concerned from 4.1 to last Android 7.

Most Android 4.x-devices are using ext4 for the file system of the internal storage and are therefore concerned. The usage of FAT32 which can not manage file greater than 4 GiB seems not appropriate anyway. For memory cards smaller than 64 GiB it is usual to use FAT32, bigger cards use exFAT by default.

It is possible to access external file systems, eg SAMBA or FTP, and then usually the timestamp is set correctly, because this is not part of FUSE and uses other file systems. AFAIK most file manager still try to set the timestamps, although it always fails without root, and ignore the error returned by FUSE, so copying and moving should be fine. At least Total Commander copies the timestamp fine if writing to Samba using the appropriate plug-in on non-rooted devices.


3. How to recognize/test the problem?
If you copy or move a file, the date and time should be kept. But if the destination on Android uses FUSE, instead of the original timestamp the current date/time is being set. Also all other attributes which the file system may manage (rights, owner, groups etc.) usually are concerned. The original values vanish.

If you want to see which file system is being used for internal memory or some external card you may use the app DiskInfo.
If it shows vfat, it means FAT32.



4. Which possibilities exist to correct the behavior?
Google fixed the bug in Android 8 which was known for a long time (start of 2009).
Google issue 34691 with links to related issues
With Android 8 usage of FUSE was removed, the problem was corrected
https://issuetracker.google.com/issues/36930892#comment120
(careful when using command line under Android 8: cp -a seems not always to be working, but touch -r will)

5. Which possibilities exist to circumvent the problem?

5.0. do not use Android for writing to filesystem: If you don't use Android for writing the files, setting the timestamp mostly will be fine. As mentioned in 4. you can use any filesharing server (Samba, ftp etc.). Storing your documents there instead of the local device will relocate the write access to the filesystem of the filesharing server, which usually manages timestamps fine. There also exist possibilities like adopted storage mode, where the SD card gets accessed by Linux and Android only is being used like a card reader.

As the files have the owner root, all possibilities to circumvent using Android need a rooted device. All following solutions shown here won't work for devices which are not rooted.

5.1. Afterwards correcting (not tested): In the app store there exists at least one app File Timestamp which can afterwards set the timestamp.

5.2. Samba Filesharing runs under root account. If some file is accessed via samba server, the time stamp and attributes can be set correctly.

5.3. Make use of a file manager which sets the timestamp using the power of root on a rooted device:
X-Plore sets file time after copying if root mode is enabled.
Ghost Commander is said to work fine (additional requirement: Busybox)
Total Commander 2.04 and newer support changing the time stamp under root account. On Android 5 and newer you need to use link /storage/xxxx-xxxx for external SD, not ///_Name, to make it behave correctly.
SManager by devwom also deals fine with timestamp using root
MiXplorer tries calling touch. The standard touch on some Android versions is faulty implemented, MiXplorer then only succeeds when BusyBox (internal download of MiX) is installed. Try if it works on your device with your current setup, and have a second look if the timezone correctly evaluated.

5.4. Manual call via command line: Who opens a terminal (eg Open Android Terminal) on a rooted device preferrably with BusyBox can execute commands as root.

Example 5.4.

Archive (also possible on Unix/Windows/etc)

cd <Quelle>
tar -cf <Pfad_zu_Archiv>/Archiv.tar *


Extract

cd <Ziel>
su
tar -xf <Pfad_zu_Archiv>/Archiv.tar


Copy

su
cp -a <Quelle> <Ziel>


The command su changes to root user, so that write access to time stamps is possible. It is always possible to read them, so that it is not necessary to su before archive.

Careful when calling touch: The standard implementation (toybox) seems to be faulty, it does not set the given time when called using -d or -t switch.
Careful when using Android 8 (root not required), it seems at least some implementation of cp does not set timestamp on cp -a
 
Last edited:

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
As my current device Moto G uses f2fs for internal storage and I didn't root it by now the test was easy to do ;)

Yes f2fs is also affected. Current time is being used for copy of a file. Thanks for the question, I will add this. Guess it also is implemented using fuse. Until someone tells the opposite I will add it to the fuse-managed fs.

There is another information which I want to add: That the default file manager on most os (Finder on Mac, Windows Explorer on Windows, even cp on Unix and copy on DOS iirc) keep time and attributes for files, but not for folders. Please if you test the behavior, watch files not folders. Although I'd like to keep timestamp there also, you can't rely on these anyway.

Keeping date/time of folders usually can be achieved across platforms when using any archiver. tar, zip, anything. Compress and extract keeps the date of folders. Total commander on Android also.
 
Last edited:

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
Issue 34691 is now marked as obsolete. Probably someone at Google has read my FAQ, and the bug won't be fixed. I just can ask the same question like the newest comment in the issue: is the issue obsolete, or is it Android?
 
Last edited:

kotey

Senior Member
Aug 11, 2009
127
35
/etc/
As my current device Moto G uses f2fs for internal storage and I didn't root it by now the test was easy to do ;)

Yes f2fs is also affected. Current time is being used for copy of a file. Thanks for the question, I will add this. Guess it also is implemented using fuse. Until someone tells the opposite I will add it to the fuse-managed fs.

There is another information which I want to add: That the default file manager on most os (Finder on Mac, Windows Explorer on Windows, even cp on Unix and copy on DOS iirc) keep time and attributes for files, but not for folders. Please if you test the behavior, watch files not folders. Although I'd like to keep timestamp there also, you can't rely on these anyway.

Keeping date/time of folders usually can be achieved across platforms when using any archiver. tar, zip, anything. Compress and extract keeps the date of folders. Total commander on Android also.

Actually, from my experience:

Windows:
Explorer didn't maintain folder ts, only file. Total Commander has option to do so. Some archivers do maintain while some not, meaning it's possible on Windows.

Linux:
Most Explorer-like eg KDE's Konqueror didn't preserve ts. Midnight Commander can, the option when copying is there. Also cp -a or cp -prv works in Terminal. So its possible on Linux.

OSX:
I'm using MC too solely for this purpose (I'm a timestamp freak) because most file mangers on osx sux just like the os (not the underlying bsd core) Krusader even show wrong ts. Disk Order comes close but can't rival Total Commander on Windows, or Norton Commander, Volkov Commander on DOS or Midnight Commander on Linux/OSX for that matter. So also possible on OSX/HPFS.

Android:
The closest to almost able is Total Commander, and to some extent, later versions of ES File Manager. Most others simply failed even ones with root support. So I have to cp -a in Android if I have to maintain folder ts, so far I'm not able to get even TC to do that (don't know where's the option, is it there? You're implying as if it's there, do tell if so) Used 2.04 and 2.05 beta builds so far.

And also, I never get a single archiver on Android to extract timestampfor folder (files are fine obviously) except 7zip on vfat, but that means no permissions since 7zip is not unix native.

And oh, by that I meant 7za command line, not anything in apps aka shell, not going to use those archiver shells anytime (unless embedded in a file manager)
 
  • Like
Reactions: tag68

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
I'm using MC too solely for this purpose (I'm a timestamp freak) because most file mangers on osx sux just like the os (not the underlying bsd core) Krusader even show wrong ts. Disk Order comes close but can't rival Total Commander on Windows, or Norton Commander, Volkov Commander on DOS or Midnight Commander on Linux/OSX for that matter. So also possible on OSX/HPFS.

I'm using muCommander on OSX, it also keeps timestamps of folders.


Oh, guess I remembered wrong in this point that TC keeps timestamp of folders. I'll ask the author. Like I did for setting timestamp as root, I gave the authors of TC and ES Explorer the hint. While Christian Ghisler (TC) immediately answered and helped a lot, I did not get any reply from the authors of ES Explorer. Does it keep timestamp if you have root in the meantime?
 

kotey

Senior Member
Aug 11, 2009
127
35
/etc/
I'm using muCommander on OSX, it also keeps timestamps of folders.

Oh, guess I remembered wrong in this point that TC keeps timestamp of folders. I'll ask the author. Like I did for setting timestamp as root, I gave the authors of TC and ES Explorer the hint. While Christian Ghisler (TC) immediately answered and helped a lot, I did not get any reply from the authors of ES Explorer. Does it keep timestamp if you have root in the meantime?

Old ES doesn't keep ts of anything.
ES v3 has the same behaviour as TC, it keeps ts of files but not folders.

AFAIK both ES and TC doesn't actually require root in order to keep ts of files, just like cp -a did in a non-root shell (but cp will throw lots of permission copy error, just ignore those obvious warnings, in fact it does the job perfectly)
 

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
Just tested ES File Explorer on my unrooted Moto G: Without root it does not keep ts of files. Of course not. It can't. Like cp -a can not do what the OS does not allow.

On which file system did you test when it worked?
 

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
Just did a test on my rooted S3 for a file copy operation:

1. ES Explorer keeps timestamp on external SD card where it can write without root according to FAT32 on Android 4.1.2 where FUSE is not active for FAT32
2. ES does not keep timestamp when writing to internal sdcard where FUSE is active - it does not use the power of the root account to set it.

ES is not capable. For my mail 2013-10-23 to contact@estrongs.com there was no reply. Guess it was not read, or just ignored ... and I asked 2014-01-23 if my mail arrived and repeated the question, again without answer ... so I strongly recommend to prefer Total Commander at least for rooted devices.
 
Last edited:

the gladiator

Senior Member
Dec 16, 2010
319
51
Just did a test on my rooted S3 for a file copy operation:

1. ES Explorer keeps timestamp on external SD card where it can write without root according to FAT32 on Android 4.1.2 where FUSE is not active for FAT32
2. ES does not keep timestamp when writing to internal sdcard where FUSE is active - it does not use the power of the root account to set it.

ES is not capable. For my mail 2013-10-23 to contact@estrongs.com there was no reply. Guess it was not read, or just ignored ... and I asked 2014-01-23 if my mail arrived and repeated the question, again without answer ... so I strongly recommend to prefer Total Commander at least for rooted devices.

I'm dealing with this issue from sometime but only now I'm finding your fantastic thread (THANKS A LOT!!!!).

I have something slightly different about ES Explorer (v 3.2.5) :
- exactly as you say with JB 3.2 on a Sony M and an Asus tf101
- as it should be (preserving timestamps) on a Sony z1c with kitkat 4.4.4

Of course all the devices are rooted.

It's crucial for me to have timestamps preserved and I cannot afford to have on my devices two different file managers; unfortunately I'm forced to take the decision to leave ES Explorer and join Total Commander.
 

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
Since ES seems not to use power of root, my guess is that Sony allows writing of ts. If I am right it would work the same way if you disallow ES to use root.

Btw I could not reply to your email, although the address when replying was the same like you wrote inside the mail.
 

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
Some days ago there were two comments, which I still wanted to reply. Unfortunately I'm not able to find them.

The first was about the issue closed by Google and the reason of closing. If it was duplicate, as there are still open issues dealing with timestamp. When the issue was closed I looked why Google closed issues in that case. The ratio was "the issue is so old now that we treat it as handled. If it still is active, please recreate." I don't believe it will help in any way that issues dealing with the timestamp problem are open but stay unchanged another 6 years. But time will tell, and you always can feel free in bugtracker systems to vote for the issues or watch them.

The second comment was mentioning an interesting script to set timestamp and therefore linked the Android timestamp keeper project. I don't think it would be helpful for an average user, so I wanted to thank for the link, but at least currently I do not want to add it to the Guide.
 
Last edited:

matthelm

Senior Member
Jan 29, 2012
108
13
Some days ago there were two comments, which I still wanted to reply. Unfortunately I'm not able to find them.

The first was about the issue closed by Google and the reason of closing. If it was duplicate, as there are still open issues dealing with timestamp. When the issue was closed I looked why Google closed issues in that case. The ratio was "the issue is so old now that we treat it as handled. If it still is active, please recreate." I don't believe it will help in any way that issues dealing with the timestamp problem are open but stay unchanged another 6 years. But time will tell, and you always can feel free in bugtracker systems to vote for the issues or watch them.

The second comment was mentioning an interesting script to set timestamp and therefore linked the Android timestamp keeper project. I don't think it would be helpful for an average user, so I wanted to thank for the link, but at least currently I do not want to add it to the Guide.

The correct active issue is:
https://code.google.com/p/android/issues/detail?id=25460

So far it's the only one, even though the issue is now 6 years old, I think. Once or twice a Google person has post that it'll be fixed, then the next update will come out, and nothing.
 

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
matthelm, please have a look at your link. On the left side you can see
Status: Duplicate
Merged: issue 18624
Owner: jshar...@android.com
Closed: Nov 2013
So the currently active issue is 18624. It is the third in the list of 34691 which I linked because it gives the overview which issues exist. Thank you for adding the link to 25640 there - but it is not active.
 

Old faithful

Senior Member
Dec 31, 2008
595
204
Wentworth-Nord
For those looking for a file manager that solves this issue - I've tested literally a dozen of file managers out there and the only one that keeps the filestamp intact is Ghost Commander. HIGHLY recommended, powerful, efficient, even has FTP over SSH. I'm thrilled!!!
 

tag68

Senior Member
Nov 25, 2014
963
358
Moto G 2014
Moto X Play
For those looking for a file manager that solves this issue - I've tested literally a dozen of file managers out there and the only one that keeps the filestamp intact is Ghost Commander. HIGHLY recommended, powerful, efficient, even has FTP over SSH. I'm thrilled!!!

What is wrong with Total Commander? I'm using it since a long time and it does it correctly ...

Edit: In a short test did Ghost Commander not copy the attributes to internal memory of my Moto X Play. It could not because it did not ask for the power of root. So currently Total Commander stays the only comfortable option for me.
 
Last edited:

Old faithful

Senior Member
Dec 31, 2008
595
204
Wentworth-Nord
What is wrong with Total Commander? I'm using it since a long time and it does it correctly ...

Edit: In a short test did Ghost Commander not copy the attributes to internal memory of my Moto X Play. It could not because it did not ask for the power of root. So currently Total Commander stays the only comfortable option for me.

Total Commander works on the PC, actually use it as my second file manager, but on android it has very few useful features. after a few hours trying to get it to do simple file management stuff such as moving, copying and the like, I got too frustrated and uninstalled it.

Ghost commander on the other hand has all the tools available right on the screen and when rooted, does not change file attributes at all, see for yourself :)

Test copy of one picture from the external SD Card to a test folder in the root of the device:
rm1irt.jpg


Test copy of the previous file into a test subfolder onto the external SD Card
2rdgkmx.jpg


Running KitKat 4.4.4, rooted, Super Su 2.56 beta, with permissions added for writing to the external SD Card.

Sent from my Lenovo TAB 2 A10-70F using Tapatalk 2

BTW in case you wondered, I'm NOT German speaking but indeed to German descent ;)
 

Old faithful

Senior Member
Dec 31, 2008
595
204
Wentworth-Nord
Hold on, I can't seem to replicate this. I don't know why, but after reboot the folder in the root directory (device) was gone... In other words, there is something weird going on with root here.

Second thing, the app I'm using seems to be a fork of ghost commander and there are some differences. I'm looking into it...

Sent from my Lenovo TAB 2 A10-70F using Tapatalk 2

OK, so I uninstalled this app (File Manager by GOODEV) and reinstalled Ghost Commander, then back again, and I am not able to create a permanent folder in the Device Root. I am, however, able to create folders in existing root folders, as well as copying files there.

In any case, both GOODEV File Manager and Ghost Commander will transfer files to and from SDCard, EXT SD Card and Device folders without changing timestamps.

BTW, I noticed that GOODEV File Manager loads ads when you're connected to WiFi so it may well be a spam version of Ghost Commander :mad:
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 27
    1. What is the problem?
    The implementation of FUSE by Google runs using the root-account. The disadvantage is that the standard user is not capable of changing any attribute including timestamp. A copy or move file operation usually keeps all attributes including date and time on all known operating system - except Android if FUSE is involved. This can complicate management of backups or syncing - and sorting or filtering by date is not helpful anymore.


    2. What is concerned?
    The problem exists at least on all file systems which are emulated by Android using FUSE. Android 8 and later uses SDCardFS and therefore is not concerned.

    Concerned from Android 4.0: ext4, exFAT
    Not Concerned on 4.0: FAT32
    It seems FAT32 is done via FUSE in later Android versions also, so it seems every file system is concerned from 4.1 to last Android 7.

    Most Android 4.x-devices are using ext4 for the file system of the internal storage and are therefore concerned. The usage of FAT32 which can not manage file greater than 4 GiB seems not appropriate anyway. For memory cards smaller than 64 GiB it is usual to use FAT32, bigger cards use exFAT by default.

    It is possible to access external file systems, eg SAMBA or FTP, and then usually the timestamp is set correctly, because this is not part of FUSE and uses other file systems. AFAIK most file manager still try to set the timestamps, although it always fails without root, and ignore the error returned by FUSE, so copying and moving should be fine. At least Total Commander copies the timestamp fine if writing to Samba using the appropriate plug-in on non-rooted devices.


    3. How to recognize/test the problem?
    If you copy or move a file, the date and time should be kept. But if the destination on Android uses FUSE, instead of the original timestamp the current date/time is being set. Also all other attributes which the file system may manage (rights, owner, groups etc.) usually are concerned. The original values vanish.

    If you want to see which file system is being used for internal memory or some external card you may use the app DiskInfo.
    If it shows vfat, it means FAT32.



    4. Which possibilities exist to correct the behavior?
    Google fixed the bug in Android 8 which was known for a long time (start of 2009).
    Google issue 34691 with links to related issues
    With Android 8 usage of FUSE was removed, the problem was corrected
    https://issuetracker.google.com/issues/36930892#comment120
    (careful when using command line under Android 8: cp -a seems not always to be working, but touch -r will)

    5. Which possibilities exist to circumvent the problem?

    5.0. do not use Android for writing to filesystem: If you don't use Android for writing the files, setting the timestamp mostly will be fine. As mentioned in 4. you can use any filesharing server (Samba, ftp etc.). Storing your documents there instead of the local device will relocate the write access to the filesystem of the filesharing server, which usually manages timestamps fine. There also exist possibilities like adopted storage mode, where the SD card gets accessed by Linux and Android only is being used like a card reader.

    As the files have the owner root, all possibilities to circumvent using Android need a rooted device. All following solutions shown here won't work for devices which are not rooted.

    5.1. Afterwards correcting (not tested): In the app store there exists at least one app File Timestamp which can afterwards set the timestamp.

    5.2. Samba Filesharing runs under root account. If some file is accessed via samba server, the time stamp and attributes can be set correctly.

    5.3. Make use of a file manager which sets the timestamp using the power of root on a rooted device:
    X-Plore sets file time after copying if root mode is enabled.
    Ghost Commander is said to work fine (additional requirement: Busybox)
    Total Commander 2.04 and newer support changing the time stamp under root account. On Android 5 and newer you need to use link /storage/xxxx-xxxx for external SD, not ///_Name, to make it behave correctly.
    SManager by devwom also deals fine with timestamp using root
    MiXplorer tries calling touch. The standard touch on some Android versions is faulty implemented, MiXplorer then only succeeds when BusyBox (internal download of MiX) is installed. Try if it works on your device with your current setup, and have a second look if the timezone correctly evaluated.

    5.4. Manual call via command line: Who opens a terminal (eg Open Android Terminal) on a rooted device preferrably with BusyBox can execute commands as root.

    Example 5.4.

    Archive (also possible on Unix/Windows/etc)

    cd <Quelle>
    tar -cf <Pfad_zu_Archiv>/Archiv.tar *


    Extract

    cd <Ziel>
    su
    tar -xf <Pfad_zu_Archiv>/Archiv.tar


    Copy

    su
    cp -a <Quelle> <Ziel>


    The command su changes to root user, so that write access to time stamps is possible. It is always possible to read them, so that it is not necessary to su before archive.

    Careful when calling touch: The standard implementation (toybox) seems to be faulty, it does not set the given time when called using -d or -t switch.
    Careful when using Android 8 (root not required), it seems at least some implementation of cp does not set timestamp on cp -a
    3
    I've reinstalled Busybox in /sbin as another guy asks me and I add "cp" and "mv" from Busybox. They keeps timestamps while while standard and toybox commands don't do it. It's a good thing for my scripts :) .

    And now I can see /sbin with TC.
    3
    Thanks OP, I have been searching Google for ways to copy photos to my phone while preserving timestamps and this thread is the only one that provided a usable solution.

    My experience with Samsung Galaxy S4 running stock Lollipop:
    Asus File Manager - Copy via SMB from Windows. Does not preserve timestamps.
    ES File Explorer - Copy via SMB from Windows. Does not preserve timestamps.
    Droid Explorer x64 (PC based, copy via USB/ADB) - Did not preserve timestamps, however, this was recommended in other threads.
    Total Commander - Copy via SMB from Windows. It works perfectly, files copied to External SD preserves timestamps.
    Ghost Commander - Copy via SMB from Windows. Enabled auto root and saw toast notifications it was granted root, but didn't copy to External SD at all. Acted like it was, but nothing was copied. Could not even delete from external SD, got a permission error. Lollipop has an annoying extra step of having to grant write access to External SD. Every other file manager was able to ask for it, Ghost Commander never did.
    X-Plore File Manager - Copy via SMB from Windows. SMB timeout on several files with only option to SKIP. Files copied to External SD did preserve timestamps, but being forced to skip files due to SMB timeout error makes it unusable (no RETRY button).

    For me, looks like Total Commander is the only workable solution so I've uninstalled everything else.
    2
    Does this affect F2FS as well?
    2
    Using ADB to perserve timestamp and attributes when copying

    I found the best way to copy files from my PC to an Andriod device and keep both time stamps and attributes correct, is to use TWRP Boot loader and ADB. (Might work with other bootloaders, but I only tested TWRP (v3.0.0) on Nexus 7.)

    If you have a bunch of file and folders you should be one directory up on the push.
    i.e. Files are in /top/backup on the PC.

    cd into /top

    Then:
    adb devices
    adb reboot recovery
    adb push backup/ /sdcard

    adb shell
    chgrp -R media_rw <FILES>
    chown -R media_rw <FILES>