This file is indexed.

/usr/sbin/MAKEFLOPPIES is in fdutils 5.5-20060227-7+b1.

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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/bin/sh
#
# MAKEFLOPPIES
#
# requires: expr
# Note quirk of expr: if it prints "0", it always
# returns "1" regardless of whether this makes sense!
#
# 1995.01.03	David Niemi	Created

set -e
set -u

# check for devfs
if [ -e /dev/.devfsd ]; then
    echo "devfs found, skipping MAKEFLOPPIES..." >&2
    exit 0
fi

MAJOR=2
TMPDEVICE=/dev/tmpfloppy$$
if [ ! -b /dev/fd0 ] ; then
    mknod /dev/fd0 b $MAJOR 0
fi
if floppycontrol 2>/dev/null; then
	FLOPPYCONTROL=yes
else
	FLOPPYCONTROL=no
fi

MINORNAMES='d360 h1200 D360 D720 h360 h720 H1440 E2880
	CompaQ h1440 H1680 h410 H820 h1476 H1722 h420
	H830 h1494 H1743 h880 D1040 D1120 h1600 H1760
	H1920 E3200 E3520 E3840 H1840 D800 H1600'

CMOSNAMES='360K_PC 1.2M_AT 720K 1.44M 2.88M_AMI_BIOS 2.88M'

## Used only with -t option
CMOSLETTERS='d h D H E E'
UCMOSLETTERS='d h u u u u'
CMOSFORMATS='d h D DH DHE DHE'

LOCAL=
DRIVES=
USAGE=
TYPE_OVERRIDE=u
REMAINDER=
DRYRUN=
VERBOSE=


## getword nth parameter of all the subsequent parameters
getword ()
{	if [ $# -lt 1 ]; then
		return
	fi
	if [ "$1" -lt 1 ] || [ "$1" -ge $# ]; then
		return
	fi
	shift $1
	echo $1
}

basenumber()
{
	if [ $1 -ge 4 ] ; then
		expr $1 + 124
	else
		echo $1
	fi
}

minorname ()
{	if [ "$FLOPPYCONTROL" = no ]; then
		## No floppycontrol program, so use default values
		getword "$1" $MINORNAMES
	else
		rm -f "$TMPDEVICE"
		mknod "$TMPDEVICE" b "$MAJOR" "$1"
		floppycontrol -T "$TMPDEVICE" 2>/dev/null || :
		rm -f "$TMPDEVICE"
	fi

}

cmosid ()
{
	if [ "$FLOPPYCONTROL" = yes ]; then
		case `minorname $1` in
		d360)		echo 1 ;;
		h1200)		echo 2 ;;
		D720)		echo 3 ;;
		H1440)		echo 4 ;;
		E2880)		echo 6 ;;
		"(null)")	echo none ;;
		"")		echo none ;;
		*)		echo unknown ;;
		esac
	elif [ "$1" = 0 ]; then
		echo 4		# 1.44MB default for drive 0
	elif [ "$1" = 1 ]; then
		echo 2		# 1.2MB AT default for drive 1
	else
		echo none	# Nothing for everybody else
	fi
}

# main()

PERMISSION=666
while [ $# -ge 1 ] || [ -n "${REMAINDER}" ]; do
	if [ -n "$REMAINDER" ]; then
		## Continue processing options stuck together
		ARG=$REMAINDER
	else
		## Get a fresh argument
		ARG=$1
		shift
		case "$ARG" in

		## Remove dash in front of option(s)
		-?*)
			ARG=`expr "-$ARG" : '-*\(.*\)' || :`
			;;
		esac
	fi

	## Break compound options up
	case "$ARG" in
	??*)	REMAINDER=`expr "$ARG" : '.\(.*\)' || :`
		ARG=`expr "$ARG" : '\(.\)' || :`
		;;
	*)	REMAINDER= ;;
	esac

	case $ARG in

	## Process drive number(s)
	[0-7])	DRIVES="$DRIVES $ARG" ;;

	[nN])	DRYRUN=yes ;;

	## Make devices in current directory, not /dev
	[lL])	LOCAL=yes ;;

	## Base device name on drive type
	[tT])	TYPE_OVERRIDE=yes ;;
	[dD])	TYPE_OVERRIDE=yes ;;

	## Base device name on media type
	[mM])	TYPE_OVERRIDE=no ;;

	## New naming scheme
	[uU])	TYPE_OVERRIDE=no ;;

	[vV])	VERBOSE=yes ;;

	## Allow access only for group floppy
	[gG])	PERMISSION=660 ;;

	*)	echo "$0: unrecognized argument \"$ARG\"." >&2
		USAGE=yes
		;;
	esac
