SD Core for Windows WC2.0-0

sdfix: What It Checks and Repairs

Every error a check reports, what -F or -Q does about it, the dump and rebuild of mis-hashed groups, interactive mode, and what the tool will not do.

This document is separate so that it can be withheld. It links to nothing outside the administrator set. Where a page in another set is worth naming, it is named in words.

This is the second half of sdfix, the File Check Tool, which has the options and the rules for running it.

What a check reports, and what -F does#

A check never changes the file, except for -Z. Under -F every row with a repair is done without asking; under -Q each is offered with Fix?.

The check says Meaning The repair
Invalid group size (n bytes) the header's group size is not a multiple of 1,024 or is out of range none; the check stops
Large record size is invalid (n) the size above which a record goes to its own blocks is outside the group resets it to the group size less the block header
Invalid split and/or merge loads (a, b) split load is not above merge load writes the defaults SD gives a new file, split 80 and merge 50, and says Corrected by resetting to defaults (80, 50)
AKn subfile found but not expected an index file the header does not list deletes the file (an index in the file's own folder or in a relocated index folder), and says Corrected by deleting affected AK index subfile only if it went; otherwise The AK index subfile could not be deleted
AKn subfile not found the header lists an index whose file is gone removes the index from the header. The file then has no index of that name. Create and build it again
Cannot read AKn subfile header, AKn subfile has incorrect magic number a damaged index file (the magic number) deletes the file and removes the index from the header (if the file could not be deleted it says so and still removes the index from the header). An index file that cannot be read at all (an empty one, say) is reported once, as Cannot read AKn subfile header, and repaired once. Create and build it again
Active group n found after released group(s)! a used group follows groups marked as released writes empty groups over the released ones
Group n has incorrect block type (t) sets the type to data
Record 'id' mis-hashed into group n. Should be in group m the record's id does not hash to the group it is in queues the group for dump and rebuild (below). Only -F queues; -Q reports only. At most 50 are reported
Error in large record. Group g, ... Record cannot be recovered. the chain of a large record is broken deletes the record; its header is cut out of the group
Apparent modulus a differs from recorded modulus b the groups actually in use do not match the header sets the header's modulus to the number of groups in use
Incorrect mod_value (a), expected b sets it
Minimum modulus is invalid (n) sets it to 1
Load error: Actual a, file header b the bytes in use differ from the header's count updates the header
Record count error: Actual a, file header (adjusted) b, Header record count has not been set updates the header
Overflow block x has non-zero used byte count a block on the free chain holds data clears it
Faulty next block pointer, Read error at ... the free chain is broken none; the walk of the free chain stops
Overflow block n (xaddr) unreferenced reachable from no group, large record or free chain puts it on the free chain
AK n node k unreferenced an index node reachable from nothing puts it on the index's free node chain
Non-existant node, Read error on node, Type t node ... also referenced from, Unexpected node type, Invalid forward pointer in free node and the like the index tree is damaged none. Index trees are only reported on. Delete the index and build it again

The header's longest-id value is also reset to the real longest id under -F, without a message, because a value above SD's id limit would stop the file opening.

-F is not a repair of last resort. Several rows rewrite the header from what the scan found. If the scan is wrong because a group is damaged, the header is then wrong in step with it, and the next run is quiet about it. Look at what a check reports before you let -F act on it.

Dump and rebuild of mis-hashed groups#

When -F has queued groups, the check ends with a question that is asked even under -F:

Dump and rebuild groups with mis-hashed records? Y
Creating temporary file
Data copied to temporary file
Original groups cleared
Data rewritten
Temporary file deleted

In this example the header's mod value was 1, so half the records hashed to the wrong group. The check reports 20 records, the -F run sets the mod value back to 2 and rebuilds the group, and a second check is clean. All 40 records were still there.

Interactive mode (-I)#

This is a developer's debugging tool, and it can write anywhere in the file. It is off unless the configuration file has DEBUG with bit 2 set (DEBUG=2 in the [sd] section). Without that, sdfix -I prints the usage text and does nothing. To use it without changing C:\ProgramData\SD\sd.conf, copy that file, add the line to the copy, and point SD_CONFIG at the copy for that one run (the file is read when the program starts).

The prompt shows the selected subfile (0?). Commands: check, fix (a check with -F's unconditional repairs); Gn display group n, ga all groups; h the header, with the file offset of each field in hex; Lid the hash value, group and address of a record id; Sn select a subfile (0 primary, 1 overflow, 2 onward indexes); n and p next and previous window; a number shows the window at that decimal address; rebuild n dump and rebuild group n; recover; z the file's statistics counters; ?; q.

What it will not do#