Test for the existence of /proc/mounts
. Running mount
is no good because if /proc
isn't mounted, it will return potentially obsolete data from /etc
.
In theory there might be something else at /proc
. But this is extremely unlikely in practice: if /proc/mounts
exists and /proc
isn't the proc
filesystem, you can't trust anything about your environment anyway. If you're really worried, you can check that the filesystem type is proc
: df -PT /proc | awk 'NR==2 && $2=="proc" {print 1}'
(requires the Linux utilities df
, there's no corresponding option in Busybox). Conversely, in theory, there could be a proc filesystem mounted in a different place; there's no easy way to find this with shell commands (df
reads /proc/mounts
to enumerate filesystems). In practice, just check for /proc/mounts
.