123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- #ifndef _FAT_H_
- #define _FAT_H_
- #include <asm/byteorder.h>
- #define CONFIG_SUPPORT_VFAT
- #define VFAT_MAXLEN_BYTES 256
- #define VFAT_MAXSEQ 9
- #define PREFETCH_BLOCKS 2
- #ifndef CONFIG_FS_FAT_MAX_CLUSTSIZE
- #define CONFIG_FS_FAT_MAX_CLUSTSIZE 65536
- #endif
- #define MAX_CLUSTSIZE CONFIG_FS_FAT_MAX_CLUSTSIZE
- #define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry))
- #define DIRENTSPERCLUST ((mydata->clust_size * mydata->sect_size) / \
- sizeof(dir_entry))
- #define FATBUFBLOCKS 6
- #define FATBUFSIZE (mydata->sect_size * FATBUFBLOCKS)
- #define FAT12BUFSIZE ((FATBUFSIZE*2)/3)
- #define FAT16BUFSIZE (FATBUFSIZE/2)
- #define FAT32BUFSIZE (FATBUFSIZE/4)
- #define MAX_LFN_SLOT 20
- #define FAT12_SIGN "FAT12 "
- #define FAT16_SIGN "FAT16 "
- #define FAT32_SIGN "FAT32 "
- #define SIGNLEN 8
- #define ATTR_RO 1
- #define ATTR_HIDDEN 2
- #define ATTR_SYS 4
- #define ATTR_VOLUME 8
- #define ATTR_DIR 16
- #define ATTR_ARCH 32
- #define ATTR_VFAT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
- #define DELETED_FLAG ((char)0xe5)
- #define aRING 0x05
- #define LAST_LONG_ENTRY_MASK 0x40
- #define LS_NO 0
- #define LS_YES 1
- #define LS_DIR 1
- #define LS_ROOT 2
- #define ISDIRDELIM(c) ((c) == '/' || (c) == '\\')
- #define FSTYPE_NONE (-1)
- #if defined(__linux__) && defined(__KERNEL__)
- #define FAT2CPU16 le16_to_cpu
- #define FAT2CPU32 le32_to_cpu
- #else
- #if __LITTLE_ENDIAN
- #define FAT2CPU16(x) (x)
- #define FAT2CPU32(x) (x)
- #else
- #define FAT2CPU16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8))
- #define FAT2CPU32(x) ((((x) & 0x000000ff) << 24) | \
- (((x) & 0x0000ff00) << 8) | \
- (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0xff000000) >> 24))
- #endif
- #endif
- #define START(dent) (FAT2CPU16((dent)->start) \
- + (mydata->fatsize != 32 ? 0 : \
- (FAT2CPU16((dent)->starthi) << 16)))
- #define IS_LAST_CLUST(x, fatsize) ((x) >= ((fatsize) != 32 ? \
- ((fatsize) != 16 ? 0xff8 : 0xfff8) : \
- 0xffffff8))
- #define CHECK_CLUST(x, fatsize) ((x) <= 1 || \
- (x) >= ((fatsize) != 32 ? \
- ((fatsize) != 16 ? 0xff0 : 0xfff0) : \
- 0xffffff0))
- typedef struct boot_sector {
- __u8 ignored[3];
- char system_id[8];
- __u8 sector_size[2];
- __u8 cluster_size;
- __u16 reserved;
- __u8 fats;
- __u8 dir_entries[2];
- __u8 sectors[2];
- __u8 media;
- __u16 fat_length;
- __u16 secs_track;
- __u16 heads;
- __u32 hidden;
- __u32 total_sect;
-
- __u32 fat32_length;
- __u16 flags;
- __u8 version[2];
- __u32 root_cluster;
- __u16 info_sector;
- __u16 backup_boot;
- __u16 reserved2[6];
- } boot_sector;
- typedef struct volume_info
- {
- __u8 drive_number;
- __u8 reserved;
- __u8 ext_boot_sign;
- __u8 volume_id[4];
- char volume_label[11];
- char fs_type[8];
-
-
- } volume_info;
- typedef struct dir_entry {
- char name[8],ext[3];
- __u8 attr;
- __u8 lcase;
- __u8 ctime_ms;
- __u16 ctime;
- __u16 cdate;
- __u16 adate;
- __u16 starthi;
- __u16 time,date,start;
- __u32 size;
- } dir_entry;
- typedef struct dir_slot {
- __u8 id;
- __u8 name0_4[10];
- __u8 attr;
- __u8 reserved;
- __u8 alias_checksum;
- __u8 name5_10[12];
- __u16 start;
- __u8 name11_12[4];
- } dir_slot;
- typedef struct {
- __u8 *fatbuf;
- int fatsize;
- __u32 fatlength;
- __u16 fat_sect;
- __u8 fat_dirty;
- __u32 rootdir_sect;
- __u16 sect_size;
- __u16 clust_size;
- int data_begin;
- int fatbufnum;
- } fsdata;
- typedef int (file_detectfs_func)(void);
- typedef int (file_ls_func)(const char *dir);
- typedef int (file_read_func)(const char *filename, void *buffer,
- int maxsize);
- struct filesystem {
- file_detectfs_func *detect;
- file_ls_func *ls;
- file_read_func *read;
- const char name[12];
- };
- file_detectfs_func file_fat_detectfs;
- file_ls_func file_fat_ls;
- file_read_func file_fat_read;
- int file_cd(const char *path);
- int file_fat_detectfs(void);
- int file_fat_ls(const char *dir);
- int fat_exists(const char *filename);
- int fat_size(const char *filename, loff_t *size);
- int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
- loff_t maxsize, loff_t *actread);
- int file_fat_read(const char *filename, void *buffer, int maxsize);
- const char *file_getfsname(int idx);
- int fat_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
- int fat_register_device(struct blk_desc *dev_desc, int part_no);
- int file_fat_write(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actwrite);
- int fat_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actread);
- void fat_close(void);
- #endif
|