Skip to content

Instantly share code, notes, and snippets.

@alban
Created January 5, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alban/75f605b8606b195008d6 to your computer and use it in GitHub Desktop.
Save alban/75f605b8606b195008d6 to your computer and use it in GitHub Desktop.
udevd-experiment.sh
#!/bin/bash
set -e
# Try with:
# sudo $PWD/udevd-experiment.sh
THIS_SCRIPT=$0
if [ "$1" = "udevd1" ] ; then
unshare --propagation unchanged -m $THIS_SCRIPT udevd2
exit 0
fi
if [ "$1" = "udevd2" ] ; then
mount --make-rslave /
mount --make-rshared /
sleep 5000
exit 0
fi
$THIS_SCRIPT udevd1 &
sleep 1
DIR=/tmp/udevd-experiment-$RANDOM
mkdir $DIR
cd $DIR
mkdir rootfs
mount --bind / $DIR/rootfs
mount --make-rslave $DIR/rootfs
mount --make-rshared $DIR/rootfs
echo In the host namespace:
cat /proc/self/mountinfo|grep /tmp
echo In the udevd namespace:
cat /proc/$(pidof sleep)/mountinfo|grep /tmp
umount $DIR/rootfs
echo In the host namespace:
cat /proc/self/mountinfo|grep /tmp
echo In the udevd namespace:
cat /proc/$(pidof sleep)/mountinfo|grep /tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment