Slot validation

Preliminary note : I need to change return codes. In this page, you will see :
Table 1 : DIR slot
(*) CrtTimeTenth
Name
Extension Attr NTRes CrtTT (*) CrtTime
CrtDate LstAccDate FstClusHI WrtTime
WrtDate FstClusLO FileSize

By fields

Name

Tot:256^11
OK :3.0 x 10^25(9.8%)
W2 :1.2 x 10^24(0.4%)
Err:2.8 x 10^26(89.8%)
  • 48 chars invalid in names (p.24)
  • 2 special entries are valid : dot and dotdot (p.25)
  • First char might be 0x05 (p.23), must not be 0x20 (space) (p.24)
  • Inner spaces in either name or extension are valid but never used (p.29)

256 - 48 = 208 chars are valid, hence 208^11 names are valid, plus 2 special names

However, names with spaces that aren't padding chars will generate a warning.
sum(i=0..3, 207^i) extensions are OK (only trailing spaces)
208 * sum(i=0..7, 207^i) names are OK

Better scores would be achieved using codepage information (uppercase...)

Note that these values are taking erased file names into account.

Attr

Tot:256
OK : 34(13.3%)
W2 :158(61.7%)
Err: 64(25.0%)
  • 2 highest bits should be unset (p.23)
  • When attributes RHSV (=LongName) are set, attributes DA must be unset (p.26)
  • When V and not RHS, D must be unset (p.33), RHSA should be unset (p.22, p.24).

Attributes are :

  • (R)ead-only
  • (H)idden
  • (S)ystem
  • (V)olume-id
  • (D)irectory
  • (A)rchive

Combinations repartition :

  • 32 OK combinations of R,H,S,D and A (+ 32*3 W2)
  • 1 OK : V (+ 3 W2)
  • 1 OK : RHSV (+ 3 W2)
  • 64 Err with VD
  • 14 W2 with V but not D (+ 14*3 W2)

About W2 : Nothing in the specification prevents attributes RHSA to be set when V is set. However in that case that wouldn't be a volume name anymore and apart RHSV combination, no other combination is defined in the version 1.03 .

OK and W2 have the following type repartition :

  • 14 + 14*3 = 56 are unknown (future expansion)
  • 1 + 3 = 4 are long-name entries
  • 1 + 3 = 4 are volume-id
  • 16 + 16*3 = 64 are directories
  • 1 = 1 is file OR linux-erased long name entry
  • 15 + 16*3 = 63 are files

NTRes

Tot:256
OK :256(100%)
  • NT reserved. 0x00 is the default. (p.23)

CrtTimeTenth

Tot:256
OK :200(78.1%)
Err: 56(21.9%)
  • (p.23)

CrtTime, WrtTime

Tot:65 536
OK :43 200(65.9%)
Err:22 236(34.1%)
  • (p.25)

OK times : 24 * 60 * 30 = 43 200

CrtDate, LstAccDate

Tot:65 536
OK :46 752(71.3%)
Err:18 784(28.7%)
  • (p.25)

OK dates : 365.25 * 128 - 1 (2100 isn't leap) + 1 (no date is valid) = 46 752

WrtDate

Tot:65 536
OK :46 751(71.3%)
Err:18 785(28.7%)
  • (p.25)

OK dates : 365.25 * 128 - 1 (2100 isn't leap) = 46 751

FstClus

Tot:2^32
OK :2^28-40 ( 6.2%)
W2 :4 026 531 840(93.8%)
Err: 40( 0.0%)
  • 4 higher bits should be set to 0 (p.16)
  • 0x(f)f7-0x(f)ff (p.17) reserved and therefore invalid.
  • 2 being the first data cluster, 1 also is invalid (p.13)

Validation is also disk-dependant, not only semantic-dependant.

FileSize

Tot:2^32
OK :2^32(100%)

All sizes might be valid.

Constraints

Date and Time

Tot:256^11
OK :3.8 x 10^25(12.3%)
W2 :8.2 x 10^20( 0.0%)
Err:2.7 x 10^27(87.7%)
  • DIR_CrtDate and DIR_LstAccDate may be 0, DIR_WrtDate must not.
  • If Time != 0, Date should be set (!=0).
  • If DIR_LstAccDate is set, DIR_CrtDate should be set

Timestamps

  • Write date and time :
    • Tot : 2^32
    • OK : 46 751 * 43 200 = 2 019 643 200 (47.0%)
    • Err : 2 275 324 096 (53.0%)
  • Creation date and time :
    • Tot : 2^40
    • OK : 43 200 * 46 751 * 200 + 1 = 403 928 640 001 (36.7%)
    • W2 : 43 199 * 200 + 199 = 8 639 999 (0.0%) (DIR_CrtDate undefined but either DIR_CrtTime or DIR_CrtTimeTenth defined)
    • Err : 695 574 347 776 (63.3%)

    Although not explicitly forbidden by the specification, it makes in my opinion no sense to have creation time defined while creation date undefined.

  • Last access date
    • Tot : 2^16
    • OK : 46 751 + 1 = 46 752 (71.3%)
    • Err : 18 784 (28.7%)

Missing definitions

As far as I know, there are no implementations supporting last access date but not creation date.

  • Tot : 2^88
  • OK : 2 019 643 200 * 403 928 640 000 * 46 752 + 2 019 643 200 = 38 139 895 010 575 468 515 643 200 (12.3%)
  • W2 : 2 019 643 200 * 8 639 999 * 46 752 + 2 019 643 200 * 1 * 46 751 = 815 809 180 776 476 356 800 (0.0%)
  • Err : 2 275 324 096 * 2^40 * 2^16 + 2 019 643 200 * 695 574 347 776 * 2^16 + 2 019 643 200 * (403 928 640 001 + 8 639 999) * 18784 = 271 344 299 001 588 823 732 781 056 (87.7%)

Timestamps ordering

(not yet implemented)

Last access date should me more recent than both creation and write times. However, if a file was written on a last access supporting system, then is modified by a last access unaware system, that condition won't be satisfied and we will generate a W1.

Also, no assumption can be made between creation and write dates : copying a file from one support to another will change target's creation date, but not last write date, which is interpreted as last modification date. Note that the specification seems to imply the opposite : Time of last write. Note that file creation is considered a write. (p.23)

  • Only write date defined :
    • Tot : 2^32
    • OK : 46 751 * 43 200 = 2 019 643 200 (47.0%)
    • Err : 2 275 324 096 (53.0%)
  • Write and creation dates defined :

    Note again that implementations do not follow the specification (or is it the other way ?)

    • Tot : 2^72-2^32
    • OK : 200 * sum(i=1..2 019 643 200, i) = 200 * (2 019 643 200 * 2 019 643 201) / 2 = 407 895 865 732 588 320 000 (8.6%)
    • W1 : 200 * sum(i=1..2 019 643 199, i) = 200 * (2 019 643 199 * 2 019 643 200) / 2 = 407 895 865 328 659 680 000 (8.6%)
    • W2 : 2 019 643 200 * 8 639 999 = 17 449 715 228 356 800 (0.0%)
    • Err : 2 275 324 096 * (2^40-1) + 2 019 643 200 * 695 574 347 776 = 3 906 557 302 091 149 213 696 (82.7%)
  • All dates defined
    • Tot : 2^88-2^72+2^32
    • OK : sum(i=1..46751, 200*sum(j=1..43200*i, j)) = 200 * sum(i=1..46751, (43200*i*(43200*i+1) / 2) ) = 6 356 717 157 248 760 568 320 000 (2.1%)
    • W1 (Wrt<Crt) : sum(i=1..46751, 200*sum(j=1..43200*i-1, j)) = 200 * sum(i=1..46751, (43200*i-1)*43200*i/2) = 6 356 717 147 806 524 679 680 000 (2.1%)
    • W1 (LAcc<Wrt, Wrt<=Crt) :

DIR_Name + DIR_Attr + DIR_FstClus + DIR_FileSize

  • if (Name=='.' or Name=='..') then ATTR_DIRECTORY is set
  • if ATTR_DIRECTORY or ATTR_VOLUME_ID is set, FileSize=0
  • if ATTR_DIRECTORY is unset, if FileSize=0 then FstClus=0