0% found this document useful (0 votes)
79 views8 pages

Lecture # 37: Long Filename

The document discusses experiments performed to view how long file names are managed in Windows. It shows the results of a DIR command on a volume containing a file with a very long name. It then reads the drive parameter block (DPB) of the volume and displays the root directory entries to see how long file names are stored.

Uploaded by

api-3812413
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views8 pages

Lecture # 37: Long Filename

The document discusses experiments performed to view how long file names are managed in Windows. It shows the results of a DIR command on a volume containing a file with a very long name. It then reads the drive parameter block (DPB) of the volume and displays the root directory entries to see how long file names are stored.

Uploaded by

api-3812413
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

System Programming Course Code: CS609

[email protected]

Lecture # 37

Lets now perform few more experiments to see how long file names are managed.
Windows can have long file names up to 255 characters. For This purpose a file is created
with a long file name as shown in the slide below.

Following shows the result of DIR command on the same volume.

Long FileName
Volume in drive H is NEW VOLUME
Volume Serial Number is 8033-3F79

Directory of H:\

09/14/2005 10:00 AM <DIR> New Folder


10/23/2005 11:20 AM 0 I am new file to experiment long file
names.txt
1 File(s) 0 bytes
1 Dir(s) 409,944,064 bytes free

Virtual University of Pakistan 40


System Programming Course Code: CS609
[email protected]

In the following slide the DPB of the volume is being read.

Drive Parameter Block


-a
0AFC:0100 mov ah,32
0AFC:0102 int 21
0AFC:0104

-p
AX=3200 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AFC ES=0AFC SS=0AFC CS=0AFC IP=0102 NV UP EI PL NZ NA PO NC
0AFC:0102 CD21 INT 21

-p
AX=3200 BX=13D2 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=00A7 ES=0AFC SS=0AFC CS=0AFC IP=0104 NV UP EI PL NZ NA PO NC
0AFC:0104 06 PUSH ES

-d a7:13d2

00A7:13D0 07 07 00 02 0F 04-08 00 02 00 02 B0 01 87 ..............


00A7:13E0 C3 C4 00 90 01 56 34 12-00 F8 0A FF FF FF FF 00 .....V4.........
00A7:13F0 00 7A C3 00 00 00 00 00-00 00 00 00 00 00 00 00 .z..............
00A7:1400 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00A7:1410 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00A7:1420 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
00A7:1430 00 00 00 00 00 00 00 0C-00 00 80 00 06 0B 10 00 ................
00A7:1440 2E 0A 4D 5A 9A 00 29 00-00 00 20 00 C5 00 FF FF ..MZ..)... .....
00A7:1450 A7 05 ..

Using the information in DPB the root directory entries are read and are being shown in
the slide below.

Directory Entry
-l 1000 7 190 20

-d 1000
0AFC:1000 4E 45 57 20 56 4F 4C 55-4D 45 20 08 00 00 00 00 NEW VOLUME .....
0AFC:1010 00 00 00 00 00 00 04 4F-2E 33 00 00 00 00 00 00 .......O.3......
0AFC:1020 41 4E 00 65 00 77 00 20-00 46 00 0F 00 DD 6F 00 AN.e.w. .F....o.
0AFC:1030 6C 00 64 00 65 00 72 00-00 00 00 00 FF FF FF FF l.d.e.r.........
0AFC:1040 4E 45 57 46 4F 4C 7E 31-20 20 20 10 00 41 09 50 NEWFOL~1 ..A.P
0AFC:1050 2E 33 2E 33 00 00 0A 50-2E 33 02 00 00 00 00 00 .3.3...P.3......
0AFC:1060 42 20 00 49 00 6E 00 66-00 6F 00 0F 00 72 72 00 B .I.n.f.o...rr.
0AFC:1070 6D 00 61 00 74 00 69 00-6F 00 00 00 6E 00 00 00 m.a.t.i.o...n...
0AFC:1080 01 53 00 79 00 73 00 74-00 65 00 0F 00 72 6D 00 .S.y.s.t.e...rm.
0AFC:1090 20 00 56 00 6F 00 6C 00-75 00 00 00 6D 00 65 00 .V.o.l.u...m.e.
0AFC:10A0 53 59 53 54 45 4D 7E 31-20 20 20 16 00 44 09 50 SYSTEM~1 ..D.P
0AFC:10B0 2E 33 2E 33 00 00 0A 50-2E 33 03 00 00 00 00 00 .3.3...P.3......
0AFC:10C0 E5 6D 00 65 00 6E 00 74-00 2E 00 0F 00 9F 74 00 .m.e.n.t......t.
0AFC:10D0 78 00 74 00 00 00 FF FF-FF FF 00 00 FF FF FF FF x.t.............
0AFC:10E0 E5 4E 00 65 00 77 00 20-00 54 00 0F 00 9F 65 00 .N.e.w. .T....e.
0AFC:10F0 78 00 74 00 20 00 44 00-6F 00 00 00 63 00 75 00 x.t. .D.o...c.u.
0AFC:1100 E5 45 57 54 45 58 7E 31-54 58 54 20 00 9D 11 50 .EWTEX~1TXT ...P
0AFC:1110 2E 33 2E 33 00 00 12 50-2E 33 00 00 00 00 00 00 .3.3...P.3......
0AFC:1120 E5 79 00 73 00 74 00 65-00 6D 00 0F 00 A4 2E 00 .y.s.t.e.m......
0AFC:1130 74 00 78 00 74 00 00 00-FF FF 00 00 FF FF FF FF t.x.t...........
0AFC:1140 E5 6C 00 20 00 74 00 68-00 65 00 0F 00 A4 20 00 .l. .t.h.e.... .
0AFC:1150 66 00 61 00 74 00 31 00-36 00 00 00 20 00 73 00 f.a.t.1.6... .s.
0AFC:1160 E5 66 00 69 00 6C 00 65-00 20 00 0F 00 A4 74 00 .f.i.l.e. ....t.

