Rev 3503 | Rev 3506 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3503 | Rev 3505 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | * @file fat_ops.c |
34 | * @file fat_ops.c |
35 | * @brief Implementation of VFS operations for the FAT file system server. |
35 | * @brief Implementation of VFS operations for the FAT file system server. |
36 | */ |
36 | */ |
37 | 37 | ||
38 | #include "fat.h" |
38 | #include "fat.h" |
- | 39 | #include "fat_dentry.h" |
|
- | 40 | #include "fat_fat.h" |
|
39 | #include "../../vfs/vfs.h" |
41 | #include "../../vfs/vfs.h" |
40 | #include <libfs.h> |
42 | #include <libfs.h> |
41 | #include <ipc/ipc.h> |
43 | #include <ipc/ipc.h> |
42 | #include <ipc/services.h> |
44 | #include <ipc/services.h> |
43 | #include <ipc/devmap.h> |
45 | #include <ipc/devmap.h> |
Line 59... | Line 61... | ||
59 | static futex_t ffn_futex = FUTEX_INITIALIZER; |
61 | static futex_t ffn_futex = FUTEX_INITIALIZER; |
60 | 62 | ||
61 | /** List of cached free FAT nodes. */ |
63 | /** List of cached free FAT nodes. */ |
62 | static LIST_INITIALIZE(ffn_head); |
64 | static LIST_INITIALIZE(ffn_head); |
63 | 65 | ||
64 | #define FAT_NAME_LEN 8 |
- | |
65 | #define FAT_EXT_LEN 3 |
- | |
66 | - | ||
67 | #define FAT_PAD ' ' |
- | |
68 | - | ||
69 | #define FAT_DENTRY_UNUSED 0x00 |
- | |
70 | #define FAT_DENTRY_E5_ESC 0x05 |
- | |
71 | #define FAT_DENTRY_DOT 0x2e |
- | |
72 | #define FAT_DENTRY_ERASED 0xe5 |
- | |
73 | - | ||
74 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
66 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
75 | 67 | ||
76 | static void dentry_name_canonify(fat_dentry_t *d, char *buf) |
- | |
77 | { |
- | |
78 | int i; |
- | |
79 | - | ||
80 | for (i = 0; i < FAT_NAME_LEN; i++) { |
- | |
81 | if (d->name[i] == FAT_PAD) |
- | |
82 | break; |
- | |
83 | if (d->name[i] == FAT_DENTRY_E5_ESC) |
- | |
84 | *buf++ = 0xe5; |
- | |
85 | else |
- | |
86 | *buf++ = d->name[i]; |
- | |
87 | } |
- | |
88 | if (d->ext[0] != FAT_PAD) |
- | |
89 | *buf++ = '.'; |
- | |
90 | for (i = 0; i < FAT_EXT_LEN; i++) { |
- | |
91 | if (d->ext[i] == FAT_PAD) { |
- | |
92 | *buf = '\0'; |
- | |
93 | return; |
- | |
94 | } |
- | |
95 | if (d->ext[i] == FAT_DENTRY_E5_ESC) |
- | |
96 | *buf++ = 0xe5; |
- | |
97 | else |
- | |
98 | *buf++ = d->ext[i]; |
- | |
99 | } |
- | |
100 | *buf = '\0'; |
- | |
101 | } |
- | |
102 | - | ||
103 | static int dev_phone = -1; /* FIXME */ |
68 | static int dev_phone = -1; /* FIXME */ |
104 | static void *dev_buffer = NULL; /* FIXME */ |
69 | static void *dev_buffer = NULL; /* FIXME */ |
105 | 70 | ||
106 | /* TODO move somewhere else */ |
71 | /* TODO move somewhere else */ |
107 | typedef struct { |
72 | typedef struct { |
Line 297... | Line 262... | ||
297 | block_put(bb); |
262 | block_put(bb); |
298 | 263 | ||
299 | return bps; |
264 | return bps; |
300 | } |
265 | } |
301 | 266 | ||
302 | typedef enum { |
- | |
303 | FAT_DENTRY_SKIP, |
- | |
304 | FAT_DENTRY_LAST, |
- | |
305 | FAT_DENTRY_VALID |
- | |
306 | } fat_dentry_clsf_t; |
- | |
307 | - | ||
308 | static fat_dentry_clsf_t fat_classify_dentry(fat_dentry_t *d) |
- | |
309 | { |
- | |
310 | if (d->attr & FAT_ATTR_VOLLABEL) { |
- | |
311 | /* volume label entry */ |
- | |
312 | return FAT_DENTRY_SKIP; |
- | |
313 | } |
- | |
314 | if (d->name[0] == FAT_DENTRY_ERASED) { |
- | |
315 | /* not-currently-used entry */ |
- | |
316 | return FAT_DENTRY_SKIP; |
- | |
317 | } |
- | |
318 | if (d->name[0] == FAT_DENTRY_UNUSED) { |
- | |
319 | /* never used entry */ |
- | |
320 | return FAT_DENTRY_LAST; |
- | |
321 | } |
- | |
322 | if (d->name[0] == FAT_DENTRY_DOT) { |
- | |
323 | /* |
- | |
324 | * Most likely '.' or '..'. |
- | |
325 | * It cannot occur in a regular file name. |
- | |
326 | */ |
- | |
327 | return FAT_DENTRY_SKIP; |
- | |
328 | } |
- | |
329 | return FAT_DENTRY_VALID; |
- | |
330 | } |
- | |
331 | - | ||
332 | static void fat_node_sync(fat_node_t *node) |
267 | static void fat_node_sync(fat_node_t *node) |
333 | { |
268 | { |
334 | /* TODO */ |
269 | /* TODO */ |
335 | } |
270 | } |
336 | 271 |