Subversion Repositories HelenOS

Rev

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

Rev 3403 Rev 3535
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>
Line 42... Line 43...
42
 
43
 
43
#ifndef dprintf
44
#ifndef dprintf
44
#define dprintf(...)    printf(__VA_ARGS__)
45
#define dprintf(...)    printf(__VA_ARGS__)
45
#endif
46
#endif
46
 
47
 
-
 
48
#define min(a, b)       ((a) < (b) ? (a) : (b))
-
 
49
 
-
 
50
#define BS_BLOCK        0
-
 
51
#define BS_SIZE         512
-
 
52
 
47
typedef struct {
53
typedef struct fat_bs {
48
    uint8_t     ji[3];      /**< Jump instruction. */
54
    uint8_t     ji[3];      /**< Jump instruction. */
49
    uint8_t     oem_name[8];
55
    uint8_t     oem_name[8];
50
    /* BIOS Parameter Block */
56
    /* BIOS Parameter Block */
51
    uint16_t    bps;        /**< Bytes per sector. */
57
    uint16_t    bps;        /**< Bytes per sector. */
52
    uint8_t     spc;        /**< Sectors per cluster. */
58
    uint8_t     spc;        /**< Sectors per cluster. */
Line 113... Line 119...
113
            uint16_t    signature;
119
            uint16_t    signature;
114
        } __attribute__ ((packed));
120
        } __attribute__ ((packed));
115
    };
121
    };
116
} __attribute__ ((packed)) fat_bs_t;
122
} __attribute__ ((packed)) fat_bs_t;
117
 
123
 
118
#define FAT_ATTR_RDONLY     (1 << 0)
-
 
119
#define FAT_ATTR_VOLLABEL   (1 << 3)
-
 
120
#define FAT_ATTR_SUBDIR     (1 << 4)
-
 
121
 
-
 
122
typedef struct {
-
 
123
    uint8_t     name[8];
-
 
124
    uint8_t     ext[3];
-
 
125
    uint8_t     attr;
-
 
126
    uint8_t     reserved;
-
 
127
    uint8_t     ctime_fine;
-
 
128
    uint16_t    ctime;
-
 
129
    uint16_t    cdate;
-
 
130
    uint16_t    adate;
-
 
131
    union {
-
 
132
        uint16_t    eaidx;      /* FAT12/FAT16 */
-
 
133
        uint16_t    firstc_hi;  /* FAT32 */
-
 
134
    };
-
 
135
    uint16_t    mtime;
-
 
136
    uint16_t    mdate;
-
 
137
    union {
-
 
138
        uint16_t    firstc;     /* FAT12/FAT16 */
-
 
139
        uint16_t    firstc_lo;  /* FAT32 */
-
 
140
    };
-
 
141
    uint32_t    size;
-
 
142
} __attribute__ ((packed)) fat_dentry_t;
-
 
143
 
-
 
144
typedef uint16_t fat_cluster_t;
-
 
145
 
-
 
146
typedef enum {
124
typedef enum {
147
    FAT_INVALID,
125
    FAT_INVALID,
148
    FAT_DIRECTORY,
126
    FAT_DIRECTORY,
149
    FAT_FILE
127
    FAT_FILE
150
} fat_node_type_t;
128
} fat_node_type_t;
Line 221... Line 199...
221
 
199
 
222
extern void fat_mounted(ipc_callid_t, ipc_call_t *);
200
extern void fat_mounted(ipc_callid_t, ipc_call_t *);
223
extern void fat_mount(ipc_callid_t, ipc_call_t *);
201
extern void fat_mount(ipc_callid_t, ipc_call_t *);
224
extern void fat_lookup(ipc_callid_t, ipc_call_t *);
202
extern void fat_lookup(ipc_callid_t, ipc_call_t *);
225
extern void fat_read(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 *);
226
 
205
 
227
extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned);
206
extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned);
228
extern fat_idx_t *fat_idx_get_by_index(dev_handle_t, fs_index_t);
207
extern fat_idx_t *fat_idx_get_by_index(dev_handle_t, fs_index_t);
229
 
208
 
230
extern int fat_idx_init(void);
209
extern int fat_idx_init(void);