vfs_delete() implement deleting files
This commit is contained in:
@ -44,11 +44,12 @@ void vfs_init_littlefs(VfsMountPoint *mp, bool format) {
|
||||
ERR("vfs", "Little FS mount failed %d\n", err);
|
||||
}
|
||||
|
||||
mp->cleanup = &littlefs_cleanup;
|
||||
mp->open = &littlefs_open;
|
||||
mp->stat = &littlefs_stat;
|
||||
mp->cleanup = &littlefs_cleanup;
|
||||
mp->open = &littlefs_open;
|
||||
mp->stat = &littlefs_stat;
|
||||
mp->fetchdirent = &littlefs_fetchdirent;
|
||||
mp->mkdir = &littlefs_mkdir;
|
||||
mp->mkdir = &littlefs_mkdir;
|
||||
mp->delete = &littlefs_delete;
|
||||
}
|
||||
|
||||
int32_t vfs_stat(char *mountpoint, const char *path, FsStat *stat) {
|
||||
@ -93,6 +94,20 @@ int32_t vfs_fetchdirent(char *mountpoint, const char *path, FsDirent *direntbuf,
|
||||
return mp->fetchdirent(mp, path, direntbuf, idx);
|
||||
}
|
||||
|
||||
int32_t vfs_delete(char *mountpoint, const char *path) {
|
||||
VfsMountPoint *mp = NULL;
|
||||
|
||||
spinlock_acquire(&VFS_TABLE.spinlock);
|
||||
HSHTB_GET(VFS_TABLE.mountpoints, label, mountpoint, mp);
|
||||
spinlock_release(&VFS_TABLE.spinlock);
|
||||
|
||||
if (mp == NULL) {
|
||||
return E_NOENTRY;
|
||||
}
|
||||
|
||||
return mp->delete(mp, path);
|
||||
}
|
||||
|
||||
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format) {
|
||||
VfsMountPoint *mp = NULL;
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@ typedef struct VfsMountPoint {
|
||||
int32_t (*stat)(struct VfsMountPoint *vmp, const char *path, FsStat *statbuf);
|
||||
int32_t (*fetchdirent)(struct VfsMountPoint *vmp, const char *path, FsDirent *direntbuf, size_t idx);
|
||||
int32_t (*mkdir)(struct VfsMountPoint *vmp, const char *path);
|
||||
int32_t (*delete)(struct VfsMountPoint *vmp, const char *path);
|
||||
|
||||
union {
|
||||
LittleFs littlefs;
|
||||
@ -75,5 +76,6 @@ VfsObj *vfs_open(char *mountpoint, const char *path, uint32_t flags);
|
||||
int32_t vfs_stat(char *mountpoint, const char *path, FsStat *stat);
|
||||
int32_t vfs_fetchdirent(char *mountpoint, const char *path, FsDirent *direntbuf, size_t idx);
|
||||
int32_t vfs_mkdir(char *mountpoint, const char *path);
|
||||
int32_t vfs_delete(char *mountpoint, const char *path);
|
||||
|
||||
#endif // VFS_VFS_H_
|
||||
|
||||
Reference in New Issue
Block a user