Nasty bug from Android: Could it be fixed in FP Open OS?

In Android 7 and prior, there is a nasty bug that Google steadfastedly refuses to fix: When you copy a file , which on SD cards can only be done through streams, the copy will always get the current date and time and not that of the original file. Furthermore, even with the few tools that allow you to change a timestamp (Total Commander, or a shell like Temux) this fails due to lack of rights. Only the root user is allowed to modify atime, mtime, ctime.

I believe this could be faily easy to fix in Open OS…

I call this nasty, because it means that you cannot “clean up” your SD card by creating folders and sorting images into them…


Add’l remark: You cannot circumvent this by copying over MTP, i.e. USB and a PC that you connect to the phone. All files copied through MTP also get the current timestamp, and changing a timestamp isn’t even supported by MTP…

Is this in the stock file manager? I use Root Explorer and copied files preserve the modified date.

If you use adb pull -a or adb push -a, the date is also preserved.

Hm, haven’t tried the debug bridge so far. Wenn I plug the Fairphone into my Linux PC, the Fairphone opens via MTP, presenting me both the internal storage and the SD card. Everything I copy into there gets the current timestamp, and editing timestamps is not supported, even if you try it in a shell.

I just copied over a file from my SD card to my PC through MTP (through Nemo’s GUI), it preserved the timestamp. What method are you using exactly?

Edit: I didn’t read your post closely, and I can confirm that copying a file from PC to the FP2 resets the timestamp.

Using MTP, the phone’s filesystems are mounted at /run/user/1000/gvfs/mtp:host=[your phone here]. Files can be copied to and from any directory, but the timestamp is not preserved. Using cp -p, which specifically preserves the timestamp, gives the following error:

cp: preserving times for ‘/run/user/1000/gvfs/mtp:host=Fairphone_FP2_f97ab66d/sdcard1/folder.png’: Operation not supported

Which is presumably something to do with the fact that MTP does not allow modification of files, only uploads and downloads of entire files. When a copy action is configured to preserve the timestamp, it means the file is copied over and then the modified date is copied over from the original (much like if you were to use touch -r originalfile.ext newfile.ext).

So I feel pretty confident saying that MTP inherently does not allow the preservation of timestamps.

Yep, the (well documented) bug in Android affects file creations, therefore copying FROM the fairphone is absolutely okay, but not copying TO the fairphone. The same goes for copying ON the fairphone.

If you go to the command line on the PC side (every MTP connetion is inserted into the filesystem at /run/user/[userid]/gvfs) and try atime, mtime, ctime you will get the error message. But I am NOT sure whether MTP is the problem. If you open a shell on the Fairphone (e.g. Temux) and try to edit a file’s timestamp there, you will immediately get the error that you lack the priviledges to do so. And THAT is a documented bug in all Android 7 or earlier. In Oreo they fixed it, but not 7 and earlier. I believe it should be fairly easy to fix by the maintainers of FP Open OS…

From what I can make out from the MTP spec there is a feature called SetObjectPropList that may be able to modify metadata? I’m guessing that’s what’s been implemented in newer Android versions. It only works on devices that support it, so it looks like you’re right in that it is an issue with Android.

I’m sticking with good old ADB either way but I recommend adding this issue to the bugtracker (maybe with a link to this thread) as it strikes as a fairly easy fix for an upcoming update.

The bug is that ALL copy operations on Android 7 and earlier will get the current timestamp, regardless of how the copy is performed. Tried it locally (Amaze, Total Commander, Ghost Commander), tried it via MTP. Each and every time. Amaze’s developers tell me it’s a bug, and you can google it. Open a Temux shell and try to set atime, mtime, ctime on ANY file, you will immediately be prompted that you lack the rights to that.

When I copy a file with Root Explorer, the timestamp is preserved - now we’re just talking about a normal filesystem where it’s easy to adjust metadata, so I have to imagine that the problem there is app-based rather than system-based.

There’s a free version of Root Explorer, so maybe try it with that? If it doesn’t work, it looks as though your system may have something going on with it.

I’ll give root explorer a try, but it is definitely NOT easy to adjust metadata, if the operating system does not let you. And this bug means it does not, simply because only root has the permissions to adjust metadata. That is the bug. You simply get a “permission denied” error when you try.

No kidding - you’re dead on. I think my confusion stemmed from never having used Android without root access. It’s an annoying bug for sure.

FWIW, devs have been coy but suggestive about an upgrade to Android 8 for the FP2, and if you’re really bothered you can upgrade to Lineage to get the full Pie experience.

Well, I opened this topic unter Fairphone Open OS. Where you do not have root access per se. And in all normal Androids you do not have root access.

I personally think that the reasoning behind that is sound. For security sake you should not run daily business with root priviledges. It is the #1 security measure everywhere. Even admins in corporations work with regular (limited) user accounts. When they need a higher priviledge level, they must log out and log in with special accounts, which in turn are fully (!) logged and monitored, so that no one abuses these (temporary) priviledges.

I find the very same principle a good basis for designing an operating system. But I do not understand why Google decided that a regular user should not have the priviledge level to modify atime, ctime or mtime of a file the user himself/herself has created…

No one needs root priviledges for daily business. If anyone needs root for even one ordinary, daily task, even if it is a small one, then the system design is flawed.

And as I said, Google corrected this bug. But only with Oreo…

Since it is “only” a missing permission, I believe the devs from Fairphone Open have the opportunity to make FPOS Nougat better than Nougat from Google…

Peculiarities like these are the reason why Linux devs strongly oppose the mentioning that Android would be “Linux based”. They prefer the wording “Google based”, because it lacks most of the things that make up a good Linux… The way Google treats devices and file systems on Android is pure horror.

Same for me :wink:

Currently on LOS it’s officially the Android 10 “Q” experience :grinning:

1 Like

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