summaryrefslogtreecommitdiff
path: root/fs/mount.h
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-16 23:46:30 +0200
committerMiguel <m.i@gmx.at>2018-09-16 23:46:30 +0200
commit06e6e427c76bdb88a7f72dd04411d95a4bda3270 (patch)
tree5c2bae3ca5292bf3db58c33ef3d7f4f3947593c3 /fs/mount.h
parent740ae2e69995df37c44fe61f57642ee642982ca2 (diff)
starting to create sysfs
Diffstat (limited to 'fs/mount.h')
-rw-r--r--fs/mount.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/fs/mount.h b/fs/mount.h
new file mode 100644
index 0000000..4e61c28
--- /dev/null
+++ b/fs/mount.h
@@ -0,0 +1,53 @@
+/**
+ * @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 <stdint.h>
+#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);
+
+#endif