forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvfs.c
72 lines (64 loc) · 1.86 KB
/
vfs.c
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) 2018 OTA keys S.A.
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* This file demonstrates how C code can be mixed with Rust code in an
* application in an ad-hoc fashion.
*/
#include <vfs.h>
#include "fs/constfs.h"
#include <stdio.h>
#define HELLO_WORLD_CONTENT "Hello World!\n"
#define HELLO_RIOT_CONTENT "Hello RIOT!\n"
#define LARGE "1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n" \
"1234567890---------\n"
static constfs_file_t constfs_files[] = {
{
.path = "/hello-world",
.size = sizeof(HELLO_WORLD_CONTENT),
.data = (const uint8_t *)HELLO_WORLD_CONTENT,
},
{
.path = "/hello-riot",
.size = sizeof(HELLO_RIOT_CONTENT),
.data = (const uint8_t *)HELLO_RIOT_CONTENT,
},
{
.path = "/large",
.size = sizeof(LARGE),
.data = (const uint8_t *)LARGE,
}
};
static constfs_t constfs_desc = {
.nfiles = ARRAY_SIZE(constfs_files),
.files = constfs_files,
};
static vfs_mount_t const_mount = {
.fs = &constfs_file_system,
.mount_point = "/const",
.private_data = &constfs_desc,
};
void do_vfs_init(void) {
int res = vfs_mount(&const_mount);
if (res < 0) {
puts("Error while mounting constfs");
}
else {
puts("constfs mounted successfully");
}
}