Skip to content

Commit

Permalink
Merge branch 'main1'
Browse files Browse the repository at this point in the history
  • Loading branch information
min0911Y committed Nov 1, 2024
2 parents 1b08f9c + d037d30 commit 6109504
Show file tree
Hide file tree
Showing 8 changed files with 606 additions and 651 deletions.
12 changes: 7 additions & 5 deletions include/fs/vfs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include <data-structure.h>
#include <libc-base.h>

// * 所有时间请使用 GMT 时间 *

// 读写时请 padding 到 PAGE_SIZE 的整数倍
Expand Down Expand Up @@ -90,11 +89,14 @@ int vfs_regist(cstr name, vfs_callback_t callback);

void tmpfs_regist();
void fatfs_regist();
void iso9660_regist();

vfs_node_t vfs_open(cstr str);
int vfs_mkdir(cstr name);

int vfs_read(vfs_node_t file, void *addr, size_t offset, size_t size);
int vfs_mkfile(cstr name);
int vfs_write(vfs_node_t file, void *addr, size_t offset, size_t size);
int vfs_unmount(cstr path);
int vfs_read(vfs_node_t file, void *addr, size_t offset, size_t size);
int vfs_mkfile(cstr name);
int vfs_write(vfs_node_t file, void *addr, size_t offset, size_t size);
int vfs_unmount(cstr path);
int vfs_close(vfs_node_t node);
void vfs_update(vfs_node_t node);
7 changes: 5 additions & 2 deletions src/fs/fat.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ int fatfs_mount(cstr src, vfs_node_t node) {
sprintf(path, "%d:", drive);
FRESULT r = f_mount(&volume[drive], path, 1);
if (r != FR_OK) {
vfs_close(drive_number_mapping[drive]);
drive_number_mapping[drive] = null;
free(path);
return -1;
}
Expand All @@ -151,8 +153,9 @@ int fatfs_mount(cstr src, vfs_node_t node) {
}

void fatfs_unmount(void *root) {
file_t f = root;
int number = f->path[0] - '0';
file_t f = root;
int number = f->path[0] - '0';
drive_number_mapping[number] = null;
f_closedir(f->handle);
f_unmount(f->path);
free(f->path);
Expand Down
Loading

0 comments on commit 6109504

Please sign in to comment.