I just found this page that has a ton more FAT16 information - most of the stuff towards the beginning deals with the boot sector, the FAT16 system in general - towards the bottom it talks about the directory entries...
http://www.beginningtoseethelight.org/fat16/the name is stored in unicode format. a double byte character system designed to handle all possible foreign and scientific characters. the orginal ascii characters are the same except they are two bytes in size, the second byte is a null; 00. check http://www.unicode.org for a more in depth explaination. there can be up to 13 unicode characters per 32 byte section. if however the long file name does not fill the slot exactly a unicode null (00,00) will be added to the end, followed by ff,ff's until the section is filled. note that entries do not have to have a lfn.
Does CHDK
only support FAT16 file systems? If we are going to support FAT32 as well as FAT16 - things will obviously get a bit more complicated.
I'll take a stab at that code in a few minutes...
Haven't done much on the code, but found a bunch of open-source fat16 lfn implementations... One of them has some good definitions of structures and constants -
//
http://www.krugle.org/kse/files/archive/archive.sourceforge.net/sleuthkit/task-1.60/src/fstools/fatfs.h
/* flags for attributes field */
#define FATFS_ATTR_NORMAL 0x00 /* normal file */
#define FATFS_ATTR_READONLY 0x01 /* file is readonly */
#define FATFS_ATTR_HIDDEN 0x02 /* file is hidden */
#define FATFS_ATTR_SYSTEM 0x04 /* file is a system file */
#define FATFS_ATTR_VOLUME 0x08 /* entry is a volume label */
#define FATFS_ATTR_DIRECTORY 0x10 /* entry is a directory name */
#define FATFS_ATTR_ARCHIVE 0x20 /* file is new or modified */
#define FATFS_ATTR_LFN 0x0f /* A long file name entry */
#define FATFS_ATTR_ALL 0x3f /* all flags set */
/* constants for first byte of name[] */
#define FATFS_SLOT_EMPTY 0x00
#define FATFS_SLOT_E5 0x05 /* actual value is 0xe5 */
#define FATFS_SLOT_DELETED 0xe5
typedef unsigned char u_int8_t;
typedef unsigned int u_int32_t;
/* directory entry short name structure */
typedef struct {
u_int8_t name[8];
u_int8_t ext[3];
u_int8_t attrib;
u_int8_t lowercase;
u_int8_t ctimeten; /* create times */
u_int8_t ctime[2];
u_int8_t cdate[2];
u_int8_t adate[2]; /* access time */
u_int8_t highclust[2];
u_int8_t wtime[2]; /* last write time */
u_int8_t wdate[2];
u_int8_t startclust[2];
u_int8_t size[4];
} fatfs_dentry;
typedef struct {
u_int8_t seq;
u_int8_t part1[10];
u_int8_t attributes;
u_int8_t reserved1;
u_int8_t chksum;
u_int8_t part2[12];
u_int8_t reserved2[2];
u_int8_t part3[4];
} fatfs_dentry_lfn;
Given the set of FAT16 constants, it's pretty obvious that there are only a few ways that the function in the firmware can read LFN's out of FAT16 - so there are only a few possible things to search for to find a function that reads directories... That being said - I'm not good enough at IDA to do it efficiently yet
At some point in any function, it's going to have to check two bytes it will have to see if the attribute is set to 0x0F and then it will have to check the sequence bit... It will also have to grab the pieces of the name in the set chunk sizes...
Would the DryOS compiler define a data structure for this the lfn? (i.e. make data structures in the compiled version that match structs the programmer wrote them in) Perhaps looking for a data structure that matched the known data structure of the fat16 lfn might help...
I'm leafing through my firmware looking and going over ARM9 as I do it. I searched for all occurrences of 0x0f - of which, there are many... but not an infinite number.
I found a few more helpful ARM things - like this quick reference:
http://www.zap.org.au/elec2041-cdrom/reference/arm-instructions-quickref.pdfOr this paper on ARM performance that talks about the use of the semaphore in an RTOS:
http://www.nit.gsu.unibel.by/resources/conferences%5Cesc_2004%5CSan_Francisco%5Cesc_470.pdf