3 # Set up a fusefile as a disk device using device mapper.
4 # Note that this requires root access.
6 if [ $(id -u) != 0 ] ; then
7 echo "block device set up requires root." >&2
11 # fuse blkdev mounting needs to sniff an existing but unmounted block
12 # device node for setup. However the device mapping has an empty table
13 # and the content is only accessible via the fuse mount that links it
14 # to the fusefile process. The device node (major:minor) are still
15 # considered in use by the kernel and, and the device node is "open"
18 [ -e /dev/mapper/control ] || modprobe dm_mod || exit 1
20 # Create up to N fusedisk named as fusedisk0..fusediskN, the device
21 # mapper also creates its dm-X device nodes and we also force
22 # /dev/mapper/$NAME nodes for them.
25 for I in $(seq 0 $N) ; do
27 C="$(dmsetup info --noheadings -c -o open $NAME 2>/dev/null)"
28 if [ "$C" != "1" ] ; then
30 dmsetup create $NAME --notable || exit 1
31 dmsetup mknodes $NAME || exit 1
37 if [ -z "$DEV" ] ; then
38 echo "** No more fusedisk devices" >&2
41 echo "using $DEV for $*" | logger -t fusedisk
42 exec fusefile -oblkdev,fsname=$DEV -oallow_other $*