=========================================== Dumping DOS Directory Structure using DEBUG =========================================== -IAN! idallen@ncf.ca This file gives a disk dump (using DEBUG) of the ROOT directory on a disk and then asks you questions about it. ------------------------------ Output of the DOS DIR command: ------------------------------ Volume in drive A is DAT2343DEMO Volume Serial Number is FEED-FACE Directory for A:/ FINLEXAM WPD 37976 04-05-2000 8:19 finlexam.wpd DIRECT~1 04-13-2000 10:31 directory PROJECT4 TXT 1569 04-03-2000 6:46 project4.txt TOTAL ASM 4908 04-03-2000 7:16 total.asm GETSHOW ASM 5493 04-03-2000 10:15 getshow.asm MERCURY TXT 0 04-13-2000 10:37 mercury.txt EARTH TXT 0 04-13-2000 10:37 earth.txt 8 files 53 291 bytes 1 401 856 bytes free ------------------------------------------------------- DEBUG output for the same (root) directory on the disk: ------------------------------------------------------- Note the Volume Label and deleted files: 1585:2600 44 41 54 32 33 34 33 44-45 4D 4F 28 00 00 00 00 DAT2343DEMO(.... 1585:2610 00 00 00 00 00 00 83 44-EA 22 00 00 00 00 00 00 .......D."...... 1585:2620 41 66 00 69 00 6E 00 6C-00 65 00 0F 00 0C 78 00 Af.i.n.l.e....x. 1585:2630 61 00 6D 00 2E 00 77 00-70 00 00 00 64 00 00 00 a.m...w.p...d... 1585:2640 46 49 4E 4C 45 58 41 4D-57 50 44 20 00 6A F3 42 FINLEXAMWPD .j.B 1585:2650 85 28 85 28 00 00 77 42-85 28 B1 00 58 94 00 00 .(.(..wB.(..X... 1585:2660 41 64 00 69 00 72 00 65-00 63 00 0F 00 6F 74 00 Ad.i.r.e.c...ot. 1585:2670 6F 00 72 00 79 00 00 00-FF FF 00 00 FF FF FF FF o.r.y........... 1585:2680 44 49 52 45 43 54 7E 31-20 20 20 10 00 47 FC 53 DIRECT~1 ..G.S 1585:2690 8D 28 8D 28 00 00 FD 53-8D 28 4D 00 00 00 00 00 .(.(...S.(M..... 1585:26A0 41 70 00 72 00 6F 00 6A-00 65 00 0F 00 48 63 00 Ap.r.o.j.e...Hc. 1585:26B0 74 00 33 00 2E 00 74 00-78 00 00 00 74 00 00 00 t.4...t.x...t... 1585:26C0 50 52 4F 4A 45 43 54 34-54 58 54 20 00 8A D7 42 PROJECT4TXT ...B 1585:26D0 85 28 85 28 00 00 D9 35-83 28 98 00 21 06 00 00 .(.(...5.(..!... 1585:26E0 41 74 00 6F 00 74 00 61-00 6C 00 0F 00 11 2E 00 At.o.t.a.l...... 1585:26F0 61 00 73 00 6D 00 00 00-FF FF 00 00 FF FF FF FF a.s.m........... 1585:2700 54 4F 54 41 4C 20 20 20-41 53 4D 20 00 A7 D8 42 TOTAL ASM ...B 1585:2710 85 28 85 28 00 00 17 3A-83 28 9C 00 2C 13 00 00 .(.(...:.(..,... 1585:2720 41 67 00 65 00 74 00 73-00 68 00 0F 00 A7 6F 00 Ag.e.t.s.h....o. 1585:2730 77 00 2E 00 61 00 73 00-6D 00 00 00 00 00 FF FF w...a.s.m....... 1585:2740 47 45 54 53 48 4F 57 20-41 53 4D 20 00 49 D9 42 GETSHOW ASM .I.B 1585:2750 85 28 85 28 00 00 E3 51-83 28 A6 00 75 15 00 00 .(.(...Q.(..u... 1585:2760 41 6D 00 65 00 72 00 63-00 75 00 0F 00 64 72 00 Am.e.r.c.u...dr. 1585:2770 79 00 2E 00 74 00 78 00-74 00 00 00 00 00 FF FF y...t.x.t....... 1585:2780 4D 45 52 43 55 52 59 20-54 58 54 20 00 55 B4 54 MERCURY TXT .U.T 1585:2790 8D 28 8D 28 00 00 B5 54-8D 28 00 00 00 00 00 00 .(.(...T.(...... 1585:27A0 E5 76 00 65 00 6E 00 75-00 73 00 0F 00 CA 2E 00 .v.e.n.u.s...... 1585:27B0 74 00 78 00 74 00 00 00-FF FF 00 00 FF FF FF FF t.x.t........... 1585:27C0 E5 45 4E 55 53 20 20 20-54 58 54 20 00 A5 B4 54 .ENUS TXT ...T 1585:27D0 8D 28 8D 28 00 00 B5 54-8D 28 AB 00 78 56 00 00 .(.(...T.(...... 1585:27E0 41 65 00 61 00 72 00 74-00 68 00 0F 00 A5 2E 00 Ae.a.r.t.h...... 1585:27F0 74 00 78 00 74 00 00 00-FF FF 00 00 FF FF FF FF t.x.t........... 1585:2800 45 41 52 54 48 20 20 20-54 58 54 20 00 B9 B4 54 EARTH TXT ...T 1585:2810 8D 28 8D 28 00 00 B5 54-8D 28 00 00 00 00 00 00 .(.(...T.(...... 1585:2820 E5 6D 00 61 00 72 00 73-00 2E 00 0F 00 C4 74 00 .m.a.r.s......t. 1585:2830 78 00 74 00 00 00 FF FF-FF FF 00 00 FF FF FF FF x.t............. 1585:2840 E5 41 52 53 20 20 20 20-54 58 54 20 00 1A B5 54 .ARS TXT ...T 1585:2850 8D 28 8D 28 00 00 B6 54-8D 28 F0 01 34 12 00 00 .(.(...T.(...... 1585:2860 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1588:2870 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1585:2880 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 1585:2890 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ========== Exercises: ========== ------- Part I: ------- 1) List the names and attributes of all entries that are not ordinary files. 2) Find the DOS names of all deleted entries in this directory. How can you know the first letter of the deleted file name? 3) List the sizes and starting clusters of all the ordinary files (including deleted files) in both hexadecimal and decimal. 4) What formulas are used to calculate the Absolute (Disk) Sector number of a file? Show how the disk boot sector numbers are used in each part of the formula. 5) Using information about the disk geometry from the following BOOT block DEBUG dump, give the absolute sector number of the first sector of every non-empty file (including deleted files) in both decimal and hexadecimal: C:\>DEBUG -L 0 0 0 1 -D 0 9876:0000 EB 45 90 2B 4A 59 73 35-49 48 43 00 02 02 01 00 9876:0010 02 E0 00 40 0B F0 09 00-12 00 02 00 00 00 00 00 ... -------- Part II: -------- 6) Calculate (in decimal) the C/H/S (Cylinder/Head/trackSector) location of every starting sector from the previous question. Which sectors are on the top and which are on the bottom of the disk? Bonus: Write a program that, given sectors per track, number of heads, and an absolute sector number, returns the C/H/S of the given sector in decimal. ======== Answers: ======== 1) DAT2343DEMO Volume Label, Archive Needed (Note: no period in name!) DIRECT~1 SubDirectory 2) VENUS.TXT MARS.TXT Looking at the Windows long name gives us the missing first character of the DOS short name. 3) Name Size Starting Cluster FINLEXAMWPD 00009458h 37976d 00B1h 177d PROJECT4TXT 00000621h 1569d 0098h 152d TOTAL ASM 0000132Ch 4908d 009Ch 156d GETSHOW ASM 00001575h 5493d 00A6h 166d MERCURY TXT 00000000h 0d 0000h 0d (empty file) .ENUS TXT 00005678h 22136d 00ABh 171d EARTH TXT 00000000h 0d 0000h 0d (empty file) .ARS TXT 00001234h 4660d 01F0h 496d 4) Formula to calculate an Absolute (Disk) Sector number: = start sector of data clusters + (C# - 2) * sectors per cluster Start sector of data clusters = start sector of Cluster #2 = sectors in Cluster #0 + sectors in Cluster #1 Sectors in Cluster #0 = always 1 sector (boot block) Sectors in Cluster #1 = N copies of FAT, plus sectors in ROOT directory Sectors used for ROOT directory: = (number of ROOT entries * size of each entry) / bytes per sector 5) Decode the boot block using the table from the notes: http://www.algonquincollege.com/~pincka/dat2343/lect124.htm Bytes per sector: 0200h = 512d Sectors per cluster: 02h = 2d Copies of FAT: 02h = 2d Root dir entries: 00E0h = 224d Sectors per FAT: 0009h = 9d Sectors per track: 0012h = 18d Number of heads: 0002h = 2d Sectors used for N copies of FAT: Copies of FAT = 2h Sectors in each FAT = 9h PRODUCT 2h * 9h = 12h (18 decimal) sectors Sectors used for ROOT directory: Entries in ROOT directory = E0h (224 decimal) Size (in bytes) of each entry = 20h (32 decimal) Bytes per sector = 200h (512 decimal) Sectors in ROOT directory = (number of entries * size of each entry) / bytes per sector = (E0h * 20h) / 200h = (E0h * 1h) / 10h = E0h / 10h = Eh (14 decimal) Sectors in Cluster #1 = N copies of FAT, plus ROOT directory = 2h * 9h + Eh = 12h + Eh = 20h (32 decimal) Start sector of data clusters (start of Cluster #2) = sectors in Cluster #0 + sectors in Cluster #1 = 1h + 20h = 21h (33 decimal) Formula to calculate any Absolute Sector number for this disk = start of data clusters + (C# - 2) * sectors per cluster = 21h + (C# - 2) * 2h Using the formula: FINLEXAMWPD 00B1h -> 21h + ( B1h - 2) * 2 = 17Fh = 383d PROJECT4TXT 0098h -> 21h + ( 98h - 2) * 2 = 14Dh = 333d TOTAL ASM 009Ch -> 21h + ( 9Ch - 2) * 2 = 155h = 341d GETSHOW ASM 00A6h -> 21h + ( A6h - 2) * 2 = 169h = 361d .ENUS TXT 00ABh -> 21h + ( ABh - 2) * 2 = 173h = 371d .ARS TXT 01F0h -> 21h + (1F0h - 2) * 2 = 3FDh = 1021d 6) Using the method from the web page: From the BOOT sector DEBUG dump: Sectors per track: 0012h = 18d Number of heads: 0002h = 2d We calculate: Sectors per cylinder = 2d * 18d = 36d (decimal) Then we calculate C/H/S for all the absolute sectors (in decimal): FINLEXAMWPD sector 383d is located at 10/1/6 (bottom of disk) PROJECT4TXT sector 333d is located at 9/0/10 (top of disk) TOTAL ASM sector 341d is located at 9/0/18 (top of disk) GETSHOW ASM Sector 361d is located at 10/0/2 (top of disk) .ENUS TXT sector 371d is located at 10/0/12 (top of disk) .ARS TXT sector 1021d is located at 28/0/14 (top of disk)