fs_init: change to_mount to block_device
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
d2c698ac0a
commit
07ea385f96
8 changed files with 73 additions and 2 deletions
52
fs/fat32/fat32.c
Normal file
52
fs/fat32/fat32.c
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <kernel/common.h>
|
||||
|
||||
#include <fs/vfs.h>
|
||||
|
||||
#include <lib/string.h>
|
||||
|
||||
#include "inode.h"
|
||||
|
||||
static struct fs_driver fat32_driver = {0};
|
||||
|
||||
static int alloc_inode(fs_t *fs, u64 mode, inode_t **out)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int free_inode(fs_t *fs, inode_t *inode)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int open_inode(fs_t *fs, u64 id, dirent_t *dirent, inode_t **out)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int fs_init(int flags, struct block_device *bdev, fs_t **out)
|
||||
{
|
||||
fs_t *fs = kalloc(sizeof(fs_t), ALLOC_KERN);
|
||||
if (!fs)
|
||||
return -ENOMEM;
|
||||
*out = fs;
|
||||
|
||||
fs->fs_ops.alloc_inode = alloc_inode;
|
||||
fs->fs_ops.free_inode = free_inode;
|
||||
fs->fs_ops.open_inode = open_inode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fs_deinit(fs_t *fs)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
void fat32_init()
|
||||
{
|
||||
strcpy(fat32_driver.name, "fat32");
|
||||
fat32_driver.init = fs_init;
|
||||
fat32_driver.deinit = fs_deinit;
|
||||
}
|
||||
DRIVER_ENTRY(fat32_init);
|
||||
2
fs/fat32/inode.c
Normal file
2
fs/fat32/inode.c
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
7
fs/fat32/inode.h
Normal file
7
fs/fat32/inode.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _INODE_H_
|
||||
#define _INODE_H_
|
||||
|
||||
|
||||
|
||||
#endif /* _INODE_H_ */
|
||||
|
|
@ -104,6 +104,7 @@ static ssize_t read_next(fs_t *fs, const char *file, rbtree_t *list, dirent_t **
|
|||
if (res == 0) {
|
||||
new_dent->fs = parent->fs;
|
||||
new_dent->parent = parent;
|
||||
dirent_inc_ref(parent);
|
||||
*out = new_dent;
|
||||
} else {
|
||||
inode_dec_ref(existing_ino);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ int dirent_populate_children(dirent_t *dir)
|
|||
goto cleanup;
|
||||
|
||||
insert->parent = dir;
|
||||
dirent_inc_ref(dir);
|
||||
|
||||
if (!list_insert(&inode->dirents, insert)) {
|
||||
dirent_free(insert);
|
||||
|
|
@ -211,6 +212,9 @@ dirent_t *dirent_dup(dirent_t *src)
|
|||
ret->fs = src->fs;
|
||||
ret->parent = src->parent;
|
||||
|
||||
if (ret->parent)
|
||||
dirent_inc_ref(ret->parent);
|
||||
|
||||
if (src->inode) {
|
||||
inode_inc_ref(src->inode);
|
||||
ret->inode = src->inode;
|
||||
|
|
@ -221,6 +225,9 @@ dirent_t *dirent_dup(dirent_t *src)
|
|||
|
||||
void dirent_free(dirent_t *dirent)
|
||||
{
|
||||
if (dirent->parent)
|
||||
dirent_dec_ref(dirent->parent);
|
||||
|
||||
kfree(dirent->name);
|
||||
slab_free(dirent_slab, dirent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ static ssize_t get_dents(inode_t *parent, dirent_t **dents)
|
|||
return n;
|
||||
}
|
||||
|
||||
static int init(int flags, dirent_t *to_mount, fs_t **out)
|
||||
static int init(int flags, struct block_device *to_mount, fs_t **out)
|
||||
{
|
||||
return ramfs_create(flags, out);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t
|
|||
|
||||
new_dirent->fs = fs;
|
||||
new_dirent->parent = parent;
|
||||
dirent_inc_ref(parent);
|
||||
*out = new_dirent;
|
||||
write_unlock(&ino->rwlock);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <kernel/spinlock.h>
|
||||
#include <kernel/slab.h>
|
||||
#include <kernel/block.h>
|
||||
#include <fs/inode.h>
|
||||
|
||||
#include <lib/rwlock.h>
|
||||
|
|
@ -55,7 +56,7 @@
|
|||
|
||||
struct fs_driver {
|
||||
char name[FILE_NAME_MAX_LEN + 1];
|
||||
int (*init)(int flags, dirent_t *to_mount, fs_t **out);
|
||||
int (*init)(int flags, struct block_device *to_mount, fs_t **out);
|
||||
int (*deinit)(fs_t *fs);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue