WARN tar EPERM: operation not permitted, futime
indicates that futime
syscall (used to change file last access and modification times) fails with error: EPERM
. From utime
manpage 1:
EPERM ... the caller's effective UID does not match the owner of the file ...
That seems to be the reason of failure. You are using path: /data/data/com.termux/files/home/storage/shared/
which is actually /sdcard/
2 (symlink to /storage/emulated/0/
). It's not an actual filesystem but an emulated 3 view of underlying filesystem (ext4
or f2fs
). It has fixed permissions and doesn't support many features of Linux filesystems including symlinks and ioctls
like FS_IOC_FIEMAP
4.
Due to fixed permissions all directories and files in /sdcard/
are always owned by user root
(UID 0
). So while trying to change file's timestamp, Operation not permitted
is returned. touch
command however uses utimensat
5 which has different permissions requirements.
So to avoid this problem, you should not use emulated filesystem. Termux $HOME
directory is on ext4
or f2fs
, so it's a good place to save files. Use e.g. /data/data/com.termux/files/home/npm-test
directory.
From comments:
But is it possible to somehow create a link inside $HOME
to another location, which will grant all the rights that Termux has for $HOME
for all the subfolders of this distant location?
No it's not possible on non-rooted phone. Apps can write only to their private directories in internal storage (which is /data/data/com.termux
for Termux) and in shared storage (/sdcard/Android/data/com.termux
). Apps with Storage
permission granted can read and write to whole /sdcard/
. There is no other place on device where apps can save files 6. With SELinux disabled
or permissive
, it's possible to write to a sub-directory created (with adb shell
) in /data/local/tmp
, but it's not intended use of this directory.
LINKS:
1 utime
manpage
2 How do I access $HOME/storage
outside of Termux (with a file explorer)?
3 What is /storage/emulated/0/
?
4 How can I make a symlink inside /storage/emulated/0
?
5 How to change the modified date of a file without root?
6 Where Android apps store data?