edit: Nov 13 to attach latest version of script.
Thanks for the patch.
Here's my current test script.
tl;dr instructions:
Trunk 4277 or later build is required.
Run the script.
Post the logfile A/lfntest.log
If the camera crashes, you can look at the last item tried, and adjust the one of the limits described below to prevent files or paths of that length from being attempted.
I would suggest not running this on an SD card that has anything you wouldn't want to lose on it. I never had to reformat a card, but I did end up with some directories that could only be deleted using a card reader.
Gory details:
The basic approach is to try progressively increasing filename lengths in a series of increasingly deeper directory trees. It doesn't try every possible length, just some ranges I've found or guessed to be significant. It prints the file and path length of each test, just so you can see it's doing something. All the important information in is in the log.
There are many permutations that aren't tried: for example, all the directory names are short, and not much is done to check with total path limits are the same for long and short names. Since it uses lua io, it only checks fopen() behavior, not open(). stat and remove are also checked.
There are two options
Limit total path <=
Limit filename <=
These prevent the script from trying a path (directory + filename) or filename longer than the specified value. This can be used if certain values are found to crash.
All the crashes I've found were based on total path length (that is any path longer than X causes a crash, regardless how much is in the directory or file parts.) Filename limits seem to cause fopen to return an error.
Each file + directory length combination is logged with something like
TEST START
check: dir=A pfx=t01 ext=.TXT len=11
long: A/t01AAAA.TXT
short: A/T01AAAA.TXT
PASS open A/t01AAAA.TXT
PASS stat A/t01AAAA.TXT
PASS stat A/T01AAAA.TXT
PASS idir CHDK_LFN A/ found long
PASS idir CANON_FW A/ found short
PASS read A/t01AAAA.TXT
PASS read A/T01AAAA.TXT
PASS os.remove long
PASS remove long
TEST PASSED
"long:" and "short:" show the filename being tested. The "short" is based on the assumptiont the file will be ~1.EXT. The script checks whether a ~1 file exists before running the test, and logs an error if it does.
open tests opening the long name in write mode.
stat checks that the file was created, using both the long and short names
idir checks directory listing, with and without the chdklfn option (for dryos, vxworks only checks onece). The result of this can be: "found long", "found short", "found long==short" or an error.
Note that the short name can still be returned with chdklfn, if the long name is longer than 99 chars, or otherwise unsupported.
The no-chdklfn option can still return the long name: on vxworks, or in the root directory, or presumably on exfat.
read checks that the file can be read, using both long and short names and checking the content.
os.remove checks that it can delete the file by the long name. If removing by long name fails,
removing by short name is attempted.
The final remove test verifies with stat that the file was removed.
The script logs and flushes to disk after each check, so it should be relatively easy to see what combination triggered a crash.
If the script doesn't crash, a summary like the following is logged at the end:
PASSED 57
FAILED 6
path: 2 pass: 18 ( 20) fail: 19 ( 21)
path: 11 pass: 18 ( 29) fail: 19 ( 30)
path: 14 pass: 18 ( 32) fail: 19 ( 33)
path: 15 pass: 18 ( 33) fail: 19 ( 34)
path: 20 pass: 18 ( 38) fail: 19 ( 39)
path: 21 pass: 18 ( 39) fail: 19 ( 40)
path: 48 pass: 11 ( 59) fail:-
This shows the maximum file length that passed and minimum length that failed, for each directory depth attempted. In this case (D10), filenames longer than 18 chars generate an error, and the total path length is limited to 59 in options because the camera crashes on paths longer than this.
Limits are discovered are
A540 (vxworks, FAT16)
filename 18 total 255 (>255 crashes)
D10 (DryOS r31, FAT16)
filename 18 total 59 (>59 crashes)
sx160 (DryOS r49, FAT32) and elph130 (Dryos r51, FAT32)
filename 255 total unknown but > 500
The remaining versions of interest are DryOS r39-r47, IIRC some of these cameras had a ~32 char limit. DryOS < r31 might also be different.
VxWorks doesn't matter too much since CHDK has no special LFN support.
I have not tried exfat, but again since CHDK doesn't do anything special, it shouldn't matter too much.
I'm not too concerned about testing every variant before 1.4, if we have a system in place we can add limits for specific cameras as needed.