Subversion Repositories HelenOS

Rev

Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3022 Rev 4055
Line 31... Line 31...
31
 */
31
 */
32
 
32
 
33
#ifndef FAT_FAT_H_
33
#ifndef FAT_FAT_H_
34
#define FAT_FAT_H_
34
#define FAT_FAT_H_
35
 
35
 
-
 
36
#include "fat_fat.h"
36
#include <ipc/ipc.h>
37
#include <ipc/ipc.h>
37
#include <libfs.h>
38
#include <libfs.h>
38
#include <atomic.h>
39
#include <atomic.h>
39
#include <sys/types.h>
40
#include <sys/types.h>
40
#include <bool.h>
41
#include <bool.h>
41
#include "../../vfs/vfs.h"
42
#include "../../vfs/vfs.h"
42
 
43
 
-
 
44
#ifndef dprintf
43
#define dprintf(...)    printf(__VA_ARGS__)
45
#define dprintf(...)    printf(__VA_ARGS__)
-
 
46
#endif
44
 
47
 
-
 
48
#define min(a, b)       ((a) < (b) ? (a) : (b))
-
 
49
 
-
 
50
#define BS_BLOCK        0
-
 
51
#define BS_SIZE         512
-
 
52
 
45
typedef struct {
53
typedef struct fat_bs {
46
    uint8_t     ji[3];      /**< Jump instruction. */
54
    uint8_t     ji[3];      /**< Jump instruction. */
47
    uint8_t     oem_name[8];
55
    uint8_t     oem_name[8];
48
    /* BIOS Parameter Block */
56
    /* BIOS Parameter Block */
49
    uint16_t    bps;        /**< Bytes per sector. */
57
    uint16_t    bps;        /**< Bytes per sector. */
50
    uint8_t     spc;        /**< Sectors per cluster. */
58
    uint8_t     spc;        /**< Sectors per cluster. */
Line 111... Line 119...
111
            uint16_t    signature;
119
            uint16_t    signature;
112
        } __attribute__ ((packed));
120
        } __attribute__ ((packed));
113
    };
121
    };
114
} __attribute__ ((packed)) fat_bs_t;
122
} __attribute__ ((packed)) fat_bs_t;
115
 
123
 
116
#define FAT_ATTR_RDONLY     (1 << 0)
-
 
117
#define FAT_ATTR_VOLLABEL   (1 << 3)
-
 
118
#define FAT_ATTR_SUBDIR     (1 << 4)
-
 
119
 
-
 
120
typedef struct {
-
 
121
    uint8_t     name[8];
-
 
122
    uint8_t     ext[3];
-
 
123
    uint8_t     attr;
-
 
124
    uint8_t     reserved;
-
 
125
    uint8_t     ctime_fine;
-
 
126
    uint16_t    ctime;
-
 
127
    uint16_t    cdate;
-
 
128
    uint16_t    adate;
-
 
129
    union {
-
 
130
        uint16_t    eaidx;      /* FAT12/FAT16 */
-
 
131
        uint16_t    firstc_hi;  /* FAT32 */
-
 
132
    };
-
 
133
    uint16_t    mtime;
-
 
134
    uint16_t    mdate;
-
 
135
    union {
-
 
136
        uint16_t    firstc;     /* FAT12/FAT16 */
-
 
137
        uint16_t    firstc_lo;  /* FAT32 */
-
 
138
    };
-
 
139
    uint32_t    size;
-
 
140
} __attribute__ ((packed)) fat_dentry_t;
-
 
141
 
-
 
142
typedef uint16_t fat_cluster_t;
-
 
143
 
-
 
144
typedef enum {
124
typedef enum {
145
    FAT_INVALID,
125
    FAT_INVALID,
146
    FAT_DIRECTORY,
126
    FAT_DIRECTORY,
147
    FAT_FILE
127
    FAT_FILE
148
} fat_node_type_t;
128
} fat_node_type_t;
Line 215... Line 195...
215
    bool            dirty;
195
    bool            dirty;
216
} fat_node_t;
196
} fat_node_t;
217
 
197
 
218
extern fs_reg_t fat_reg;
198
extern fs_reg_t fat_reg;
219
 
199
 
-
 
200
extern void fat_mounted(ipc_callid_t, ipc_call_t *);
-
 
201
extern void fat_mount(ipc_callid_t, ipc_call_t *);
220
extern void fat_lookup(ipc_callid_t, ipc_call_t *);
202
extern void fat_lookup(ipc_callid_t, ipc_call_t *);
-
 
203
extern void fat_read(ipc_callid_t, ipc_call_t *);
-
 
204
extern void fat_write(ipc_callid_t, ipc_call_t *);
-
 
205
extern void fat_truncate(ipc_callid_t, ipc_call_t *);
-
 
206
extern void fat_destroy(ipc_callid_t, ipc_call_t *);
221
 
207
 
-
 
208
extern fat_idx_t *fat_idx_get_new(dev_handle_t);
222
extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned);
209
extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned);
223
extern fat_idx_t *fat_idx_get_by_index(dev_handle_t, fs_index_t);
210
extern fat_idx_t *fat_idx_get_by_index(dev_handle_t, fs_index_t);
-
 
211
extern void fat_idx_destroy(fat_idx_t *);
-
 
212
extern void fat_idx_hashin(fat_idx_t *);
-
 
213
extern void fat_idx_hashout(fat_idx_t *);
-
 
214
 
-
 
215
extern int fat_idx_init(void);
-
 
216
extern void fat_idx_fini(void);
-
 
217
extern int fat_idx_init_by_dev_handle(dev_handle_t);
-
 
218
extern void fat_idx_fini_by_dev_handle(dev_handle_t);
224
 
219
 
225
#endif
220
#endif
226
 
221
 
227
/**
222
/**
228
 * @}
223
 * @}