Re: Oops to floppy patch enhancement

Riley Williams (rhw@MemAlpha.CX)
Sat, 10 Jul 1999 21:06:52 +0100 (GMT)


Hi Willy.

>> Using the format I devised for an MS-DOS compatible dump floppy,
>> the equivalent test would be the following bash script...

Can I update that script somewhat...

Q> #!/bin/bash
Q> function bit() {
Q> echo $[`word $1`&$[1<<$2]]
Q> }
Q> function byte() {
Q> get $1 1 | hexdump -e '1/1 "%d"'
Q> }
Q> function get() {
Q> dd if=/dev/fd0 bs=1 skip=$1 count=$2
Q> }
Q> function word() {
Q> get $1 2 | hexdump -e '1/2 "%d"'
Q> }
Q>
Q> # DIRPTR calculation below:
Q> # DIRPTR = (SectorsPerFAT * NumFATs + Reserved) * SectorSize
Q> # In Reverse Polish:
Q> # DIRPTR = SectorsPerFAT NumFATs * Reserved + SectorSize *
Q>
Q> if [ `word 510` != $[0xAA55] ]; then
Q> echo 'Unformatted, so usable as a Linux Panic Dump floppy.' >&2
Q> exit 0
Q> elif [ "`get 3 8`" = "LinPanic" ]; then
Q> echo 'This is a Linux Panic Dump floppy.' >&2
Q> exit 0
Q> else
Q> DIRPTR="`word 22` `byte 16`*`word 14`+`word 11`*p"
Q> DIRPTR=`echo "$DIRPTR" | dc`
Q> DIRSIZE=`word 17`
Q> declare -i N=0
Q> OK=Y
Q> while [ $N -lt $DIRSIZE ]; do
Q> PTR=`echo "32 $N*$DIRPTR+p" | dc
Q> ATT=$[$PTR+11]
Q> if [ `byte $PTR` -eq 0 ]; then
Q> break
Q> fi
Q> if [ `byte $PTR` -ne $[0xE5] -a `bit $ATT 3` -eq 0 ]; then
Q> OK=N
Q> break
Q> fi
Q> N=$N+1
Q> done
Q> if [ $OK != Y ]; then
Q> echo 'ERROR: Not usable as a Linux Panic Dump floppy.' >&2
Q> exit 1
Q> else
Q> echo 'Not a LinPanic floppy, but usable as one.' >&2
Q> exit 0
Q> fi
Q> fi

The above script implements the following decision strategy:

1. If the disk is not marked as formatted, go to step 5,
else go to step 2.

2. If the disk format ID is "LinPanic", go to step 6,
else go to step 3.

3. If the disk does not contain any non-deleted directory
entries that are not volume label entries, go to step 5,
else go to step 4.

4. This disk is not usable as a Linux Panic disk. Abort.

5. This disk can be reformatted as a Linux Panic disk. Accept.

6. This disk is a Linux Panic disk. Accept.

That is the logic as I would see it...

>> Alternatively, it would be sufficient to require that the
>> directory is already formatted for MS-DOS and is either empty
>> or contains only a volume label entry, since any such disk by
>> by definition can have no data of any value on it.

> I really think that any trashable diskette should be used, but
> with three choices :

> - a "LinPanic" diskette would allow automatic dump
> - a non "LinPanic" diskette would :
> - either put the dumper in interactive mode (user operation
> needed),
> - or reboot without any dump because we don't want to risk
> the diskette contents.

Make that five choices, as follows:

A. Any "LinPanic" diskette would allow an automatic dump.

B. Any unformatted diskette would be formatted as a LinPanic
diskette, then treated as one of type (A).

C. Any non "LinPanic" diskette with no entries other than a possible
volume label on it would cause the dumper to ask whether to
convert it to a LinPanic diskette, and if the user said "Y", it
would then treat it as unformatted, or type (B).

D. Any non "LinPanic" diskette with files and/or directories on it
would either:

1. Put the dumper in interactive mode, as user intervention
is required, or

2. Reboot without any dump as we don't wish to risk the
diskette's contents.

In addition, I would see (A), (B) and (C) as being an inbuilt part of
the dumper's logic, with a configuration choice only for (D). This has
the advantage that the user does not need to preformat diskettes for
LinPanic use, thus enabling them to capture a panic they hadn't
prepared for.

> But your script is interesting in the case of a server. At boot
> time, it could shout "Hey, you have a diskette in your drive
> which is not a linpanic one. is this normal ?"

Given the above, it could shout a little more intelligently as well...

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/