Virtual University of Pakistan 41


System Programming Course Code: CS609
[email protected]

Cont…
0AFC:1170 6F 00 20 00 63 00 68 00-65 00 00 00 63 00 6B 00 o. .c.h.e...c.k.
0AFC:1180 E5 74 00 68 00 69 00 73-00 69 00 0F 00 A4 73 00 .t.h.i.s.i....s.
0AFC:1190 20 00 61 00 20 00 6E 00-65 00 00 00 77 00 20 00 .a. .n.e...w. .
0AFC:11A0 E5 48 49 53 49 53 7E 32-54 58 54 20 00 9D 11 50 .HISIS~2TXT ...P
0AFC:11B0 2E 33 2E 33 00 00 12 50-2E 33 00 00 00 00 00 00 .3.3...P.3......
0AFC:11C0 41 52 00 65 00 63 00 79-00 63 00 0F 00 21 6C 00 AR.e.c.y.c...!l.
0AFC:11D0 65 00 64 00 00 00 FF FF-FF FF 00 00 FF FF FF FF e.d.............
0AFC:11E0 52 45 43 59 43 4C 45 44-20 20 20 16 00 86 A7 63 RECYCLED ....c
0AFC:11F0 3C 33 3C 33 00 00 A8 63-3C 33 08 00 00 00 00 00 <3<3...c<3......
0AFC:1200 E5 6D 00 65 00 6E 00 74-00 2E 00 0F 00 9F 74 00 .m.e.n.t......t.
0AFC:1210 78 00 74 00 00 00 FF FF-FF FF 00 00 FF FF FF FF x.t.............
0AFC:1220 E5 4E 00 65 00 77 00 20-00 54 00 0F 00 9F 65 00 .N.e.w. .T....e.
0AFC:1230 78 00 74 00 20 00 44 00-6F 00 00 00 63 00 75 00 x.t. .D.o...c.u.
0AFC:1240 E5 45 57 54 45 58 7E 31-54 58 54 20 00 8C F8 56 .EWTEX~1TXT ...V
0AFC:1250 57 33 57 33 00 00 F9 56-57 33 00 00 00 00 00 00 W3W3...VW3......
0AFC:1260 E5 61 00 6D 00 65 00 2E-00 74 00 0F 00 43 78 00 .a.m.e...t...Cx.
0AFC:1270 74 00 00 00 FF FF FF FF-FF FF 00 00 FF FF FF FF t...............
0AFC:1280 E5 6B 00 20 00 6C 00 6F-00 6E 00 0F 00 43 67 00 .k. .l.o.n...Cg.
0AFC:1290 20 00 66 00 69 00 6C 00-65 00 00 00 20 00 6E 00 .f.i.l.e... .n.
0AFC:12A0 E5 20 00 66 00 69 00 6C-00 65 00 0F 00 43 20 00 . .f.i.l.e...C .
0AFC:12B0 74 00 6F 00 20 00 63 00-68 00 00 00 65 00 63 00 t.o. .c.h...e.c.
0AFC:12C0 E5 74 00 68 00 69 00 73-00 20 00 0F 00 43 69 00 .t.h.i.s. ...Ci.
0AFC:12D0 73 00 20 00 61 00 20 00-6E 00 00 00 65 00 77 00 s. .a. .n...e.w.
0AFC:12E0 E5 48 49 53 49 53 7E 31-54 58 54 20 00 8C F8 56 .HISIS~1TXT ...V
0AFC:12F0 57 33 57 33 00 00 F9 56-57 33 00 00 00 00 00 00 W3W3...VW3......
0AFC:1300 E5 6D 00 65 00 6E 00 74-00 2E 00 0F 00 9F 74 00 .m.e.n.t......t.

