Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_fat.h

    r7ece4247 r991f645  
    11/*
    22 * Copyright (c) 2008 Jakub Jermar
    3  * Copyright (c) 2011 Oleg Romanenko
    43 * All rights reserved.
    54 *
     
    3029/** @addtogroup fs
    3130 * @{
    32  */
     31 */ 
    3332
    3433#ifndef FAT_FAT_FAT_H_
     
    4140#define FAT1            0
    4241
    43 #define FAT_CLST_RES0     0
    44 #define FAT_CLST_RES1     1
    45 #define FAT_CLST_FIRST    2
    46 
    47 #define FAT32_CLST_BAD    0x0ffffff7
    48 #define FAT32_CLST_LAST1  0x0ffffff8
    49 #define FAT32_CLST_LAST8  0x0fffffff
    50 
    51 #define FAT12_MASK        0x0fff
    52 #define FAT16_MASK        0xffff
    53 #define FAT32_MASK        0x0fffffff
    54 
    55 #define FAT12_CLST_MAX    4085
    56 #define FAT16_CLST_MAX    65525
    57 
    58 /* Size in bytes for cluster value of FAT */
    59 #define FAT12_CLST_SIZE   2
    60 #define FAT16_CLST_SIZE   2
    61 #define FAT32_CLST_SIZE   4
     42#define FAT_CLST_RES0   0x0000
     43#define FAT_CLST_RES1   0x0001
     44#define FAT_CLST_FIRST  0x0002
     45#define FAT_CLST_BAD    0xfff7
     46#define FAT_CLST_LAST1  0xfff8
     47#define FAT_CLST_LAST8  0xffff
    6248
    6349/* internally used to mark root directory's parent */
     
    6652#define FAT_CLST_ROOT           FAT_CLST_RES1
    6753
    68 /*
    69  * Convenience macros for computing some frequently used values from the
    70  * primitive boot sector members.
    71  */
    72 #define RDS(bs)   ((sizeof(fat_dentry_t) * RDE((bs))) / BPS((bs))) + \
    73                    (((sizeof(fat_dentry_t) * RDE((bs))) % BPS((bs))) != 0)
    74 #define SSA(bs)   (RSCNT((bs)) + FATCNT((bs)) * SF((bs)) + RDS(bs))
    75 #define DS(bs)    (TS(bs) - SSA(bs))
    76 #define CC(bs)    (DS(bs) / SPC(bs))
    77 
    78 #define CLBN2PBN(bs, cl, bn) \
    79         (SSA((bs)) + ((cl) - FAT_CLST_FIRST) * SPC((bs)) + (bn) % SPC((bs)))
    80 
    81 #define FAT_IS_FAT12(bs)        (CC(bs) < FAT12_CLST_MAX)
    82 #define FAT_IS_FAT16(bs) \
    83     ((CC(bs) >= FAT12_CLST_MAX) && (CC(bs) < FAT16_CLST_MAX))
    84 #define FAT_IS_FAT32(bs)        (CC(bs) >= FAT16_CLST_MAX)
    85 
    86 #define FAT_CLST_SIZE(bs) \
    87     (FAT_IS_FAT32(bs) ? FAT32_CLST_SIZE : FAT16_CLST_SIZE)
    88 
    89 #define FAT_MASK(bs) \
    90     (FAT_IS_FAT12(bs) ? FAT12_MASK : \
    91     (FAT_IS_FAT32(bs) ? FAT32_MASK : FAT16_MASK))
    92 
    93 #define FAT_CLST_LAST1(bs)      (FAT32_CLST_LAST1 & FAT_MASK((bs)))
    94 #define FAT_CLST_LAST8(bs)      (FAT32_CLST_LAST8 & FAT_MASK((bs)))
    95 #define FAT_CLST_BAD(bs)        (FAT32_CLST_BAD & FAT_MASK((bs)))
    96 
    97 #define FAT_ROOT_CLST(bs) \
    98     (FAT_IS_FAT32(bs) ? uint32_t_le2host(bs->fat32.root_cluster) : \
    99     FAT_CLST_ROOT)
    100 
    10154/* forward declarations */
    10255struct block;
     
    10457struct fat_bs;
    10558
    106 typedef uint32_t fat_cluster_t;
     59typedef uint16_t fat_cluster_t;
    10760
    108 #define fat_clusters_get(numc, bs, sid, fc) \
    109     fat_cluster_walk((bs), (sid), (fc), NULL, (numc), (uint32_t) -1)
    110 extern int fat_cluster_walk(struct fat_bs *, service_id_t, fat_cluster_t,
    111     fat_cluster_t *, uint32_t *, uint32_t);
     61#define fat_clusters_get(numc, bs, dh, fc) \
     62    fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1)
     63extern int fat_cluster_walk(struct fat_bs *, devmap_handle_t, fat_cluster_t,
     64    fat_cluster_t *, uint16_t *, uint16_t);
    11265
    11366extern int fat_block_get(block_t **, struct fat_bs *, struct fat_node *,
    11467    aoff64_t, int);
    115 extern int _fat_block_get(block_t **, struct fat_bs *, service_id_t,
     68extern int _fat_block_get(block_t **, struct fat_bs *, devmap_handle_t,
    11669    fat_cluster_t, fat_cluster_t *, aoff64_t, int);
    11770
     
    12073extern int fat_chop_clusters(struct fat_bs *, struct fat_node *,
    12174    fat_cluster_t);
    122 extern int fat_alloc_clusters(struct fat_bs *, service_id_t, unsigned,
     75extern int fat_alloc_clusters(struct fat_bs *, devmap_handle_t, unsigned,
    12376    fat_cluster_t *, fat_cluster_t *);
    124 extern int fat_free_clusters(struct fat_bs *, service_id_t, fat_cluster_t);
    125 extern int fat_alloc_shadow_clusters(struct fat_bs *, service_id_t,
     77extern int fat_free_clusters(struct fat_bs *, devmap_handle_t, fat_cluster_t);
     78extern int fat_alloc_shadow_clusters(struct fat_bs *, devmap_handle_t,
    12679    fat_cluster_t *, unsigned);
    127 extern int fat_get_cluster(struct fat_bs *, service_id_t, unsigned,
     80extern int fat_get_cluster(struct fat_bs *, devmap_handle_t, unsigned,
    12881    fat_cluster_t, fat_cluster_t *);
    129 extern int fat_set_cluster(struct fat_bs *, service_id_t, unsigned,
     82extern int fat_set_cluster(struct fat_bs *, devmap_handle_t, unsigned,
    13083    fat_cluster_t, fat_cluster_t);
    13184extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
    13285    aoff64_t);
    133 extern int fat_zero_cluster(struct fat_bs *, service_id_t, fat_cluster_t);
    134 extern int fat_sanity_check(struct fat_bs *, service_id_t);
     86extern int fat_zero_cluster(struct fat_bs *, devmap_handle_t, fat_cluster_t);
     87extern int fat_sanity_check(struct fat_bs *, devmap_handle_t);
    13588
    13689#endif
Note: See TracChangeset for help on using the changeset viewer.