99 lines
3.7 KiB
C
99 lines
3.7 KiB
C
#ifndef _KERNEL_FS_VFS_H
|
|
#define _KERNEL_FS_VFS_H
|
|
|
|
#include <desc.h>
|
|
#include <device/device.h>
|
|
#include <dir_entry.h>
|
|
#include <fs_types.h>
|
|
#include <libk/hash.h>
|
|
#include <libk/list.h>
|
|
#include <libk/rbtree.h>
|
|
#include <libk/std.h>
|
|
#include <path_defs.h>
|
|
#include <proc/proc.h>
|
|
#include <proc/procgroup.h>
|
|
#include <proc/reschedule.h>
|
|
#include <proc/suspension_q.h>
|
|
#include <sync/spin_lock.h>
|
|
#include <volume_info.h>
|
|
|
|
struct vfs_volume;
|
|
|
|
struct vfs_volume {
|
|
char key[VOLUME_MAX];
|
|
struct hash_node_link volume_table_link;
|
|
int fs_type;
|
|
struct {
|
|
int (*mount)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
bool format);
|
|
|
|
int (*unmount)(struct vfs_volume* volume);
|
|
|
|
int (*format)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx);
|
|
|
|
int (*describe)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path, struct desc* desc);
|
|
|
|
int (*read_file)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path, uint8_t* buffer, size_t off, size_t size);
|
|
|
|
int (*write_file)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path, uint8_t* buffer, size_t off, size_t size, uint32_t flags);
|
|
|
|
int (*read_dir_entry)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path, struct dir_entry* entry, size_t entry_num);
|
|
|
|
int (*create_file)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path);
|
|
|
|
int (*create_dir)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path);
|
|
|
|
int (*remove)(struct vfs_volume* volume, struct proc* proc, struct reschedule_ctx* rctx,
|
|
const char* path);
|
|
} driver_ops;
|
|
struct device* back_device;
|
|
void* udata
|
|
};
|
|
|
|
struct vfs_volume_table {
|
|
struct hash_node_link* volume_buckets[1024];
|
|
};
|
|
|
|
int vfs_create_volume(struct proc* proc, struct reschedule_ctx* rctx, const char* key, int fs_type,
|
|
struct device* back_device, bool format);
|
|
|
|
int vfs_volume_delete(const char* key);
|
|
|
|
int vfs_format(struct proc* proc, struct reschedule_ctx* rctx, const char* volume_name);
|
|
|
|
int vfs_read_file(struct proc* proc, struct reschedule_ctx* rctx, const char* volume,
|
|
const char* path, uint8_t* buffer, size_t off, size_t size);
|
|
|
|
int vfs_write_file(struct proc* proc, struct reschedule_ctx* rctx, const char* volume,
|
|
const char* path, uint8_t* buffer, size_t off, size_t size, uint32_t flags);
|
|
|
|
int vfs_describe(struct proc* proc, struct reschedule_ctx* rctx, const char* volume,
|
|
const char* path, struct desc* desc);
|
|
|
|
int vfs_read_dir_entry(struct proc* proc, struct reschedule_ctx* rctx, const char* volume,
|
|
const char* path, struct dir_entry* entry, size_t entry_num);
|
|
|
|
int vfs_create_file(struct proc* proc, struct reschedule_ctx* rctx, const char* volume_name,
|
|
const char* path);
|
|
|
|
int vfs_create_dir(struct proc* proc, struct reschedule_ctx* rctx, const char* volume_name,
|
|
const char* path);
|
|
|
|
int vfs_remove(struct proc* proc, struct reschedule_ctx* rctx, const char* volume_name,
|
|
const char* path);
|
|
|
|
void vfs_init(void);
|
|
|
|
void vfs_translate(size_t fs_block, size_t fs_block_count, size_t fs_block_size,
|
|
size_t device_sector_size, size_t* out_phys_sector, size_t* out_sector_count);
|
|
|
|
size_t volume_populate_volume_infos(struct volume_info* infos, size_t count);
|
|
|
|
#endif // _KERNEL_FS_VFS_H
|