Cont…
0AFC:1310 78 00 74 00 00 00 FF FF-FF FF 00 00 FF FF FF FF x.t.............
0AFC:1320 E5 4E 00 65 00 77 00 20-00 54 00 0F 00 9F 65 00 .N.e.w. .T....e.
0AFC:1330 78 00 74 00 20 00 44 00-6F 00 00 00 63 00 75 00 x.t. .D.o...c.u.
0AFC:1340 E5 45 57 54 45 58 7E 31-54 58 54 20 00 26 85 5A .EWTEX~1TXT .&.Z
0AFC:1350 57 33 57 33 00 00 86 5A-57 33 00 00 00 00 00 00 W3W3...ZW3......
0AFC:1360 44 61 00 6D 00 65 00 73-00 2E 00 0F 00 0A 74 00 Da.m.e.s......t.
0AFC:1370 78 00 74 00 00 00 FF FF-FF FF 00 00 FF FF FF FF x.t.............
0AFC:1380 03 74 00 20 00 6C 00 6F-00 6E 00 0F 00 0A 67 00 .t. .l.o.n....g.
0AFC:1390 20 00 66 00 69 00 6C 00-65 00 00 00 20 00 6E 00 .f.i.l.e... .n.
0AFC:13A0 02 20 00 74 00 6F 00 20-00 65 00 0F 00 0A 78 00 . .t.o. .e....x.
0AFC:13B0 70 00 65 00 72 00 69 00-6D 00 00 00 65 00 6E 00 p.e.r.i.m...e.n.
0AFC:13C0 01 49 00 20 00 61 00 6D-00 20 00 0F 00 0A 6E 00 .I. .a.m. ....n.
0AFC:13D0 65 00 77 00 20 00 66 00-69 00 00 00 6C 00 65 00 e.w. .f.i...l.e.
0AFC:13E0 49 41 4D 4E 45 57 7E 31-54 58 54 20 00 26 85 5A IAMNEW~1TXT .&.Z
0AFC:13F0 57 33 57 33 00 00 86 5A-57 33 00 00 00 00 00 00 W3W3...ZW3......
0AFC:1400 52 4F 4F 54 48 20 20 20-54 58 54 20 18 0F 95 5C ROOTH TXT ...\
0AFC:1410 57 33 57 33 00 00 96 5C-57 33 0E 00 13 00 00 00 W3W3...\W3......
0AFC:1420 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0AFC:1430 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0AFC:1440 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0AFC:1450 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0AFC:1460 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0AFC:1470 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................

I n the above slide it can be noticed that the long file name is also stored with the FCBs.
Also the fragments of Unicode strings in the long file name forms a chain. The first byte
in the chain will be 0x01, the first byte of the next fragment will be 0x02 and so on till
the last fragment. If the last fragment is the nth fragment starting from 0 such that n is
between 0 and 25 the first byte of the last fragment will be given as ASCII of ‘A’ plus n.

Virtual University of Pakistan 42


System Programming Course Code: CS609
[email protected]

Now lets move our discussion to FAT32. In theory the major difference between FAT 16
and FAT 32 is of course the FAT size. FAT32 evidently will contain more entries and can
hence manage a very large disk whereas FAT16 can manage a space of 2 GB maximum
practically.
Following slide shows the structure of the BPB for FAT32. Clearly there would be some
additional information required in FAT32 so the structure for BPB used in FAT32 is
different.

Fat32 BPB Structure

Virtual University of Pakistan 43


System Programming Course Code: CS609
[email protected]

Virtual University of Pakistan 44


System Programming Course Code: CS609
[email protected]

There can be different volumes with different volume sizes. The device driver for file
handling would require knowing the FAT size. The following slide illustrates an
algorithm that can be used to determine the FAT size in use after reading the BPB.

Virtual University of Pakistan 45


System Programming Course Code: CS609
[email protected]

Virtual University of Pakistan 46


System Programming Course Code: CS609
[email protected]

Fat Type Determination


if(BPB_ FATSz16 != 0)
FATSz = BPB_ FATSz16 ;
else
FATSz = BPB_ FATSz32 ;
if(BPB_TotSec16 != 0)
TotSec = BPB_TotSec16;
else
TotSec = BPB_TotSec32;
DataSec = TotSec – (BPB_ResvdSecCnt + (BPB_Num FATs * FATSz) +
RootDirSectors);
CountofClusters = DataSec / BPB_SecPerClus ;

if(CountofClusters < 4085)


/* Volume is FAT12 */
else if(CountofClusters < 65525)
/* Volume is FAT16 */
else
/* Volume is FAT32 */

Virtual University of Pakistan 47

You might also like