/usr/share/initramfs-tools/scripts/lupin-helpers is in lupin-casper 0.55.
This file is owned by root:root, with mode 0o644.
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 | . /scripts/casper-helpers
is_supported_fs(){
[ -z "${1}" ] && return 1
case ${1} in
ext2|ext3|ext4|xfs|jfs|reiserfs|vfat|ntfs|iso9660)
return 0
;;
esac
return 1
}
wait_for_devs(){
if [ -e /dev/.initramfs/lupin-waited-for-devs ]; then
return
fi
[ "$quiet" != "y" ] && log_begin_msg "...waiting for devs..."
udevadm trigger --subsystem-match=block
udevadm settle
#TBD, modprobe on demand?
modprobe ext3
modprobe ext4
modprobe reiserfs
modprobe xfs
modprobe jfs
modprobe vfat
modprobe fuse
[ "$quiet" != "y" ] && log_end_msg "...devs loaded..."
touch /dev/.initramfs/lupin-waited-for-devs
}
find_path()
{
local path="${1}"
# must match find_path_cleanup
local default_mountpoint="${2:-/tmpmountpoint}"
local mountoptions="${3:-ro}"
local mountpoint=
local dev devname devfstype
local trial_number
FOUNDDEV=
FOUNDPATH=
[ -z "${path}" ] && return 1
wait_for_devs
mkdir -p "${default_mountpoint}"
for trial_number in 1 2 3; do
[ $trial_number -gt 1 ] && sleep 3
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v /ram | grep -v /loop | grep -v /fd); do
for dev in $(subdevices "${sysblock}"); do
devname=$(sys2dev "${dev}")
devfstype="$(get_fstype ${devname})"
if is_supported_fs "${devfstype}" ; then
#if device is already mounted, do not remount
if grep -q "^${devname} " /proc/mounts; then
mountpoint=$(grep "^${devname} " /proc/mounts|cut -d ' ' -f 2)
unmount=false
else
mountpoint="${default_mountpoint}"
try_mount "$devname" "$mountpoint" "$mountoptions" || continue
unmount=true
fi
if [ -e "${mountpoint}${path}" ]; then
FOUNDDEV="${devname}"
FOUNDPATH="${mountpoint}${path}"
return 0
fi
[ "${unmount}" = "true" ] && umount ${mountpoint} 2> /dev/null || true
fi
done
done
done
return 1
}
find_path_cleanup()
{
# must match find_path
local default_mountpoint="${1:-/tmpmountpoint}"
if grep -q "^[^ ]* $default_mountpoint " /proc/mounts; then
umount "$default_mountpoint" 2>/dev/null || true
fi
rmdir "$default_mountpoint" 2>/dev/null || true
}
|