mount corrupts ramdisk

Kurt Garloff (K.Garloff@ping.de)
Wed, 10 Feb 1999 11:01:34 +0100


--9Ek0hoCL9XbhcSqy
Content-Type: multipart/mixed; boundary="lEGEL1/lMxI0MVQ2"

--lEGEL1/lMxI0MVQ2
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hi everybody,

I posted a similar report before and I was very astonished to see nobody
answering.

Create a ramdisk:=20
$ dd if=3D/dev/zero of=3D/dev/ram2 bs=3D512 count=3D2880
$ mkfs.msdos /dev/ram2 1440
mkfs.msdos produces a valid MS-DOS filesystem:=20
$ hex /dev/ram2 | less
0000 eb 3c 90 6d 6b 64 6f 73 66 73 00 00 02 04 01 00 =EB<.mkdos fs......
0010 02 00 02 40 0b f8 03 00 eb 00 12 00 00 00 00 00 ...@.=F8.. =EB.....=
..

You are able to mount it:
mount -t msdos /dev/ram2 /mnt/ram2

The filesystem is mounted and can be accessed:
$ df
/dev/ram2 1420 0 1420 0% /mount/ram
$ mount
/dev/ram2 on /mount/ram type msdos (rw)

However, if you have a look at /dev/ram2, you see that something's going
wrong:
0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........

THE MOUNT CALL HAS DESTROYED THE DATA IN /DEV/RAM2 !!!

Of course umounting does not help! The strange thing about it is, that this
happens for msdos and vfat, but not for ext2 or minix.

Now the ramdisk driver is confused. A subsequent mkfs.msdos succeeds, but
you are not able to mount the ramdisk. The next mkfs.minix and mount also
fails, but after this it has recovered. rmmod and insmod rd also help to get
the ramdisk driver working again, ie. allowing minix and ext2 mounts without
and msdos/vfat mounts with corruption again.

> mkfs.msdos /dev/ram2 1440
> mount -t /dev/ram2 /mnt/ram
> umount /dev/ram2
> mount -t /dev/ram2 /mnt/ram

The last mount fails, as the first one has destroyed the msdos filesystem.
The kernel says:

[MS-DOS FS Rel. 12,FAT 12,check=3Dn,conv=3Db,uid=3D0,gid=3D0,umask=3D022,bm=
ap]
[me=3D0x0,cs=3D0,#f=3D0,fs=3D0,fl=3D0,ds=3D0,de=3D0,data=3D0,se=3D0,ts=3D0,=
ls=3D0,rc=3D0,fc=3D4294967295]
Transaction block size =3D 512
VFS: Can't find a valid MSDOS filesystem on dev 01:02.

I have no explanation, why minix and ext2 work perfectly with a ramdisk,
while msdos and vfat fail. I guess, msdos does an operation (seek behind
end, or whatever) that confuses the ramdisk driver.

I hope somebody is able to fix this!

I append a script to do tests with.

--=20
Kurt Garloff <kurt@garloff.de> [Dortmund, FRG]
Plasma physics, high perf. computing [Linux-ix86,-axp, DUX]
PGP key: see mailheader [Linux SCSI driver: DC390]

--lEGEL1/lMxI0MVQ2
Content-Type: text/plain; charset=us-ascii
Content-Description: crash_msdos.sh
Content-Disposition: attachment; filename="crash_msdos.sh"

#!/bin/bash

finish() {
echo "*** ABORT ***"
umount $device
freeramdisk $device
exit
}

export fstype=msdos
export device=/dev/ram2
export size=1440
test -z "$1" || fstype="$1"
test -z "$2" || device="$2"
test -z "$3" || size="$3"
echo "*** Test with filesystem $fstype on device $device, size $size ***"
dd if=/dev/zero of=$device bs=1024 count=$size 2>/dev/null
#mkdir /mnt/ram2
#ln -s /sbin/mkfs.msdos /sbin/mkfs.vfat
mkfs -t $fstype $device $size || finish
mount -t $fstype $device /mnt/ram2 || finish
cp /vmlinuz /System.map /mnt/ram2/
ls -lF /mnt/ram2
umount /mnt/ram2 || finish
ls -lF /mnt/ram2
# Now, watch it crash your kernel's VFS layer
mount -t $fstype $device /mnt/ram2 || finish
ls -lF /mnt/ram2
umount /mnt/ram2
freeramdisk $device
ls -lF /mnt/ram2

--lEGEL1/lMxI0MVQ2--

--9Ek0hoCL9XbhcSqy
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3in

iQCVAwUBNsFY/haQN/7O/JIVAQGl7QP+Lip6zNifxj6qauEuA8vfN+K80aX1J1eC
xu1bcxdK+/+EZVJ0QNO6xmFeaRBYw94Tdh34+MlVjuOvmVc9tZwHgvQQytPLW2kg
JgbwI6gMsdzBauy9Zv9n4E8DMnu6jcLmTVnO7oprr8tLSOMvU3UIEI2InwCGA/8h
Bn2qgJ3USV0=
=ekKr
-----END PGP SIGNATURE-----

--9Ek0hoCL9XbhcSqy--

-
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/