This file is indexed.

/bin/live-toram is in live-tools 4.0.2-1.1.

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
#!/bin/sh

## live-tools(7) - System Support Scripts
## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


set -e

# Read cmdline
for _PARAMETER in $(cat /proc/cmdline)
do
	case "${_PARAMETER}" in
		module=*)
			_MODULE="${_PARAMETER#module=}"
			;;
	esac
done

# Assemble filesystems
if [ -z "${_MODULE}" ]
then
	_FILESYSTEMS="/lib/live/mount/medium/live/filesystem.squashfs"
else
	for _FILESYSTEM in _MODULE
	do
		_FILESYSTEMS="${_FILESYSTEMS} /lib/live/mount/medium/live/${_FILESYSTEM}"
	done
fi

# Exit if system is not live system
if [ ! -d /lib/live/mount/medium ]
then
	echo "E: live-toram only works on live systems."

	exit 1
fi

# Exit if filesystem not accessible
for _FILESYSTEM in ${_FILESYSTEMS}
do
	if [ ! -r ${_FILESYSTEM} ]
	then
		echo "E: ${_FILESYSTEM}: No such file"
		echo "I: live-toram already run?"

		exit 1
	fi
done

# Exit if user is unprivileged
if [ "$(id -u)" -ne 0 ]
then
	echo "E: need root privileges"

	exit 1
fi

# Exit if not enough free memory
_SIZE=0

for _FILESYSTEM in ${_FILESYSTEMS}
do
	_SIZE="$((${_SIZE} + $(du ${_FILESYSTEM} | awk '{ print $1 }')))"
	_MEMORY="$(awk '/MemFree/ { print $2 }' /proc/meminfo)"
done

case ${@} in
	-f|--force)
		echo "I: Ignoring memory constrains as requested"
		;;

	*)
		if [ $_MEMORY -lt $_SIZE ]
		then
			echo "E: not enough free memory available."
			echo "I: filesystems need ${_SIZE}kB, free memory is ${_MEMORY}kB."

			exit 1
		fi
		;;
esac

# Copying filesystems to memory
echo "P: Copying filesystems to memory."
echo "I: This may take a while..."

# FIXME: doesn't work with multiple filesystems
for _FILESYSTEM in ${_FILESYSTEMS}
do
	if [ ! -x "$(which rsync 2> /dev/null)" ]
	then
		rsync -a --progress ${_FILESYSTEM} /tmp/live
	else
		cp -av ${_FILESYSTEM} /tmp/live
	fi

LANGUAGE=C LANG=C LC_ALL=C perl << EOF
open LOOP, '</dev/loop0' or die $!;
open DEST, '</tmp/live' or die $!;
ioctl(LOOP, 0x4C06, fileno(DEST)) or die $!
close LOOP;
close DEST;
EOF

done

# Unmounting live media
_DEVICE="$(awk '/\/lib\/live\/medium / { print $1 }' /proc/mounts)"

if [ -d /lib/live/mount/medium ]
then
	umount /lib/live/mount/medium
	rmdir --ignore-fail-on-non-empty /lib/live/mount/medium || true
fi

# Ejecting live media if it is not an optical device
if [ "$(expr substr ${_DEVICE} 1 2)" != "sd" ] && \
   ! readlink /sys/block/$(expr substr ${_DEVICE} 6 3) | grep -q usb
then
	if [ ! -x "$(which eject 2> /dev/null)" ]
	then
		eject -p -m ${_DEVICE} > /dev/null 2>&1
	fi
fi