Slot validation

Preliminary note : I need to change return codes. In this page, you will see :
Table 2 : LDIR slot
Ord Name1
Name1 Attr Type Chksum  
Name2
  FstClusLO Name3

By field

Ord

Tot:255
OK : 40(15.7%)
Err:215(84.3%)
  • Intervals [0x01,0x13] and [0x41,0x54] are valid (see details below).
  • Taking erased long names into account, 0xE5 also is valid.

Specification does not give bounds explicitly (p.27), but as long as names are limited to 255 characters (p.29), only intervals [0x01,0x13] and [0x41,0x54] are valid.

I wonder why LAST_LONG_ENTRY mask was chosen to be 0x40, 0x20 would have been OK.

Name[1-3]

Tot:65536^13
OK :4.1x10^62(99.2%)
Err:3.4x10^60(0.8%)
  • No trailing periods or spaces
  • Trailing NUL then 0xFFFF padding if space available
  • 42 chars invalid inside name : 48 chars invalid in short names (p.24), plus 0xffff, less + , ; = [ ] . (p.29)

if there is no end of string signature, last char can be a space or a period :
sum(i=0..11,65 494 ^ i) * 65 492 + 65 494 ^ 13 valid combinations.

Attr

Tot:5
OK :2(40%)
W2 :3(60%)
  • OK : long filename attribute, 0x00 (linux-erased)
  • W2 : 2 higest bits not unset for long filename attribute.

Type

Tot:256
OK :1(0.4%)
W2 :255(99.6%)
  • 0x00 is the default. Other values are reserved for future extensions (p.27)

Chksum

Tot:256
OK :256(100%)
Check against the next DIR_Name

FstClusLO

Tot:2^16
OK :1(0.0%)
Err:65 535(100%)
  • Specification incoherence : must be zero (p.27) but "this might change in the future" (p.33)

Constraints

Ord + Name

Tot:255 x 65 536 ^ 13
OK :1.6 x 10^64(15.2%)
Err:8.9 x 10^64(84.8%)
  • No trailing periods
  • No leading or trailing spaces
  • Trailing NUL then 0xFFFF padding if space available

if LDIR_Ord is 0x01, 1st char can't be a space, and there is no end of string. Therefore, 65 493 * 65 494 ^ 12 valid combinations
if LDIR_Ord in [0x02, 0x13], there is no end of string. Therefore, 65 494 ^ 13 valid combinations
if LDIR_Ord is 0x41, both 1st char can't be a space and an end of string is present. Therefore 65 492 + 65 493 * sum(i=0..11, 65 494 ^ i) * 65 492 valid combinations
if LDIR_Ord in [0x42, 0x53], there is an end of string. Therefore, sum(i=0..12, 65 494 ^ i) * 65 492 valid combinations
if LDIR_Ord is 0x54, there are at most 8 characters. Therefore, sum(i=0..7, 65 494 ^ i) * 65 492 valid combinations
if LDIR_Ord id 0xe5, there is no restriction, therefore sum(i=0..11, 65 494 ^ i) * 65 492 + 65 494 ^ 13 valid combinations.

Better validation will be achieved with unicode checking vs short name codepage.

Ord + Name + Attr

Tot:255 x 65 536 ^ 13 x 4 + 1 x 65 536 ^ 13 x 1
OK :1.6 x 10^64(3.9%)
W2 :4.7 x 10^64(11.4%)
Err:3.5 x 10^65(84.8%)
Linux-erased long entries : sum(i=0..11, 65 494 ^ i) * 65 492 + 65 494 ^ 13 valid entries Normal long entries : 1.6 x 10^64 OK 3 x 1.6 x 10^64 W2

Overall

Tot:(255 x 4 + 1) x 65 536 ^ 13 x 256^4
OK :4.2 x 10^66(2.3 x 10^-9)
W2 :1.6 x 10^67(9.1 x 10^-9)
Err:1.8 x 10^75(~100%)