simple-mtpfs
simple-mtpfs copied to clipboard
Unison can't sync properly existing files over MTPFS
I've tried the following (and this is repeatable on multiple devices, with different Android versions, e.g. LineageOS 15.1 on Samsung Tablet vs. Android 8.1.0 on BQ Phone):
simple-mtpfs dirA
mkdir -p dirA/testdir
mkdir dirB
echo Android > dirA/testdirA/test.txt
echo PC > dirB/testdirB/test.txt
then setup unison to sync testdirA with testdirB.
- first sync -> unison shows a conflict, decide in favour of the PC, sync, all looks well
- 2nd sync -> unison states:
test.txt Error: Two or more files on a case-sensitive system have names identical except for case. They cannot be synchronized to a case-insensitive file system. (File 'test.txt')
$ ll dirA/testdirA
total 1
-rw-r--r--. 1 ericl ericl 3 Jul 14 10:35 test.txt
-rw-r--r--. 1 ericl ericl 3 Jul 14 10:35 test.txt
(notice the size of 3 for both files)
- on the Android device, there is only one test.txt file and it has the right content "PC"
- un-plug, re-plug, re-mount the Android device:
$ ll -ia dirA/testdirA
total 1
3 -rw-r--r--. 1 ericl ericl 8 Jul 14 10:34 test.txt
4 -rw-r--r--. 1 ericl ericl 3 Jul 14 10:35 .unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
$ cat dirA/testdirA/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
cat: /tmp/bla/rdtmp/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp: Numerical result out of range
$ cat dirA/testdirA/rdtmp/test.txt
PC
(the file .unison.test...
definitely isn't seen on Android)
While doing the last 3 commands (1x ls + 2 x cat) shows in debug mode the following:
unique: 187, opcode: LOOKUP (1), nodeid: 1, insize: 46, pid: 6798
LOOKUP /testdirA
getattr /testdirA
NODEID: 2
unique: 187, success, outsize: 144
unique: 188, opcode: OPENDIR (27), nodeid: 2, insize: 48, pid: 6798
opendir flags: 0x18800 /testdirA
opendir[0] flags: 0x18800 /testdirA
unique: 188, success, outsize: 32
unique: 189, opcode: READDIR (28), nodeid: 2, insize: 80, pid: 6798
readdir[0] from 0
unique: 189, success, outsize: 136
unique: 190, opcode: LOOKUP (1), nodeid: 2, insize: 101, pid: 6798
LOOKUP /testdirA/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
getattr /testdirA/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
NODEID: 4
unique: 190, success, outsize: 144
unique: 191, opcode: LOOKUP (1), nodeid: 2, insize: 49, pid: 6798
LOOKUP /testdirA/test.txt
getattr /testdirA/test.txt
NODEID: 3
unique: 191, success, outsize: 144
unique: 192, opcode: READDIR (28), nodeid: 2, insize: 80, pid: 6798
unique: 192, success, outsize: 16
unique: 193, opcode: RELEASEDIR (29), nodeid: 2, insize: 64, pid: 0
releasedir[0] flags: 0x0
unique: 193, success, outsize: 16
unique: 194, opcode: LOOKUP (1), nodeid: 1, insize: 46, pid: 6805
LOOKUP /testdirA
getattr /testdirA
NODEID: 2
unique: 194, success, outsize: 144
unique: 195, opcode: LOOKUP (1), nodeid: 2, insize: 101, pid: 6805
LOOKUP /testdirA/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
getattr /testdirA/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
NODEID: 4
unique: 195, success, outsize: 144
unique: 196, opcode: OPEN (14), nodeid: 4, insize: 48, pid: 6805
open flags: 0x8000 /testdirA/.unison.test.txt.a8cbe6a01ee35a5b7a3843a1058af622.unison.tmp
Error 2: PTP Layer error 02fe: LIBMTP_Get_File_To_File_Descriptor(): Could not get file from device.
Error 2: Error 02fe: PTP Data Expected
fuse: bad error value: 2
unique: 196, error: -34 (Numerical result out of range), outsize: 16
unique: 197, opcode: LOOKUP (1), nodeid: 1, insize: 46, pid: 6813
LOOKUP /testdirA
getattr /testdirA
NODEID: 2
unique: 197, success, outsize: 144
unique: 198, opcode: LOOKUP (1), nodeid: 2, insize: 49, pid: 6813
LOOKUP /testdirA/test.txt
getattr /testdirA/test.txt
NODEID: 3
unique: 198, success, outsize: 144
unique: 199, opcode: OPEN (14), nodeid: 3, insize: 48, pid: 6813
open flags: 0x8000 /testdirA/test.txt
open[4] flags: 0x8000 /testdirA/test.txt
unique: 199, success, outsize: 32
unique: 200, opcode: READ (15), nodeid: 3, insize: 80, pid: 6813
read[4] 4096 bytes from 0 flags: 0x8000
read[4] 3 bytes from 0
unique: 200, success, outsize: 19
unique: 201, opcode: GETATTR (3), nodeid: 3, insize: 56, pid: 6813
getattr /testdirA/test.txt
unique: 201, success, outsize: 120
unique: 202, opcode: READ (15), nodeid: 3, insize: 80, pid: 6813
read[4] 4096 bytes from 0 flags: 0x8000
read[4] 3 bytes from 0
unique: 202, success, outsize: 19
unique: 203, opcode: FLUSH (25), nodeid: 3, insize: 64, pid: 6813
flush[4]
unique: 203, success, outsize: 16
unique: 204, opcode: RELEASE (18), nodeid: 3, insize: 64, pid: 0
release[4] flags: 0x8000
unique: 204, success, outsize: 16
In my opinion, there are potentially 2 errors:
- overwriting a file didn't work properly
- simple-tmpfs seems to keep some kind of (wrong) cache across re-mounting a file system
Perhaps there is a smart combination of options that would make it work, but there are so many of them that at least a hint which one(s) could be helpful would be really nice.
After a reboot of the PC, the issue is gone, so it sounds really like a caching issue. I tried again with direct_io but the result was the same (debug log: mtpfs_debug.txt