Android: "operation not permitted" on open .tmp file

How to fix this error and sync files? I can’t sync files with my Android Syncthing 1.19 and Syncthing 1.19 on Archlinux: “operation not permitted”.

Also it writes: “Filesystem: Watcher Errors”

This is Xperia 10 II, Android 11, LineageOS 18.1-20211101.

See log below.

Thanks

Some messages from log:

2022-02-21 15:03:29 Scanner (folder "ref" (-), item "Курсы на stepik.org/.git/objects/1f"): scan: readdirent /storage/emulated/0/mydir/ref/Курсы на stepik.org/.git/objects/1f: invalid argument
2022-02-21 15:03:30 Puller (folder "books" (-), item "Pull Request Etiquette for Reviewers and Authors | by Meng Taing | Better Programming | Medium_files/8286.js"): syncing: opening temp file: open /storage/emulated/0/mydir/books/Pull Request Etiquette for Reviewers and Authors | by Meng Taing | Better Programming | Medium_files/.syncthing.8286.js.tmp: operation not permitted
...
2022-02-21 15:05:41 "books" (-): Failed to sync 68 items

You’ve got funky characters like | and ? in your filenames. The Android storage is likely formatted as FAT, which doesn’t support them, hence the errors when trying to sync the files.

Not sure how to check it. I used `mount | grep “^/dev” and it shows ‘fuse’:

/dev/fuse on /storage/emulated type fuse (rw,lazytime,nosuid,nodev,noexec,noatime,user_id=0,group_id=0,allow_other)
/dev/fuse on /storage/3233-3731 type fuse (rw,lazytime,nosuid,nodev,noexec,noatime,user_id=0,group_id=0,allow_other)

Other lines has ext4.

vfat for

/dev/block/bootdevice/by-name/bluetooth_b on /vendor/bt_firmware type vfat (ro,context=u:object_r:bt_firmware_file:s0,relatime,uid=1002,gid=3002,fmask=0337,dmask=0227,codepage=437,iocharset=utf8,shortname=lower,errors=remount-ro)

and other.

It keeps breaking with such messages:

2022-03-12 14:49:26 TCP listener ([::]:22000) starting
2022-03-12 14:49:26 Listing network interfaces: route ip+net: netlinkrib: permission denied
2022-03-12 14:49:26 ...
2022-03-12 17:30:46 Puller (folder "notes" (), item ".git/objects/fa/f0c1650baba0d364b466c6891afde26a795122"): syncing: checking parent dirs: readdirent /storage/emulated/0/mydir/notes/.git/objects: invalid argument
...
2022-03-12 17:30:46 Puller (folder "books" (), item "Pull Request Etiquette for Reviewers and Authors | by Meng Taing | Better Programming | Medium_files/1TyRLQdZO7NdPATwSeut8gg.png"): syncing: opening temp file: open /storage/emulated/0/mydir/books/Pull Request Etiquette for Reviewers and Authors | by Meng Taing | Better Programming | Medium_files/.syncthing.1TyRLQdZO7NdPATwSeut8gg.png.tmp: operation not permitted

...
2022-03-12 17:30:46 Puller (folder "books" (), item "Pull Request Etiquette for Reviewers and Authors | by Meng Taing | Better Programming | Medium_files/2602.js"): syncing: opening temp file: open /storage/emulated/0/mydir/books/Pull Request Etiquette for Reviewers and Authors | by Meng Taing | Better Programming | Medium_files/.syncthing.2602.js.tmp: operation not permitted

...
2022-03-12 17:40:04 Error while trying to start filesystem watcher for folder "ref" (wqnc4-kxns5), trying again in 1h4m0s: readdirent /storage/emulated/0/mydir/ref/dotfiles/nvim/pack/minpac/start/fzf.vim/.git/objects/16: invalid argument
...
2022-03-12 17:40:35 Scanner (folder "ref" (wqnc4-kxns5), item "dotfiles/nvim/pack/minpac/start/fzf.vim/.git/objects/16"): scan: readdirent /storage/emulated/0/mydir/ref/dotfiles/nvim/pack/minpac/start/fzf.vim/.git/objects/16: invalid argument
2022-03-12 17:49:35 Listing network interfaces: route ip+net: netlinkrib: permission denied

There are several ways to check it (e.g. see https://android.stackexchange.com/questions/105077/how-to-find-out-which-file-system-is-used-by-my-device). You’re using LineageOS, so I’d guess you’ve also got a custom recovery like TWRP installed which also allows to check the currently used filesystems.

Although, unless you’ve manually formatted the partition to something else, it will almost surely be FAT, because that’s been the default in Android since the very beginning. Some custom ROMs may allow to format it as EXT4 and still remain usable.

I didn’t find any FAT. It only shows ‘fuse’ and ‘ext4’. The Syncthing dir is /storage/emulated/0/mydir.

When booted into the system. Tried DiskInfo, tried adb shell df, adb shell mount. All those display “fuse” filesystem for /storage/emulated/0.

❯ adb shell df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/block/dm-6       2.2G  1.1G  1.1G  50% /
tmpfs                 1.7G  1.2M  1.7G   1% /dev
tmpfs                 1.7G     0  1.7G   0% /mnt
/dev/block/dm-7       1.4G  342M  1.1G  23% /product
/dev/block/dm-8       844M  351M  477M  43% /vendor
tmpfs                 1.7G     0  1.7G   0% /apex
/dev/block/mmcblk0p51  27M   13M   14M  50% /vendor/dsp
/dev/block/mmcblk0p86 102G   44G   58G  43% /data
/dev/block/loop6      8.4M  8.4M     0 100% /apex/com.android.permission@300000000
/dev/block/loop7      864K  836K   12K  99% /apex/com.android.tethering@300000000
/dev/block/loop8       18M   18M     0 100% /apex/com.android.media.swcodec@300000000
/dev/block/loop9      128M  125M  1.0M 100% /apex/com.android.vndk.v30@1
/dev/block/loop10     3.8M  3.8M     0 100% /apex/com.android.extservices@300000000
/dev/block/loop11     3.6M  3.6M     0 100% /apex/com.android.mediaprovider@300000000
/dev/block/loop12      82M   82M     0 100% /apex/com.android.art@1
/dev/block/loop13     4.7M  4.7M     0 100% /apex/com.android.wifi@300000000
/dev/block/loop14     336K  304K   28K  92% /apex/com.android.sdkext@300000000
/dev/block/loop15     4.5M  4.5M     0 100% /apex/com.android.media@300000000
/dev/block/loop16     5.0M  4.9M     0 100% /apex/com.android.runtime@1
/dev/block/loop17     848K  820K   12K  99% /apex/com.android.tzdata@300000000
/dev/block/loop18     1.6M  1.6M     0 100% /apex/com.android.os.statsd@300000000
/dev/block/loop19     232K   92K  136K  41% /apex/com.android.apex.cts.shim@1
/dev/block/loop20     6.2M  6.1M     0 100% /apex/com.android.cellbroadcast@300000000
/dev/block/loop21     2.3M  2.3M     0 100% /apex/com.android.resolv@300000000
/dev/block/loop22     524K  496K   20K  97% /apex/com.android.ipsec@300000000
/dev/block/loop23     5.5M  5.5M     0 100% /apex/com.android.neuralnetworks@300000000
/dev/block/loop24     4.6M  4.5M     0 100% /apex/com.android.conscrypt@300000000
/dev/block/loop25     7.5M  7.5M     0 100% /apex/com.android.adbd@300000000
/dev/block/loop26      24M   24M     0 100% /apex/com.android.i18n@1
/dev/fuse             102G   44G   58G  43% /storage/emulated

When booted into recovery and the system mounted. It shows ‘ext4’:

/dev/block/dm-4 on /mnt/system type ext4 (ro,seclabel,relatime,discard)

/system (and /data) is usually formatted to ext4. You need to look for the internal storage or /sdcard. Please keep in mind that re-formatting the partition in recovery will delete all files located there.

Thanks. It requires root? I didn’t see /data when running adb shell mount inside recovery. It seems not to mount /data. Not sure how to check if /storage/emulated/0 (this is where the dir) is FAT or not. Will search more.

Tried to set “Ignore permissions” on the source machine. Still that “Operation not permitted” error

As mentioned above, this has nothing to do with file permissions. The filesystem just doesn’t support the special characters that are used in those filenames (e.g. ? or |).

You need to either switch to a different filesystem (if even possible) or simply rename the files on the source device, removing the special characters from their names.

1 Like

Ok, but why ‘invalid argument’ error?

2022-03-12 17:30:46 Puller (folder "notes" (), item ".git/objects/fa/f0c1650baba0d364b466c6891afde26a795122"): syncing: checking parent dirs: readdirent /storage/emulated/0/mydir/notes/.git/objects: invalid argument
...

Not really sure where the other error is coming from. I’ve tried searching for it, but I couldn’t find anything related neither on the forum nor on GitHub. As far as I understand, the invalid argument error message itself comes from the OS (which is Android in this case).

1 Like

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