done

if [ -n "$USAGE" ]; then
	echo "Usage: $0 [ <option> ... ] [ <drive #> ... ]" >&2
	echo 'Options:
	-l	Local (make files in local directory, not /dev)
	-n	Dry run (just report what would be done, do not do anything)
	-t | -d	Use the old naming convention for 3 1/2 devices (e.g. fd0H720 instead of fd0u720)
	-m | -u	Base the name for the created devices on the type of the media (e.g. fd0h720 instead of fd0u720)
	-g	Allow access only for group floppy
	-v	Verbose
' >&2
	exit 1
fi

if [ -z "$DRIVES" ]; then
	DRIVES="0 1 2 3 4 5 6 7"
fi

for DRIVE in $DRIVES; do
	if [ -n "$LOCAL" ]; then
		FILE=fd$DRIVE
	else
		FILE=/dev/fd$DRIVE
	fi
	BASENUMBER=`basenumber $DRIVE`
	CMOS=`cmosid "$BASENUMBER"`
	if [ $CMOS = none ] ; then
		echo "Drive $DRIVE is not installed or not configured, skipping"
		continue
	fi

	if [ $CMOS = unknown ] ; then
		echo "Drive $DRIVE is of unknown type, skipping"
		continue
	fi	

	CN=`getword "$CMOS" $CMOSNAMES`

	if [ "$TYPE_OVERRIDE" = u ]; then
		CL=`getword "$CMOS" $UCMOSLETTERS`
	else
		CL=`getword "$CMOS" $CMOSLETTERS`
	fi

	FORMATS=`getword "$CMOS" $CMOSFORMATS`
	if [ -n "$VERBOSE" ] || [ -n "$DRYRUN" ]; then
		echo rm -f "$FILE"*
	fi
	if [ -z "$DRYRUN" ]; then
		rm -f "$FILE"*
	fi
	if [ -z "$CMOS" ] || [ -z "$CN" ]; then
		echo "Skipping invalid drive \"$FILE\"" >&2
		continue
	fi
	echo "Creating \"$FILE\", ID=$DRIVE, Type=$CMOS ($CN)"
	if [ -z "$DRYRUN" ]; then
		mknod "$FILE" b "$MAJOR" "$BASENUMBER"
		chown root:floppy "$FILE"
		chmod ${PERMISSION} "$FILE"
	fi
	if [ -n "$VERBOSE" ] || [ -n "$DRYRUN" ]; then
		echo mknod "$FILE" b "$MAJOR" "$BASENUMBER"
	fi

	## Todo: query about tracks and such (for now assume 80 only)

	BASE=4
	while [ $BASE -lt 128 ] ; do
		MINOR=`expr "$BASE" + "$BASENUMBER" || :`
		NAME=`minorname "$BASE"`
		if expr index "$FORMATS" "$NAME" >/dev/null ; then
			if [ "$TYPE_OVERRIDE" != no ]; then
				NAME=`echo $NAME | sed "s/^./$CL/g"`
			fi
		
			if [ -z	"$NAME" ]; then
				echo "Oops, skipping invalid format \"$FORMAT\"" >&2
				continue
			fi
			if [ -z "$DRYRUN" ]; then
				mknod "${FILE}${NAME}" b "$MAJOR" "$MINOR"
				chown root:floppy "${FILE}${NAME}"
				chmod ${PERMISSION} "${FILE}${NAME}"
			fi
			if [ -n "$VERBOSE" ] || [ -n "$DRYRUN" ]; then
				echo mknod "${FILE}${NAME}" b "$MAJOR" "$MINOR"
			fi
		fi
		BASE=`expr $BASE + 4`
	done
done

## END ##