Rev 3550 | Rev 3572 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3550 | Rev 3571 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Jakub Jermar |
2 | * Copyright (c) 2008 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup fs |
29 | /** @addtogroup fs |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | #ifndef FAT_FAT_FAT_H_ |
33 | #ifndef FAT_FAT_FAT_H_ |
34 | #define FAT_FAT_FAT_H_ |
34 | #define FAT_FAT_FAT_H_ |
35 | 35 | ||
36 | #include "../../vfs/vfs.h" |
36 | #include "../../vfs/vfs.h" |
37 | #include <stdint.h> |
37 | #include <stdint.h> |
- | 38 | #include <libblock.h> |
|
38 | 39 | ||
39 | #define FAT1 0 |
40 | #define FAT1 0 |
40 | 41 | ||
41 | #define FAT_CLST_RES0 0x0000 |
42 | #define FAT_CLST_RES0 0x0000 |
42 | #define FAT_CLST_RES1 0x0001 |
43 | #define FAT_CLST_RES1 0x0001 |
43 | #define FAT_CLST_FIRST 0x0002 |
44 | #define FAT_CLST_FIRST 0x0002 |
44 | #define FAT_CLST_BAD 0xfff7 |
45 | #define FAT_CLST_BAD 0xfff7 |
45 | #define FAT_CLST_LAST1 0xfff8 |
46 | #define FAT_CLST_LAST1 0xfff8 |
46 | #define FAT_CLST_LAST8 0xffff |
47 | #define FAT_CLST_LAST8 0xffff |
47 | 48 | ||
48 | /* internally used to mark root directory's parent */ |
49 | /* internally used to mark root directory's parent */ |
49 | #define FAT_CLST_ROOTPAR FAT_CLST_RES0 |
50 | #define FAT_CLST_ROOTPAR FAT_CLST_RES0 |
50 | /* internally used to mark root directory */ |
51 | /* internally used to mark root directory */ |
51 | #define FAT_CLST_ROOT FAT_CLST_RES1 |
52 | #define FAT_CLST_ROOT FAT_CLST_RES1 |
52 | 53 | ||
53 | /* forward declarations */ |
54 | /* forward declarations */ |
54 | struct block; |
55 | struct block; |
55 | struct fat_node; |
56 | struct fat_node; |
56 | struct fat_bs; |
57 | struct fat_bs; |
57 | 58 | ||
58 | typedef uint16_t fat_cluster_t; |
59 | typedef uint16_t fat_cluster_t; |
59 | 60 | ||
60 | #define fat_clusters_get(bs, dh, fc) \ |
61 | #define fat_clusters_get(bs, dh, fc) \ |
61 | fat_cluster_walk((bs), (dh), (fc), NULL, NULL, (uint16_t) -1) |
62 | fat_cluster_walk((bs), (dh), (fc), NULL, (uint16_t) -1) |
- | 63 | extern uint16_t fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t, |
|
- | 64 | fat_cluster_t *, uint16_t); |
|
- | 65 | ||
62 | #define fat_block_get(bs, np, off) \ |
66 | #define fat_block_get(bs, np, bn) \ |
63 | _fat_block_get((bs), (np)->idx->dev_handle, (np)->firstc, (off)) |
67 | _fat_block_get((bs), (np)->idx->dev_handle, (np)->firstc, (bn)) |
64 | 68 | ||
65 | extern struct block *_fat_block_get(struct fat_bs *, dev_handle_t, |
69 | extern struct block *_fat_block_get(struct fat_bs *, dev_handle_t, |
66 | fat_cluster_t, off_t); |
70 | fat_cluster_t, bn_t); |
67 | extern uint16_t fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t, |
- | |
68 | fat_cluster_t *, fat_cluster_t *, uint16_t); |
- | |
69 | 71 | ||
70 | extern void fat_append_clusters(struct fat_bs *, struct fat_node *, |
72 | extern void fat_append_clusters(struct fat_bs *, struct fat_node *, |
71 | fat_cluster_t); |
73 | fat_cluster_t); |
72 | extern int fat_alloc_clusters(struct fat_bs *, dev_handle_t, unsigned, |
74 | extern int fat_alloc_clusters(struct fat_bs *, dev_handle_t, unsigned, |
73 | fat_cluster_t *, fat_cluster_t *); |
75 | fat_cluster_t *, fat_cluster_t *); |
74 | extern void fat_alloc_shadow_clusters(struct fat_bs *, dev_handle_t, |
76 | extern void fat_alloc_shadow_clusters(struct fat_bs *, dev_handle_t, |
75 | fat_cluster_t *, unsigned); |
77 | fat_cluster_t *, unsigned); |
76 | extern void fat_mark_cluster(struct fat_bs *, dev_handle_t, unsigned, |
78 | extern void fat_mark_cluster(struct fat_bs *, dev_handle_t, unsigned, |
77 | fat_cluster_t, fat_cluster_t); |
79 | fat_cluster_t, fat_cluster_t); |
78 | extern void fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t, |
80 | extern void fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t, |
79 | off_t); |
81 | off_t); |
80 | 82 | ||
81 | #endif |
83 | #endif |
82 | 84 | ||
83 | /** |
85 | /** |
84 | * @} |
86 | * @} |
85 | */ |
87 | */ |
86 | 88 |