Using a computer with Ubuntu 16.04 (no update suggestions please) I mounted /proc/
at my Raspberry Pi 3B + (linux kernel version 4.19.88) via SSHFS:
sshfs [email protected]:/proc ~/procAtPi
ls -la ~/procAtPi
Here ls
shows me all files in the Pi's /proc
without any problems, just as I had connected directly via ssh. But when I try to read the files with cat
, nothing is displayed here. The file content is only output to me when I connect directly via
user@remote:~$ ssh [email protected]
[email protected]:~$ cat /proc/stat
How can I read out a file from procfs that I access via SSHFS?
Some more observations I made:
Using sudo cat ~/procAtPi/stat
leads to Access denied
(So root seems to have fewer access rights than the normal user?) but the files owner is root:
user@remote:~$ ls -lai ~/procAtPi/stat
16 -r--r--r-- 1 root root 0 Dez 24 00:00 stat
The displayed owner differs depending on the access:
user@remote:~$ ls -lai ~/procAtPi/
...
171 dr-xr-xr-x 1 user user 0 Jan 20 09:18 11045
...
[email protected]:~$ ls -lai /proc/
...
2035700 dr-xr-xr-x 8 pi pi 0 Jan 20 09:18 11045
...
Remote access to files in the Pi's sysfs (/sys/
) seems to work fine.
A current workaround is to run a server on the Pi that reads the data from /proc/stat
and makes it available via TCP. To do so, however, I have to start the server manually every time (I don't want an autostart because I don't need it all the time). I need access to proc/stat
for a htop
-like program that is supposed to monitor my Pi cluster.
ls
shows me all files in the Pi's/proc
without any problems, just as I had connected directly viassh
. But when I try to read the files withcat
, nothing is displayed here.
As a workaround, use the -o direct_io
option of sshfs
:
# sshfs localhost:/proc /mnt/tmp
root@localhost's password:
# cat /mnt/tmp/self/stat
<nothing!>
# umount /mnt/tmp
# sshfs -o direct_io localhost:/proc /mnt/tmp
root@localhost's password:
# cat /mnt/tmp/self/stat
8242 (sftp-server) R 8236 8242 8242 0 -1 4194560 335 0 0 0 0 0 0 0 20 0 1 0 1846105 2506752 441 18446744073709551615 94732486082560 94732486157085 140730261312560 0 0 0 0 0 0 0 0 0 17 3 0 0 0 0 0 94732486190800 94732486194248 94732486483968 140730261319328 140730261319357 140730261319357 140730261319643 0
See here for a description of what that option is doing.
The problem with those files under /proc
is that they appear as regular files of size = 0, yet they're not empty and contain data when read.
Notice that this problem is NOT caused by the SFTP protocol, and is not specific to sshfs
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments