blob: f6e9e2fd81a7c90e136fb53ec7542ed541c6a8f8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* Copyright (c) 2021, Marvin Borner <melvix@marvinborner.de>
* SPDX-License-Identifier: MIT
*/
#ifndef MARFS_SPEC
#define MARFS_SPEC
#include <def.h>
#define MARFS_POINT(head, tail) ((struct marfs_pointer){ (head), (tail) })
#define MARFS_MAGIC "MarFS"
#define MARFS_SPEC_VERSION 1
#define MARFS_END 0xffffffff
#define MARFS_NAME_LENGTH 32
#define MARFS_ENTRY_SIZE 1024
#define MARFS_EMPTY_ENTRY 0
#define MARFS_DIR_ENTRY 1
#define MARFS_FILE_ENTRY 2
#define MARFS_DIR_ENTRY_COUNT (MARFS_ENTRY_SIZE / sizeof(struct marfs_dir_entry_data))
struct marfs_pointer {
u32 head, tail;
} PACKED;
struct marfs_header {
char magic[6];
u32 version;
u32 entry_size;
u32 entry_count;
struct marfs_pointer main;
u8 padding[MARFS_ENTRY_SIZE - 26];
} PACKED;
struct marfs_entry_header {
u32 type;
u32 id;
u32 prev, next; // MARFS_END if end
} PACKED;
struct marfs_dir_entry_data {
char name[MARFS_NAME_LENGTH + 1];
u32 length;
struct marfs_pointer pointer;
} PACKED;
struct marfs_dir_entry_info {
struct marfs_entry_header header;
u32 count;
} PACKED;
struct marfs_dir_entry {
struct marfs_dir_entry_info info;
struct marfs_dir_entry_data entries[MARFS_DIR_ENTRY_COUNT];
u8 padding[MARFS_ENTRY_SIZE - sizeof(struct marfs_dir_entry_info) -
(MARFS_DIR_ENTRY_COUNT * sizeof(struct marfs_dir_entry_data))];
} PACKED;
struct marfs_file_entry_info {
struct marfs_entry_header header;
u32 size;
} PACKED;
struct marfs_file_entry {
struct marfs_file_entry_info info;
u8 data[MARFS_ENTRY_SIZE - sizeof(struct marfs_file_entry_info)];
} PACKED;
#endif
|