andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.58k stars 179 forks source link

Does anyone still have problem problems with ZFS or btrfs? #242

Closed andreafrancia closed 2 years ago

andreafrancia commented 2 years ago

/cc @ejpcmac /cc @twome /cc @oxalica

I'm trying to understand the problems of trash-empty with some filesystem ZSF, brtfs or technologies (WSL). I think that these problems are related to the problem with NFS that was resolved recently. I don't have direct access to machines with these technologies. So I'm asking you to send me information about the misbehavior from your computers.

What I need is: 1) a description of the problem 2) the output of this command: trash-list --debug-volumes

Please redact any sensitive data before sending me the informations. The --debug-volumes options is only available in the latest version of trash-cli, you can install it with: pip uninstall trash-cli && pip install trash-cli

Thank you

twome commented 2 years ago

First off, here's my output running from inside WSL (2), hosted inside Windows 10 64-bit on a physical machine. The Windows OS is stored on C: (SSD, only one "real" partition) and everything else in G: (HDD, only one "real" partition). I'm using the default location for where WSL's FS is stored by Windows (no doubt in some extremely dumb location). The other tiny drive partitions are abortive remnants of a dual-boot.

Filesystem     1024-blocks      Used Available Capacity Mounted on
/dev/sdb         263174212  21968536 227767520       9% /
tmpfs              6517400         0   6517400       0% /mnt/wsl
tools            116558844  93227344  23331500      80% /init
none               6515316         0   6515316       0% /dev
none               6517400         8   6517392       1% /run
none               6517400         0   6517400       0% /run/lock
none               6517400         0   6517400       0% /run/shm
none               6517400         0   6517400       0% /run/user
tmpfs              6517400         0   6517400       0% /sys/fs/cgroup
drivers          116558844  93227344  23331500      80% /usr/lib/wsl/drivers
lib              116558844  93227344  23331500      80% /usr/lib/wsl/lib
C:\              116558844  93227344  23331500      80% /mnt/c
D:\                 306584      5512    301072       2% /mnt/d
F:\                 102396     37600     64796      37% /mnt/f
G:\              819096572 650730496 168366076      80% /mnt/g
physical ->
[sdiskpart(device='/dev/sdb', mountpoint='/', fstype='ext4', opts='rw,relatime,discard,errors=remount-ro,data=ordered', maxfile=255, maxpath=4096)]
virtual ->
[sdiskpart(device='', mountpoint='/dev', fstype='devtmpfs', opts='rw,nosuid,relatime,size=6515316k,nr_inodes=1628829,mode=755',maxfile=255, maxpath=4096),
 sdiskpart(device='', mountpoint='/run', fstype='tmpfs', opts='rw,nosuid,noexec,noatime,mode=755', maxfile=255, maxpath=4096),
 sdiskpart(device='', mountpoint='/run/lock', fstype='tmpfs', opts='rw,nosuid,nodev,noexec,noatime', maxfile=255, maxpath=4096),
 sdiskpart(device='', mountpoint='/run/shm', fstype='tmpfs', opts='rw,nosuid,nodev,noatime', maxfile=255, maxpath=4096),
 sdiskpart(device='', mountpoint='/run/user', fstype='tmpfs', opts='rw,nosuid,nodev,noexec,noatime,mode=755', maxfile=255, maxpath=4096),
 sdiskpart(device='C:\\', mountpoint='/mnt/c', fstype='9p', opts='rw,dirsync,noatime,aname=drvfs;path=C:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8', maxfile=255, maxpath=4096),
 sdiskpart(device='D:\\', mountpoint='/mnt/d', fstype='9p', opts='rw,dirsync,noatime,aname=drvfs;path=D:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8', maxfile=255, maxpath=4096),
 sdiskpart(device='F:\\', mountpoint='/mnt/f', fstype='9p', opts='rw,dirsync,noatime,aname=drvfs;path=F:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8', maxfile=255, maxpath=4096),
 sdiskpart(device='G:\\', mountpoint='/mnt/g', fstype='9p', opts='rw,dirsync,noatime,aname=drvfs;path=G:\\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8', maxfile=255, maxpath=4096),
 sdiskpart(device='binfmt_misc', mountpoint='/proc/sys/fs/binfmt_misc', fstype='binfmt_misc', opts='rw,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/cpuset', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,cpuset', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/cpu', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,cpu', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/cpuacct', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,cpuacct', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/blkio', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,blkio', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/memory', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,memory', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/devices', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,devices', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/freezer', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,freezer', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/net_cls', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,net_cls', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/perf_event', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,perf_event', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/net_prio', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,net_prio', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/hugetlb', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,hugetlb', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/pids', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,pids', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup', mountpoint='/sys/fs/cgroup/rdma', fstype='cgroup', opts='rw,nosuid,nodev,noexec,relatime,rdma', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup2', mountpoint='/sys/fs/cgroup/unified', fstype='cgroup2', opts='rw,nosuid,nodev,noexec,relatime,nsdelegate', maxfile=255, maxpath=4096),
 sdiskpart(device='devpts', mountpoint='/dev/pts', fstype='devpts', opts='rw,nosuid,noexec,noatime,gid=5,mode=620,ptmxmode=000', maxfile=255, maxpath=4096),
 sdiskpart(device='drivers', mountpoint='/usr/lib/wsl/drivers', fstype='9p', opts='ro,dirsync,nosuid,nodev,noatime,aname=drivers;fmask=222;dmask=222,mmap,access=client,msize=65536,trans=fd,rfd=4,wfd=4', maxfile=255, maxpath=4096),
 sdiskpart(device='lib', mountpoint='/usr/lib/wsl/lib', fstype='9p', opts='ro,dirsync,nosuid,nodev,noatime,aname=lib;fmask=222;dmask=222,mmap,access=client,msize=65536,trans=fd,rfd=4,wfd=4', maxfile=255, maxpath=4096),
 sdiskpart(device='proc', mountpoint='/proc', fstype='proc', opts='rw,nosuid,nodev,noexec,noatime', maxfile=255, maxpath=4096),
 sdiskpart(device='sysfs', mountpoint='/sys', fstype='sysfs', opts='rw,nosuid,nodev,noexec,noatime', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/mnt/wsl', fstype='tmpfs', opts='rw,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/sys/fs/cgroup', fstype='tmpfs', opts='rw,nosuid,nodev,noexec,relatime,mode=755', maxfile=255, maxpath=4096),
 sdiskpart(device='tools', mountpoint='/init', fstype='9p', opts='ro,dirsync,relatime,aname=tools;fmask=022,loose,access=client,trans=fd,rfd=6,wfd=6', maxfile=255, maxpath=4096)]
andreafrancia commented 2 years ago

I made a commit that can solve the problem on WSL, but I don't have an Windows computer where to check the result. Can you try on your computer, please? You need just to download the latest version using pip:

pip install --upgrade trash-cli

Thank you

twome commented 2 years ago

I just trashed a /mnt/g/... file from inside WSL and it seemed to work fine! I can find the trashed file in my /mnt/g/.Trash-1000/ dir. Running trash-list with the process working directory @ /mnt/g/ or a subdirectory unfortunately still uses the inside-WSL trash dir by default (and so can't see the trash dir that was created in /mnt/g).

/mnt/g
❯ trash-list --volumes
/

/mnt/g
❯ trash -v downloads/EpicInstaller-10.17.0.msi
trash: Volume of file: /mnt/g
trash: Trash-dir: /home/leon/.local/share/Trash from volume: /
trash: found unusable .Trash dir (should be a dir): /mnt/g/.Trash
trash: Trash-dir: /mnt/g/.Trash-1000 from volume: /mnt/g
trash: 'downloads/EpicInstaller-10.17.0.msi' trashed in /mnt/g/.Trash-1000

Interestingly, /mnt/g/.Trash does not exist; only .Trash-1000 does.

But your patch definitely addresses the major blockage - thanks so much! Your program's so useful it occupies my t shell alias :)

andreafrancia commented 2 years ago

Has been a pleasure, thanks to you. I'm glad that something starts working. I'm not sure I understand the current problem, can you send an/some usage example/s that shows me what is working and what is not working?

twome commented 2 years ago

Sorry, it's probably clearer to explain with a CLI log:

~
❯ trash-list

~
❯ touch example.txt

~
❯ trash example.txt

~
❯ trash-list
2022-08-22 18:52:59 /home/leon/example.txt

~
❯ cd /mnt/g

/mnt/g
❯ rm -rf .Trash-1000

/mnt/g
❯ touch G-example.txt

/mnt/g
❯ trash G-example.txt

/mnt/g
❯ trash-list
2022-08-22 18:52:59 /home/leon/example.txt

/mnt/g
❯ cat .Trash-1000/info/G-example.txt.trashinfo
[Trash Info]
Path=G-example.txt
DeletionDate=2022-08-22T18:58:00

/mnt/g
❯ trash-empty
Would empty the following trash directories:
    - /home/leon/.local/share/Trash
Proceed? (y/n)

So, the "put into trash" operation is correctly detecting that I'm inside /mnt/g, which is a separate physical drive, and it's correctly creating a trash directory inside /mnt/g/ to store files trashed from inside there. But unlike trash, trash-empty and trash-list don't seem to know they're being run from inside /mnt/g, and so they still refer to the default/root trash dir.

andreafrancia commented 2 years ago

Ok, thank you, now I understand. I will investigate.

andreafrancia commented 2 years ago

There is something I cannot yet understand.

Please run again these commands:

$ trash-list --version
$ trash-list --debug-volumes
$ trash-list --volumes
$ ls -lad /mnt/g
$ ls -lad /mnt/g/.Trash-1000/

Thank you

ejpcmac commented 2 years ago

Hello, with trash-cli 0.22.4.16, installed from the NixOS package manager, it is now working properly on ZFS.

0xadeeb commented 2 years ago

I don't know if this problem is apt in this thread but recently I switched my file system from ext4 to btrfs. In ext4 I used to use crontab to auto delete my trash using trash-empty 14 command and it worked well there. But after moving to btrfs it wasn't working. While I ran trash-empty command manually is showed me a prompt to confirm if I wanted to delete a specific trash directory. After going through the manual I couldn't find a "--no-confirm" or some option to avoid the confirmation prompt. So is there any way to automatically delete trash using trash-empty in my system? Edit: I couldn't find anything in the docs but trying the "f" flag trash-empty 14 -f worked, is this the correct way to do it?

andreafrancia commented 2 years ago

I think that all issue found in this thread have been solved. I’m closing this issue. Fell free to add comments and/or open another issue if your problem is not yet solved.