This file is indexed.

/bin/list-devices is in ubiquity 2.18.7.

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
#! /bin/sh
set -e
TYPE="$1"

case $TYPE in
    maybe-floppy)
	logger -t list-devices "deprecated parameter maybe-floppy"
	TYPE=floppy
	;;
    cd|disk|partition|floppy|maybe-usb-floppy|usb-partition|mmc-partition) ;;
    *)
	echo "Usage: $0 cd|disk|partition|floppy|maybe-usb-floppy|usb-partition|mmc-partition" >&2
	exit 2
	;;
esac

if [ ! -d /sys/block ]; then
	exit 0
fi
if type udevadm >/dev/null 2>&1; then
	device_info () {
		udevadm info -q "$1" -p "$2" 2>/dev/null
	}
elif type udevinfo >/dev/null 2>&1; then
	device_info () {
		udevinfo -q "$1" -p "$2" 2>/dev/null
	}
else
	exit 0
fi

device_name () {
	local name
	if ! name="$(device_info name "$1")"; then
		name="$(printf %s "${1##*/}" | \
			sed 's,!,/,g')"
	fi
	echo "/dev/$name"
}

is_sataraid () {
	grep -qs ^DMRAID- "$1/dm/uuid"
}

is_sataraid_partition () {
	# dmraid partitions are always slaved to another dm device
	for slave in "$1"/slaves/dm-*; do
		if [ -e "$slave" ]; then
			return 0
		fi
	done
	return 1
}

if type dmraid >/dev/null 2>&1; then
	raiddevs="$(dmraid -r -c || true)"
else
	raiddevs=
fi

# cloned-and-hacked from partman-base/init.d/parted
part_of_sataraid () {
	local raiddev
	for raiddev in $raiddevs; do
		if [ "$(readlink -f "$raiddev")" = "$1" ]; then
			return 0
		fi
	done
	return 1
}

syspaths=
scan_partition=false
case $TYPE in
    partition)
	for x in /sys/block/*/*[0-9]; do
		[ -d "$x" ] || continue
		syspaths="${syspaths:+$syspaths }$x"
	done
	for x in /sys/block/dm-*; do
		[ -d "$x" ] || continue
		(is_sataraid "$x" && is_sataraid_partition "$x") || continue
		syspaths="${syspaths:+$syspaths }$x"
	done
	TYPE=disk
	# Also allow misdetected USB devices
	scan_partition=:
	;;
    usb-partition|mmc-partition)
	for x in /sys/block/*/*; do
		[ -d "$x" ] || continue
		syspaths="${syspaths:+$syspaths }$x"
	done
	;;
    *)
	for x in /sys/block/*; do
		[ -d "$x" ] || continue
		case $x in
		    /sys/block/dm-*)
			if is_sataraid "$x" && is_sataraid_partition "$x"; then
				continue
			fi
			;;
		    *)
			name="$(device_name "$x")"
			if part_of_sataraid "$name"; then
				continue
			fi
			;;
		esac
		syspaths="${syspaths:+$syspaths }$x"
	done
	;;
esac
for x in $syspaths; do
	devpath="${x#/sys}"
	match=false
	case $TYPE in
	    floppy)
		# TODO ugly special case for non-IDE floppies
		case $devpath in
		    /block/fd[0-9]*)
			match=:
			;;
		esac
		;;
	esac
	if ! $match && [ "$TYPE" = cd ]; then
		if device_info env "$devpath" | grep -q '^ID_CDROM='; then
			match=:
		fi
	fi
	if ! $match; then
		if device_info env "$devpath" | grep -q "^ID_TYPE=$TYPE"; then
			match=:
		fi
	fi
	if ! $match && [ "$TYPE" = disk ]; then
		case $devpath in
		    /block/cciss\!*|/block/ida\!*|/block/rd\!*|/block/mmcblk*|/block/vd[a-z]*|/block/xvd[a-z]*)
			match=:
			;;
		    /block/dm-*)
			# for now, we only understand dmraid
			if is_sataraid "/sys$devpath"; then
				match=:
			fi
			;;
		esac
	fi
	# Some USB sticks and CD drives are misdetected as floppy
	# This allows to scan for those
	if ! $match && ( $scan_partition || [ "$TYPE" = maybe-usb-floppy ] ); then
		if device_info env "$devpath" | grep -q '^ID_BUS=usb' && \
		   device_info env "$devpath" | grep -q '^ID_TYPE=floppy'; then
			match=:
		fi
	fi
	# Disk partitions, but only on USB drives
	if ! $match && [ "$TYPE" = usb-partition ]; then
		if device_info env "$devpath" | grep -q '^ID_BUS=usb' && \
		   device_info env "$devpath" | grep -q '^ID_TYPE=disk'; then
			match=:
		fi
	fi
	# Disk partitions, but only on (non-USB) MMC devices
	if ! $match && [ "$TYPE" = mmc-partition ]; then
		if device_info env "$devpath" | egrep -q '^ID_PATH=(platform-mmc|platform-orion-ehci|platform-mxsdhci|platform-omap)'; then
			match=:
		fi
	fi
	if $match && ! device_info env "$devpath" | egrep -q '^ID_PART_ENTRY_TYPE=0x(5|f|85)$'; then
		device_name "/sys$devpath"
	fi
done