CASE HISTORY # 5 by The Disk Doctor -------------------------------------------- Copyright (C) 1987, the Disk Doctor. First published in the Rochester (PC)^3 News: Picture City PC Programming Club PO BOX 20342 Rochester, NY 14602 The Disk Doctor may be contacted at this address, or via CIS [73147,414]. This material may be reproduced for internal use by other not-for-profit groups, provided this copyright notice is included. ---------------------------------------------- 11:20pm I was graphing some spreadsheet results when "K" ran up to me, all out of breath. "Doc, you've got to help me! Before they find out." he huffed and puffed. "Who?" I calmly /FS~Replaced. "The rest of the guys in my group." K. peered over his shoulder. "I accidently trashed our departmental database. Can you help me?" I pried the floppy out of his sweaty fist. "Is this the original disk?" "No. I made an exact copy using DISKCOPY, like you always tell people. That way you can always go back if the working disk gets messed up even worse." "You're a smart kid. How did you get yourself in this kind of trouble?" He hesitated, as the words choked up in his throat. "I was my fault. I was in a hurry this morning and I think I shut off the power while the disk drive was still saving the file. The file is there in the DIRrectory, but when I try to read it in, the program says 'Part of file missing'." "The CHKDSK command will give us a clue of what we have here." I had his disk in my drive. "There's the problem. You have lost-chains." K. looked at the screen as if it was in a foreign language. "What's that?" "The data is probably written out there on the disk, but DOS doesn't know how to find the next sector." "Well, uhmm, how does it normally find the next sector?" 11:22pm I invited K. to sit down. "At the beginning of every disk, there is a File Allocation Table (commonly known as the F.A.T.). The FAT contains an entry for every sector on the disk, marking it as either: 1) free and available, 2) part of a file (gives the location of the next sector in the chain), 3) the end-of-a-file, or 4) a bad sector (isolated from further use). " I continued, "If you get an end-of-file marker in the middle of a chain, the missing segment is called a 'lost chain'. The remaining sectors are not marked available, so they still take up space, but DOS can't access them. A bad-sector marker would have the same effect, but in this case, CHKDSK didn't report any bad sectors." "But why does the database report a error? Why doesn't it read in as much as it can?" "I not all that familiar with the database program you're using, but my guess is that it looks for certain 'signature' bytes at the end of the file to know it has a valid data file. It can't find the signature because the file got truncated." Gulp. "So what do you do now?" "I'll use CHKDSK command with the /F option to capture the sectors in the lost chain, so we append them to your file. Just one word of warning, K., if you ever do any work with CHKDSK. A lot of the fixes are irreversible, and sometimes they don't come out like you want." 11:32am "Here's a case, right here. You should always answer 'Y' to CHKDSK's lost-chains question. It creates a a link to the lost chain, so you can look at the segment and decide whether to delete it. If you answer 'N', the sectors are marked available, and you'll never see them again." "Gee. How come you know so much, Doc? Where did you go to school?" "Ha. There's no school that teaches this stuff." The doctor paused and stared out the window. "Something happened a long time ago... I swore it would never happen again. Now I only use my knowledge to help other people..." The flashback ended, and my computer came into focus. "I'd rather not talk about my past. Let's just get you back in business again." "Now, I can just concatenate these 2 files with the COPY command. There. Let's try to run it." 11:47am "It works. Doc, you're a life-saver. There's a good chance I can get this disk back to my office before the other guys find out what happened. How can I ever repay you?" "If you learned something today, then I am repaid." WARNING: The feats described in this report are performed by carefully trained specialists. Children should not attempt these stunts at home without proper supervision.