btfs
btfs copied to clipboard
preserve the original file order for sequential access
i want to download large torrents with many files in sequential order and process the content files in their original order in the torrent which is some random sort order, not abc order
currently ls -U returns files in abc order, not in the original order
man ls
-U do not sort; list entries in directory order
when i have access to the torrent file, i can do
mkdir mount_dir
btfs test.torrent mount_dir
torrenttools show files test.torrent | while read path; do
md5sum mount_dir/*/"$path"
done
fusermount -u mount_dir
... but ideally this should also work via the filesystem
to make this work recursively we could abuse the file times to encode the file order
all file times (atime, btime, ctime, mtime) should be set to some pseudo time for example timestamp zero (year 1970) plus the file index as seconds
so i get sequential access with
mkdir mount_dir
btfs test.torrent mount_dir
# %T = mtime
find mount_dir/ -type f -printf '%T@ %P\n' | sort -n | cut -c23- | while read path; do
md5sum "$path"
done
fusermount -u mount_dir
current file times: mtime = mount time atime = zero ctime = zero btime = missing
$ TZ=C stat mount_dir/aaa/bbb
File: mount_dir/aaa/bbb
Size: 481515 Blocks: 0 IO Block: 4096 regular file
Device: 0,76 Inode: 24029 Links: 0
Access: (0444/-r--r--r--) Uid: ( 1000/ user) Gid: ( 100/ users)
Access: 1970-01-01 00:00:00.000000000 +0000
Modify: 2024-07-25 20:36:48.000000000 +0000
Change: 1970-01-01 00:00:00.000000000 +0000
Birth: -