1 /*****************************************************************************\
3 fat.h - FAT12/FAT16 file system
5 (c) 2004 Copyright Hewlett-Packard Development Company, LP
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USALP
21 \*****************************************************************************/
25 #define FAT_HARDSECT 512 /* sector size in bytes */
27 /* Block size is set to the lowest common denominator. The ps325 reads 3 sectors max per command (LP?). While the ps130, ps 245,
28 * and ?? can do 8 sector reads.
30 #define FAT_BLKSIZE 3 /* block size in sectors */
43 int SectorsPerCluster;
50 } PHOTO_CARD_ATTRIBUTES;
55 int FatReadFile(char *name, int fd);
56 int FatReadFileExt(char *name, int offset, int len, void *outbuf);
57 int FatSetCWD(char *dir);
58 int FatDeleteFile(char *name);
59 int FatFreeSpace(void);
60 int FatDirBegin(FILE_ATTRIBUTES * a);
61 int FatDirNext(FILE_ATTRIBUTES * a);
62 int FatDiskAttributes(PHOTO_CARD_ATTRIBUTES * pa);
64 /* System dependent external functions */
65 extern int ReadSector(int sector, int nsector, void *buf, int size);
66 extern int WriteSector(int sector, int nsector, void *buf, int size);
70 #if defined(WORDS_BIGENDIAN)
71 #define h2lits(A) ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8)) /* host to little-endian 16-bit value */
72 #define lit2hs h2lits /* little-endian to host 16-bit value */