Skip to content

Commit c55eeb3

Browse files
A simple VFS (Virtual File System) has been added for OpenKernel.
1 parent c6c8c88 commit c55eeb3

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

VFS/vfs.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "vfs.c"
2+
#include <OpenKernel/FAT12/fat12.h>
3+
#include <OpenKernel/FAT16/fat16.h>
4+
#include <OpenKernel/FAT32/fat32.h>
5+
#include <OpenKernel/OFS/ofs.h>
6+
7+
void vfs_init(fs_t *fsname) {
8+
switch (fsname) {
9+
case OFS:
10+
default:
11+
ofs_init();
12+
break;
13+
case FAT12:
14+
fat12_init();
15+
break;
16+
case FAT16:
17+
fat16_init();
18+
break;
19+
case FAT32:
20+
fat32_init();
21+
break;
22+
}
23+
}
24+
25+
void vfs_list(fs_t *fsname) {
26+
switch (fsname) {
27+
case OFS:
28+
default:
29+
ofs_list_files();
30+
break;
31+
case FAT12:
32+
fat12_list_root();
33+
break;
34+
case FAT16:
35+
fat16_list_root();
36+
break;
37+
case FAT32:
38+
fat32_list_dir();
39+
break;
40+
}
41+
}

VFS/vfs.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#ifndef VFS_H
22
#define VFS_H
33

4+
enum filesystem_list {
5+
OFS,
6+
FAT12,
7+
FAT16,
8+
FAT32
9+
} fs_t;
410

11+
void vfs_init(fs_t *fsname);
12+
void vfs_list();
13+
14+
/* Coming soon...
15+
void vfs_create_file(const char *name, uint32_t size);
16+
void vfs_read_file(const char *name, uint8_t* buffer);
17+
void vfs_write_file(const char *name, const uint8_t* data, uint32_t size);
18+
void vfs_delete_file(const char *fname);
19+
*/
520

621
#endif

0 commit comments

Comments
 (0)