|
-
Nov 2nd, 2000, 05:32 AM
#1
Thread Starter
Frenzied Member
Hi all.
Everybody knows how to format right? Well, the question is, what does a format do exactly?
Of course it erases all the files and folders on the disk and removes all residual data from the disk.
Well it seems to do more than that and I am trying to figure out what exactly it does.
Here is what I am trying to figure out.
If I format a disk, I can go into hex editor and see that the disk holds no data anywhere in the 2847 clusters ( a floppy disk here). Then when I write a file to the disk, it writes to cluster number 2 ( the starting point of the disk). The next file begins writing at the end of that file, etc.
Sooo, when I erase all the files on the disk, the next file automatically goes to the next available clusters right? Wrong. Because those clusters no longer contain files, but do retain the data. Only after a format will Windows write to those clusters again.
Logically, the next step was to look at what format does. It replaces every character on a disk with (from what I can tell) Chr$(246). So I wrote a small app that writes 1,457,664 of these to a floppy and then deletes the file. That should have been the basic equivalent. But it wasn't. Two bad results. One is that the next file I tried to write returned error 61 - disk full.
Second, when I go into the Hex editor (Norton Disk Edit), I see that the file names are retained. Again, after format, these are gone too and things are back to normal.
At last, the question (sorry, just want to eliminate unneccessary reply questions). What is it that format does to a disk exactly and how can I get the same results without using the Windows format API or a DOS batch file to call a format. In other words, to write my own formatter.
Now, if you have read this far and have an answer or a clue, please share it with me.
Thanks
Wengang
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Nov 2nd, 2000, 05:47 AM
#2
Fanatic Member
Formatting
Didn't you wonder why Cluster 2 was the start of the data?
The disk maintains a cluster map in the first two clusters. Deleting a file marks the used clusters as available in the cluster map. These will be used in rotation so the oldest deleted file will be overwritten first - this is why NDD and similar can (sometimes) retrieve files. Formatting does indeed write a single character to all data clusters on the disk, but CRUCIALLY it also clears the cluster map. There is also a back up cluster map which resides elsewhere (I forget where) This is what gets used when disks are 'repaired'.
For more details you might try finding an old book on MS-Dos - yes it wasn't just a myth - there was a time when PCs existed without Windows!!!
Good Luck.
Paul.
Not nearly so tired now...
Haven't been around much so be gentle...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|