tracking down the vfat bug

From: Sacha Chua (sachac@asti.dost.gov.ph)
Date: Wed May 08 2002 - 04:50:28 EDT


I know why I hadn't seen it before. =) I was just making sure that I
could copy and load from the bootloader. Completely forgot about Linux!

set_filesize appears to work, but writing doesn't.

Does it work if I write a byte? Nope. Hmm.
Hey, vfat_write is still using my old code. I changed quite a bit of
nonworking stuff there already.

mount complains about bad FAT. Let me double-check the set_filesize..
Could not find file? Hmm, didn't notice that...

I don't understand this. find_file_entry succeeds, and then fails?
Oh. Ah, for some reason, image gets turned into a directory. I must
be marking the attributes wrong.

Oh. Wait. imagehasalongname is properly seen. Might be the LFN support.

Next test: imagehasalongname, set_filesize twice and see if I've screwed
up the directory entries... Passed.

So I must be screwing up the write somewhere.
I can look at the list of allocated clusters then try ide
write_clustering each of them. If that works, then I'll know (a)
ide write_cluster works, and (b) the allocated clusters aren't stepping
on other allocated clusters.

Oh, wait, I need to add a list_clusters command. That wasn't so hard.
Foo. Now that I know what clusters there are, how do I go about
actually writing the sectors?

vfat write says it's writing cluster 3, sector 219, but writes cylinder
2, sector 29. Jamey corrected my kludge, so I guess that's normal.

How can I test this?

vfat set_filesize imagehasalongname 100, so it gets allocated a cluster.
It is probably going to get assigned cluster 3.

So I need to write sector 0x219 with some value.
Hmm. 0x219 has 0s, but 0x229 has E24CB004. I suspect ide write_cluster
should write 0x229, but will write 0x219 first.

I think I trampled on the root directory entries. That's why!

Writing to 0x219 gives me an error, but 0x229 writes without problems.
That's if I poke the sectors by hand.

Now - how is ide write_sector invoking ide write, and how does
vfat_write_clusters mess up?

[side note: cross-compiling X apps is painless once you've waited for X
to download. Wish I'd gotten into it before!]

Maybe I should remove this - 2...

I think I'll go make myself some hot chocolate.

HEY.

It's still alive.
It didn't screw up my directory entry.

Of course if I really believed it work I should try cloning my carefully
set up root...

... which, naturally, I am just about to do.

Mwahaha.

Oh, joy! =D

touch /boot/toughluck...

and time to reflash...

Mental note: in future, watch out for magic numbers. Don't kludge just
to get the numbers to agree!

TADA!

It was fun tracking down that bug, although kinda embarrassing. ;)
What the heck, good time to learn this sort of stuff anyway.

Let me just check if short filenames work again.. Oh, looks like there
aren't any problems.

Patch to be sent to jamey right after this. See it in .44! =)

Sacha 8)



This archive was generated by hypermail 2.1.5 : Fri Jan 17 2003 - 17:47:04 EST