Rev 2404 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2404 | Rev 2435 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
33 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | */ |
34 | */ |
35 | - | ||
36 | 35 | ||
37 | /* Superblock support. */ |
36 | /** @addtogroup FileSystemImpl |
- | 37 | * @{ |
|
- | 38 | */ |
|
38 | 39 | ||
39 | /* Methods: |
40 | /** |
40 | * init_super: initializes the superblock structure for later use |
- | |
41 | * get_super: return pointer at the superblock |
41 | * @file utility.c |
42 | * read_super: read a superblock |
42 | * @brief Superblock support. |
43 | */ |
43 | */ |
44 | 44 | ||
45 | #include <string.h> |
45 | #include <string.h> |
46 | #include "fs.h" |
46 | #include "fs.h" |
47 | #include "block.h" |
47 | #include "block.h" |
Line 54... | Line 54... | ||
54 | 54 | ||
55 | static int v1(int magic, int *version, int *extend); |
55 | static int v1(int magic, int *version, int *extend); |
56 | static int v2(int magic ,int*version, int *extend); |
56 | static int v2(int magic ,int*version, int *extend); |
57 | static int get_native(int magic, int *version, int *extend); |
57 | static int get_native(int magic, int *version, int *extend); |
58 | 58 | ||
- | 59 | /** |
|
- | 60 | * File system versions |
|
- | 61 | */ |
|
59 | int (*versions[TOTAL_VERSIONS])(int , int*, int*) = { |
62 | int (*versions[TOTAL_VERSIONS])(int , int*, int*) = { |
60 | v1, /* 0 = V1 version */ |
63 | v1, /* 0 = V1 version */ |
61 | v2 /* 1 = V2 version */ |
64 | v2 /* 1 = V2 version */ |
62 | }; |
65 | }; |
63 | 66 | ||
- | 67 | /** |
|
- | 68 | * Initializes the superblock structure for later use |
|
- | 69 | */ |
|
64 | int init_super_block() |
70 | int init_super_block() |
65 | { |
71 | { |
66 | - | ||
67 | super_block = (super_block_t*)malloc(sizeof(super_block_t)); |
72 | super_block = (super_block_t*)malloc(sizeof(super_block_t)); |
68 | if (super_block != NULL) |
73 | if (super_block != NULL) |
69 | return TRUE; |
74 | return TRUE; |
70 | 75 | ||
71 | return FALSE; |
76 | return FALSE; |
72 | } |
77 | } |
73 | 78 | ||
- | 79 | /** |
|
- | 80 | * Return pointer at the superblock |
|
- | 81 | */ |
|
74 | super_block_t *get_super() |
82 | super_block_t *get_super() |
75 | { |
83 | { |
76 | return super_block; |
84 | return super_block; |
77 | } |
85 | } |
78 | 86 | ||
- | 87 | /** |
|
- | 88 | * Read a superblock |
|
- | 89 | */ |
|
79 | int read_super(register super_block_t *sp) |
90 | int read_super(register super_block_t *sp) |
80 | { |
91 | { |
81 | - | ||
82 | /* Read a superblock. */ |
92 | /* Read a superblock. */ |
83 | 93 | ||
84 | register block_t *bp; |
94 | register block_t *bp; |
85 | int magic, version, extend, native; |
95 | int magic, version, extend, native; |
86 | 96 | ||
Line 138... | Line 148... | ||
138 | } |
148 | } |
139 | 149 | ||
140 | return OK; |
150 | return OK; |
141 | } |
151 | } |
142 | 152 | ||
- | 153 | /** |
|
- | 154 | * Test the superblock against MINIX FS v1 |
|
- | 155 | */ |
|
143 | int v1(int magic, int* version, int *extend) |
156 | int v1(int magic, int* version, int *extend) |
144 | { |
157 | { |
145 | 158 | ||
146 | if (magic == SUPER_MAGIC || magic == conv2(BYTE_SWAP,SUPER_MAGIC)) { |
159 | if (magic == SUPER_MAGIC || magic == conv2(BYTE_SWAP,SUPER_MAGIC)) { |
147 | 160 | ||
Line 154... | Line 167... | ||
154 | } |
167 | } |
155 | 168 | ||
156 | return FALSE; |
169 | return FALSE; |
157 | } |
170 | } |
158 | 171 | ||
- | 172 | /** |
|
- | 173 | * Test the superblock against MINIX FS v2 |
|
- | 174 | */ |
|
159 | int v2(int magic, int *version, int *extend) |
175 | int v2(int magic, int *version, int *extend) |
160 | { |
176 | { |
161 | 177 | ||
162 | if (magic == SUPER_V2 || magic == conv2(BYTE_SWAP,SUPER_V2)) { |
178 | if (magic == SUPER_V2 || magic == conv2(BYTE_SWAP,SUPER_V2)) { |
163 | *version = V2; *extend = FALSE; |
179 | *version = V2; *extend = FALSE; |
Line 170... | Line 186... | ||
170 | } |
186 | } |
171 | 187 | ||
172 | return FALSE; |
188 | return FALSE; |
173 | } |
189 | } |
174 | 190 | ||
- | 191 | /** |
|
- | 192 | * Check the file system version and type |
|
- | 193 | */ |
|
175 | int get_native(int magic, int *version, int *extend) |
194 | int get_native(int magic, int *version, int *extend) |
176 | { |
- | |
177 | - | ||
178 | 195 | { |
|
179 | int i, result; |
196 | int i, result; |
180 | 197 | ||
181 | /* Get file system version and type */ |
198 | /* Get file system version and type */ |
182 | for (i = 0; i < TOTAL_VERSIONS; i++) { |
199 | for (i = 0; i < TOTAL_VERSIONS; i++) { |
183 | result = versions[i](magic, version, extend); |
200 | result = versions[i](magic, version, extend); |
Line 186... | Line 203... | ||
186 | } |
203 | } |
187 | } |
204 | } |
188 | 205 | ||
189 | return FS_EINVAL; |
206 | return FS_EINVAL; |
190 | } |
207 | } |
- | 208 | ||
- | 209 | /** |
|
- | 210 | * } |
|
- | 211 | */ |
|
- | 212 |