I have already tried mounting the filesystems without checking like this:
sudo -- mount -t proc /proc $chroot_dir/proc
sudo -- mount --bind /tmp $chroot_dir/tmp
However, this would corrupt the parent OS session if already mounted, and I would have to restart the OS. I want to check if they're mounted beforehand.
You can see in /etc/mtab
what's currently mounted:
if grep $chroot_dir/proc /etc/mtab; then
echo already mounted
fi;
And analogously for tmp
.