hos/kernel/fs/vfs.h

69 lines
1.7 KiB
C

// vfs.h
// Author: Josh Holtrop
// Date: 08/22/04
// Modified: 12/21/04
#ifndef __HOS_VFS_H__
#define __HOS_VFS_H__ __HOS_VFS_H__
#include "hos_defines.h"
#include "fs/devices.h"
#define FS_EXT2 1
#define VFS_MAX_FS 10
/* Structure to hold information about a mount point */
typedef struct
{
int refs;
void *super;
major_t major;
minor_t minor;
} vfs_mount_t;
/* Every filesystem must provide pointers to its respective functions in a structure like this */
typedef struct
{
void *(*mount_super)(major_t major, minor_t minor);
int (*mkfs)(major_t major, minor_t minor);
} vfs_fs_t;
/* This structure represents a node of the "VFS Mount Tree" */
struct vfs_node_s
{
char chr; // the character we are at
vfs_mount_t *mount; // is there a mount at this character?
struct vfs_node_s *up; // the parent
struct vfs_node_s *next; // the next sibling
struct vfs_node_s *down; // subtree for submounts
};
typedef struct vfs_node_s vfs_node_t;
/* This structure is generated when a path is matched. For example, if /dev is mounted on
device (4,2) and '/dev/yoda' is looked up, the structure returned would be
{4, 2, 4} and then the lookup could continue on device (4,2) with 4 characters stripped
off the front of the initial path (ex '/yoda') */
typedef struct
{
vfs_mount_t *mount;
int length;
} vfs_mount_match_t;
int vfs_init();
int vfs_mount(major_t maj, minor_t min, int fsType, char *mountPoint);
int vfs_register_fs(int fsn, vfs_fs_t *fs);
int vfs_add_mount(vfs_mount_t *mnt, char *mountPoint);
vfs_mount_t *vfs_find_mount(char *mountPoint);
vfs_mount_match_t vfs_get_rel_path(char *path);
int vfs_umount(char *mountPoint);
int vfs_retire_node(vfs_node_t *node);
void vfs_dump_tree();
void vfs_dump_node(vfs_node_t *node, int level);
#endif