00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00033 #ifndef FAT_FAT_FAT_H_
00034 #define FAT_FAT_FAT_H_
00035
00036 #include "../../vfs/vfs.h"
00037 #include <stdint.h>
00038 #include <libblock.h>
00039
00040 #define FAT1 0
00041
00042 #define FAT_CLST_RES0 0x0000
00043 #define FAT_CLST_RES1 0x0001
00044 #define FAT_CLST_FIRST 0x0002
00045 #define FAT_CLST_BAD 0xfff7
00046 #define FAT_CLST_LAST1 0xfff8
00047 #define FAT_CLST_LAST8 0xffff
00048
00049
00050 #define FAT_CLST_ROOTPAR FAT_CLST_RES0
00051
00052 #define FAT_CLST_ROOT FAT_CLST_RES1
00053
00054
00055 struct block;
00056 struct fat_node;
00057 struct fat_bs;
00058
00059 typedef uint16_t fat_cluster_t;
00060
00061 #define fat_clusters_get(numc, bs, dh, fc) \
00062 fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1)
00063 extern int fat_cluster_walk(struct fat_bs *, devmap_handle_t, fat_cluster_t,
00064 fat_cluster_t *, uint16_t *, uint16_t);
00065
00066 extern int fat_block_get(block_t **, struct fat_bs *, struct fat_node *,
00067 aoff64_t, int);
00068 extern int _fat_block_get(block_t **, struct fat_bs *, devmap_handle_t,
00069 fat_cluster_t, fat_cluster_t *, aoff64_t, int);
00070
00071 extern int fat_append_clusters(struct fat_bs *, struct fat_node *,
00072 fat_cluster_t, fat_cluster_t);
00073 extern int fat_chop_clusters(struct fat_bs *, struct fat_node *,
00074 fat_cluster_t);
00075 extern int fat_alloc_clusters(struct fat_bs *, devmap_handle_t, unsigned,
00076 fat_cluster_t *, fat_cluster_t *);
00077 extern int fat_free_clusters(struct fat_bs *, devmap_handle_t, fat_cluster_t);
00078 extern int fat_alloc_shadow_clusters(struct fat_bs *, devmap_handle_t,
00079 fat_cluster_t *, unsigned);
00080 extern int fat_get_cluster(struct fat_bs *, devmap_handle_t, unsigned,
00081 fat_cluster_t, fat_cluster_t *);
00082 extern int fat_set_cluster(struct fat_bs *, devmap_handle_t, unsigned,
00083 fat_cluster_t, fat_cluster_t);
00084 extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
00085 aoff64_t);
00086 extern int fat_zero_cluster(struct fat_bs *, devmap_handle_t, fat_cluster_t);
00087 extern int fat_sanity_check(struct fat_bs *, devmap_handle_t);
00088
00089 #endif
00090