Skip to content

addpkg(main/python-trash-cli): 0.24.5.26#28877

Open
robertkirkman wants to merge 1 commit into
termux:masterfrom
robertkirkman:python-psutil-fix-disk_partitions
Open

addpkg(main/python-trash-cli): 0.24.5.26#28877
robertkirkman wants to merge 1 commit into
termux:masterfrom
robertkirkman:python-psutil-fix-disk_partitions

Conversation

@robertkirkman
Copy link
Copy Markdown
Member

@robertkirkman robertkirkman commented Mar 11, 2026

In some Termux packages, a fake mountpoint at /storage/emulated/0
is mocked because it successfully causes Trashing files from /storage/emulated/0
and subfolders to go to a new or existing .Trash-$(id -u) folder in /storage/emulated/0 instead of
/storage/emulated being detected as the real mountpoint (it is) and causing
permission denied errors because Termux only has permission for /storage/emulated/0,
not /storage/emulated.
Doing that also reportedly allows Termux to detect and manage .Trash-$(id -u) folders
created in /storage/emulated/0 by desktop PCs when the Android
device was plugged into them and files were then Trashed from the PC file browser,
because there, that location does technically use a real mountpoint.

While such a behavior of special-casing /storage/emulated/0 when it's not
actually a real mountpoint is not part of the XDG Trash specification,
it has been reported that the most natural expected behavior for users trying to
use XDG Trash tools in Termux is for them to treat /storage/emulated/0 as though
it were a mountpoint that should be calculated as a valid directory for .Trash-$(id -u) folders, so this is deviating from the XDG Trash specification in the same way as the Rust packages currently are, meaning that this will allow Python to be able to find and manage the same Trashed files that were Trashed from the Rust packages like yazi, and vice versa.

  • Fixes the error Permission denied: '/proc/filesystems' in the command python -c "import psutil; print(psutil.disk_partitions())"

  • Fixes this series of commands:

pip install trash-cli
termux-setup-storage
cd /storage/emulated/0
touch tempfile
trash-put tempfile

@robertkirkman robertkirkman force-pushed the python-psutil-fix-disk_partitions branch from ddfbc97 to e738897 Compare March 11, 2026 12:11
@robertkirkman
Copy link
Copy Markdown
Member Author

robertkirkman commented Mar 11, 2026

The data being mocked here does vary slightly between different devices, for example on Samsung Galaxy S III it's this,

nodev	sysfs
nodev	rootfs
nodev	bdev
nodev	proc
nodev	cgroup
nodev	tmpfs
nodev	debugfs
nodev	sockfs
nodev	pipefs
nodev	anon_inodefs
nodev	rpc_pipefs
nodev	configfs
nodev	devpts
	ext3
	ext2
	ext4
nodev	ramfs
	vfat
nodev	ecryptfs
nodev	sdcardfs
nodev	nfs
nodev	nfs4
nodev	cifs
	fuseblk
nodev	fuse
nodev	fusectl
	f2fs
nodev	selinuxfs

but this is expected to be an approximation close enough for python-psutil to work, for example, python -c "import psutil; print(psutil.disk_partitions())" still works on Samsung Galaxy S III if it is given the mocked data despite the content of filesystems not exactly matching the real one.

@robertkirkman robertkirkman force-pushed the python-psutil-fix-disk_partitions branch 2 times, most recently from be3c052 to ada948a Compare March 11, 2026 12:31
@robertkirkman
Copy link
Copy Markdown
Member Author

Ok now, on samsung galaxy S III I can see that /proc/filesystems is accessible without root, so some devices do allow access to that without root, so I will make it check whether /proc/filesystems is readable first, then if it's readable use the real one, but fall back to the mock data only if the real one is not readable.

@robertkirkman
Copy link
Copy Markdown
Member Author

this is sufficient to allow the commands pip install trash-cli , trash-empty and trash-list --debug-volumes to work for me

@robertkirkman robertkirkman force-pushed the python-psutil-fix-disk_partitions branch from ada948a to aa932b4 Compare March 11, 2026 15:24
@robertkirkman robertkirkman changed the title fix(main/python-psutil): fix psutil.disk_partitions() fix(main/python{,-psutil}): Implement the fake /storage/emulated/0 mountpoint for the Termux derivative of the XDG Trash specification in Python packages Mar 11, 2026
Comment thread packages/python/0014-pretend-storage-emulated-0-mountpoint.patch Outdated
Comment thread packages/python-psutil/android.patch Outdated
Comment thread packages/python/0014-pretend-storage-emulated-0-mountpoint.patch Outdated
Comment thread packages/python-psutil/build.sh Outdated
@robertkirkman robertkirkman marked this pull request as draft March 12, 2026 18:33
@robertkirkman robertkirkman force-pushed the python-psutil-fix-disk_partitions branch from aa932b4 to 0022358 Compare April 10, 2026 10:11
@robertkirkman robertkirkman changed the title fix(main/python{,-psutil}): Implement the fake /storage/emulated/0 mountpoint for the Termux derivative of the XDG Trash specification in Python packages addpkg(main/python-trash-cli): 0.24.5.26 Apr 10, 2026
@robertkirkman robertkirkman force-pushed the python-psutil-fix-disk_partitions branch from 0022358 to 783787e Compare April 10, 2026 10:12
@robertkirkman robertkirkman marked this pull request as ready for review April 10, 2026 10:12
- termux#28186 but for Python ecosystem instead of Rust ecosystem

- Implement the fake `/storage/emulated/0` mountpoint for the Termux derivative of the XDG Trash specification in `python-trash-cli`

In some Termux packages, a fake mountpoint at `/storage/emulated/0`
is mocked because it successfully causes Trashing files from `/storage/emulated/0`
and subfolders to go to a new or existing `.Trash-$(id -u)` folder in `/storage/emulated/0` instead of
`/storage/emulated` being detected as the real mountpoint (it is) and causing
permission denied errors because Termux only has permission for `/storage/emulated/0`,
not `/storage/emulated`.
Doing that also reportedly allows Termux to detect and manage `.Trash-$(id -u)` folders
created in `/storage/emulated/0` by desktop PCs when the Android
device was plugged into them and files were then Trashed from the PC file browser,
because there, that location does technically use a real mountpoint.

While such a behavior of special-casing `/storage/emulated/0` when it's not
actually a real mountpoint is not part of the XDG Trash specification,
it has been reported that the most natural expected behavior for users trying to
use XDG Trash tools in Termux is for them to treat `/storage/emulated/0` as though
it were a mountpoint that should be calculated as a valid directory for `.Trash-$(id -u)` folders, so this is deviating from the XDG Trash specification in the same way as the Rust packages currently are, meaning that this will allow Python to be able to find and manage the same Trashed files that were Trashed from the Rust packages like `yazi`, and vice versa.

- Fixes the error `Permission denied: '/proc/filesystems'` in the command `python -c "import psutil; print(psutil.disk_partitions())"`

- Fixes this series of commands:

```
pip install trash-cli
termux-setup-storage
cd /storage/emulated/0
touch tempfile
trash-put tempfile
```
@robertkirkman robertkirkman force-pushed the python-psutil-fix-disk_partitions branch from 783787e to b25a93f Compare April 10, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants