uspace/srv/fs/fat/fat_fat.h
#define FAT_IS_FAT12(bs) (CC(bs) < FAT12_CLST_MAX)
#define FAT_IS_FAT16(bs) \
((CC(bs) >= FAT12_CLST_MAX) && (CC(bs) < FAT16_CLST_MAX))
#define FAT_CLST_LAST1(bs) \
(FAT_IS_FAT12(bs) ? FAT12_CLST_LAST1 : FAT16_CLST_LAST1)
#define FAT_CLST_LAST8(bs) \
(FAT_IS_FAT12(bs) ? FAT12_CLST_LAST8 : FAT16_CLST_LAST8)
#define FAT_CLST_BAD(bs) \
(FAT_IS_FAT12(bs) ? FAT12_CLST_BAD : FAT16_CLST_BAD)
Max clusters count for FAT12
#define FAT12_CLST_MAX 4085Max clusters count for FAT16
#define FAT16_CLST_MAX 65525
2. I used new macros while mounting first to check type of FAT:
uspace/srv/fs/fat/fat_ops.c
/* Determining type of FAT */
if (FAT_IS_FAT12(bs)) {
printf("Found FAT12 filesystem\n");
} else if (FAT_IS_FAT16(bs)) {
printf("Found FAT16 filesystem\n");
} else {
printf("FAT32 filesystem is not supported by FAT server.\n");
block_fini(devmap_handle);
async_answer_0(rid, ENOTSUP);
return;
}
3. Of course I have changed in fat_fat.c all FATTYPE(bs) == 12 to FAT_IS_FAT12(bs)
4. I try going to use FAT_IS_FAT12 instead of FAT_IS_FAT16 because it require only one calculation for clusters count.
5. I insert additional variables like clst_last1 or clst_bad to store FAT depended values when its necessary.
fat_cluster_t clst_last1 = FAT_CLST_LAST1(bs); fat_cluster_t clst_bad = FAT_CLST_BAD(bs);
No comments:
Post a Comment