Rev 3505 | Rev 3516 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3505 | Rev 3506 | ||
|---|---|---|---|
| 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 { |
| 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. */ |
| 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 | typedef uint16_t fat_cluster_t; |
124 | #define FAT_BS(b) ((fat_bs_t *)((b)->data)) |
| 119 | 125 | ||
| 120 | typedef enum { |
126 | typedef enum { |
| 121 | FAT_INVALID, |
127 | FAT_INVALID, |
| 122 | FAT_DIRECTORY, |
128 | FAT_DIRECTORY, |
| 123 | FAT_FILE |
129 | FAT_FILE |
| Line 189... | Line 195... | ||
| 189 | unsigned lnkcnt; |
195 | unsigned lnkcnt; |
| 190 | unsigned refcnt; |
196 | unsigned refcnt; |
| 191 | bool dirty; |
197 | bool dirty; |
| 192 | } fat_node_t; |
198 | } fat_node_t; |
| 193 | 199 | ||
| - | 200 | /* TODO move somewhere else */ |
|
| - | 201 | typedef struct block { |
|
| - | 202 | void *data; |
|
| - | 203 | size_t size; |
|
| - | 204 | bool dirty; |
|
| - | 205 | } block_t; |
|
| - | 206 | ||
| - | 207 | extern block_t *block_get(dev_handle_t, off_t, size_t); |
|
| - | 208 | extern void block_put(block_t *); |
|
| - | 209 | ||
| 194 | extern fs_reg_t fat_reg; |
210 | extern fs_reg_t fat_reg; |
| 195 | 211 | ||
| 196 | extern void fat_mounted(ipc_callid_t, ipc_call_t *); |
212 | extern void fat_mounted(ipc_callid_t, ipc_call_t *); |
| 197 | extern void fat_mount(ipc_callid_t, ipc_call_t *); |
213 | extern void fat_mount(ipc_callid_t, ipc_call_t *); |
| 198 | extern void fat_lookup(ipc_callid_t, ipc_call_t *); |
214 | extern void fat_lookup(ipc_callid_t, ipc_call_t *); |