/** * @file * Simple mount point manager * ========================== * * Add up to MAX_MOUNTS (as defined in kernel.h) mounts and use * mount_file_open() and mount_read_dir() to transparently * be dispatch the underlying commands to them based on the supplied paths. * * Mount directories should exist on root direcotry '/' */ #ifndef MOUNT_H #define MOUNT_H #include #include "interface/fs.h" // fs_dirent for read_dir #include "fd.h" // file descriptor returned by open /** the possible values for mount_struct.type */ enum MOUNT_TYPE{ MOUNT_TYPE_EXT2 = 1, MOUNT_TYPE_PIPES = 2, MOUNT_TYPE_SYS = 3 }; /** struct telling all we need about a single mountpoint */ typedef struct mount_struct { uint32_t type; // MOUNT_TYPE char path[256]; // where are we mounted (provide leading and trailing slash!) fd (*mount_file_open)(struct mount_struct*, char *path); int (*mount_read_dir) (struct mount_struct*, char *path, fs_dirent *dirs, uint32_t *pos); void *data; //opaque data }mount; /** dumps mount info to klog */ void mount_dump(); /** adds a new mountpoints */ void mount_add(mount mnt); /** dispatchers to according mount points */ fd mount_file_open(char *path); /** TODO: should use fd number instead of PATH on each call*/ int mount_read_dir (char *path, fs_dirent *dirs, uint32_t *pos); /** sysfs interface */ void mount_sysfs(ringbuffer *r, void (*f)(ringbuffer *r,char *fmt, ...)); #endif