/sbin/mount.ploop is in ploop 1.10-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | #!/bin/sh
#
# Usage:
# /sbin/mount.ploop spec dir [-h] [-o options]
#
# (c) 2012. Parallels IP Holdings GmbH. All rights reserved.
#
PLOOP="ploop"
DESCRIPTOR="DiskDescriptor.xml"
DISK_DESCRIPTOR=""
MOUNT_POINT=""
OPTIONS=""
OPTS_ORIG=""
READLINK="/bin/readlink"
MTAB="/etc/mtab"
LOGFILE="/var/log/ploop_mount.log"
MODULES="ploop pfmt_ploop1 pfmt_raw pio_direct pio_nfs pio_kaio"
VERBOSE=""
FAKE=""
SELF=$(basename $0)
log() {
if [ "x$USER" = "x" ]; then
echo $* >> $LOGFILE
fi
echo $*
}
verbose() {
[ -n "$VERBOSE" ] && echo "$SELF: $*"
}
parse_opt() {
local opts="$1"
local nparam="$2"
local string=""
local value=""
local param=""
while [ "x$opts" != "x" ]; do
string=`echo $opts | sed "s,\,.*,,g"`
echo $string | grep "=" > /dev/null 2>&1
if [ $? -eq 0 ]; then
value=`echo $string | sed "s,.*=,,g"`
param=`echo $string | sed "s,=.*,,g"`
else
param="$string"
fi
if [ "x$param" = "x$nparam" ]; then
[ "x$value" != "x" ] && echo $value
return 0
fi
opts=`echo $opts | sed -e "s,^$string,,g" -e "s,^\,,,g"`
done
return 1
}
canonicalize() {
echo `$READLINK -f "$1" 2>/dev/null`
}
check_bin() {
if ! which $1 >/dev/null; then
log "$1 utility is not found"
exit 2
fi
}
load_modules() {
local m
for m in $MODULES; do
/sbin/modprobe $m
done
}
# Place the timestamp into log
if [ "x$USER" = "x" ]; then
date >> $LOGFILE
fi
# Make sure we have sane PATH
for P in /sbin /usr/sbin /usr/local/sbin; do
if ! echo ":${PATH}:" | fgrep -q ":${P}:"; then
PATH="$P:$PATH"
fi
done
export PATH
check_bin $PLOOP
check_bin $READLINK
case "$1" in
-h|--help|-?)
log "mount.ploop is a private mount(8) wrapper for ploop."
log "Don't use it directly!"
exit 1
;;
esac
# Parse the parameters
if [ "x$1" = "x" ]; then
log "ploop-related $DESCRIPTOR was not given"
exit 32
else
DISK_DESCRIPTOR=`canonicalize $1`
if [ ! -f $DISK_DESCRIPTOR ]; then
log "$DISK_DESCRIPTOR does not exist"
exit 32
fi
shift
fi
if [ "x$1" = "x" ]; then
log "Mount point was not given"
exit 32
else
MOUNT_POINT=`canonicalize $1`
if [ ! -d $MOUNT_POINT ]; then
log "$MOUNT_POINT does not exist"
exit 32
fi
shift
fi
# Parse options
while [ -n "$1" ]; do
case "$1" in
-o)
shift
OPTS_ORIG="$1"
ro=`parse_opt $1 ro`
if [ $? -eq 0 -a "x$ro" != "x" ]; then
OPTIONS="$OPTIONS -r"
fi
;;
-v)
VERBOSE=yes
;;
-f)
FAKE=yes
;;
-n)
# Deliberately ignore, since otherwise there will be
# no record with "ploop" in /etc/mtab and umount won't
# run umount.ploop helper.
verbose "option -n deliberately ignored"
;;
-s)
# ignore as we don't have any subtypes
;;
*)
verbose "unexpected option $* ignored"
;;
esac
shift
done
# Check that it's already mounted
for mpoint in `awk '{print $2}' /proc/mounts`; do
if [ $mpoint = $MOUNT_POINT ]; then
log "$MOUNT_POINT already mounted"
exit 32
fi
done
load_modules
# Call the ploop utility
verbose "running $PLOOP mount $OPTIONS -m $MOUNT_POINT $DISK_DESCRIPTOR"
if [ -z "$FAKE" ]; then
if [ "x$USER" = "x" ]; then
$PLOOP mount $OPTIONS -m $MOUNT_POINT $DISK_DESCRIPTOR >> $LOGFILE 2>&1
else
$PLOOP mount $OPTIONS -m $MOUNT_POINT $DISK_DESCRIPTOR
fi
fi
if [ $? -ne 0 ]; then
log "$PLOOP mount $OPTIONS -m $MOUNT_POINT $DISK_DESCRIPTOR command failed"
exit 32
fi
# Fill /etc/mtab
if [ -f $MTAB ]; then
verbose "adding mount to $MTAB"
echo "$DISK_DESCRIPTOR $MOUNT_POINT ploop $OPTS_ORIG 0 0" >> $MTAB
fi
exit 0
|