whoozle / android-file-transfer-linux

Android File Transfer for Linux (and macOS!)
http://whoozle.github.io/android-file-transfer-linux/
GNU Lesser General Public License v2.1
1.43k stars 120 forks source link

du(1) doesn't work with FUSE #338

Closed mnalis closed 4 months ago

mnalis commented 7 months ago

E.g.


% aft-mtp-mount ~/mnt

% cd "~/mnt/Internal storage/DCIM/Camera"

% ls -la | head
total 0
drwxr-xr-x 0 root root        0 Dec 17 14:32 .
drwxr-xr-x 0 root root        0 Dec  7 16:38 ..
-rw-r--r-- 0 root root  3470422 Dec  7 16:38 20231207_163840.jpg
-rw-r--r-- 0 root root  3666784 Dec  7 17:05 20231207_170533.jpg
-rw-r--r-- 0 root root  3598267 Dec  8 10:18 20231208_101823.jpg
-rw-r--r-- 0 root root  2516511 Dec  8 11:15 20231208_111527.jpg
-rw-r--r-- 0 root root  4598054 Dec  8 11:15 20231208_111537.jpg
-rw-r--r-- 0 root root  4766333 Dec  8 11:48 20231208_114807.jpg
-rw-r--r-- 0 root root  2661973 Dec  8 14:05 20231208_140517.jpg

% du
0       .

du --apparent-size work correctly. It would be nice if regular du(1) also worked. It seems to be because st_blocks is always zero:

% stat 20231207_163840.jpg
  File: 20231207_163840.jpg
  Size: 3470422         Blocks: 0          IO Block: 4096   regular file
Device: 0,33    Inode: 1002137     Links: 0
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1970-01-01 01:00:00.000000000 +0100
Modify: 2023-12-07 16:38:41.000000000 +0100
Change: 2023-12-07 16:38:41.000000000 +0100
Birth: -

While we're there, can we also fill nlink field with reasonable values instead of 0 (like 1 for files and 2 for directories)?

android-file-transfer 4.2-1, default Debian Bookworm package, Samsung Galaxy S23+.

whoozle commented 7 months ago

it looks like nlink has been fixed in 4.3. can you try upgrading and check it again?

mnalis commented 7 months ago

it looks like nlink has been fixed in 4.3. can you try upgrading and check it again?

Thanks! Not present in Debian yet, but I've fetched and compiled 4.3 now, and indeed it seems to have nlink==1 everywhere, which seems good enough for me (it is not strictly correct, if one counts same inode numbers in ls -liaR output and compares it to number of links, but expecting more precision would be too much nitpicking for fuse FS which likely fakes inode numbers anyway :smiley_cat:)

The main issue (that du(1) returns 0) is still present in 4.3, though.

whoozle commented 6 months ago

can you try b4878efd0fbff84f4731c45828650b795ba40657 ? (just pull master and check if it works for you)

mnalis commented 6 months ago

I've tried the latest master b4878ef and du(1) now indeed seems to work correctly!

% ls -la | head
total 1153825
drwxr-xr-x 1 root   root          0 Jan 13 13:16 .
drwxr-xr-x 1 mnalis mnalis        0 Dec 26 12:06 ..
-rw-r--r-- 1 root   root    3470422 Dec  7 16:38 20231207_163840.jpg
-rw-r--r-- 1 root   root    3666784 Dec  7 17:05 20231207_170533.jpg
-rw-r--r-- 1 root   root    3598267 Dec  8 10:18 20231208_101823.jpg
-rw-r--r-- 1 root   root    2516511 Dec  8 11:15 20231208_111527.jpg
-rw-r--r-- 1 root   root    4598054 Dec  8 11:15 20231208_111537.jpg
-rw-r--r-- 1 root   root    4766333 Dec  8 11:48 20231208_114807.jpg
-rw-r--r-- 1 root   root    2661973 Dec  8 14:05 20231208_140517.jpg

% du
1153825 .

% du --apparent-size
1153757 .

% stat 20231207_163840.jpg
  File: 20231207_163840.jpg
  Size: 3470422         Blocks: 6779       IO Block: 4096   regular file
Device: 0,33    Inode: 1000045     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1970-01-01 01:00:00.000000000 +0100
Modify: 2023-12-07 16:38:41.000000000 +0100
Change: 2023-12-07 16:38:41.000000000 +0100
 Birth: -

Thanks, and hoping for next fixed release soon!

whoozle commented 4 months ago

yeah, I'm gonna release new version soon - after people see version numbers on macosx