summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/tmpfs.c18
-rw-r--r--sys/inc/kern/mount.h6
-rw-r--r--sys/kern/vfs_init.c11
-rw-r--r--sys/kern/vfs_mount.c8
4 files changed, 31 insertions, 12 deletions
diff --git a/sys/fs/tmpfs.c b/sys/fs/tmpfs.c
index cb18b6b..5ac69b1 100644
--- a/sys/fs/tmpfs.c
+++ b/sys/fs/tmpfs.c
@@ -34,7 +34,20 @@
* Mount a filesystem
*/
static int
-tmpfs_mount(struct fs_info *fip, void *data)
+tmpfs_mount(struct fs_info *fip, struct mount *mp)
+{
+ int error;
+
+ error = vnode_init(&mp->vp, VDIR);
+ if (error < 0) {
+ return error;
+ }
+
+ return 0;
+}
+
+static int
+tmpfs_init(struct fs_info *fip)
{
struct mount_args mountargs;
int error;
@@ -50,5 +63,6 @@ tmpfs_mount(struct fs_info *fip, void *data)
}
struct vfsops g_tmpfs_ops = {
- .mount = tmpfs_mount
+ .mount = tmpfs_mount,
+ .init = tmpfs_init
};
diff --git a/sys/inc/kern/mount.h b/sys/inc/kern/mount.h
index 1c3dde6..747514c 100644
--- a/sys/inc/kern/mount.h
+++ b/sys/inc/kern/mount.h
@@ -37,6 +37,7 @@
/* Filesystem names */
#define MOUNT_TMPFS "tmpfs"
+struct mount;
struct fs_info;
/*
@@ -55,7 +56,8 @@ struct mount_args {
* on filesystem objects
*/
struct vfsops {
- int(*mount)(struct fs_info *fip, void *data);
+ int(*mount)(struct fs_info *fip, struct mount *mpoint);
+ int(*init)(struct fs_info *fip);
};
/*
@@ -63,12 +65,10 @@ struct vfsops {
*
* @name: Name of filesystem
* @vfsops: Represents operations that can be performed
- * @is_mounted: Set if filesystem is mounted
*/
struct fs_info {
char *name;
struct vfsops *vfsops;
- uint8_t is_mounted : 1;
};
/*
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index 6372f3d..08be17a 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -87,18 +87,17 @@ vfs_init(void)
continue;
}
- /* Mount if we can */
- if (ops->mount != NULL) {
- error = ops->mount(fip, NULL);
+ /* Initialize the filesystem */
+ if (ops->init != NULL) {
+ error = ops->init(fip);
}
if (error != 0) {
- dtrace("failed to mount %s\n", fip->name);
+ dtrace("failed to init %s\n", fip->name);
continue;
}
- dtrace("mounted %s\n", fip->name);
- fip->is_mounted = 1;
+ dtrace("initialized %s\n", fip->name);
++mount_count;
}
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 51a464a..39f98d2 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -74,6 +74,7 @@ int
mount(struct mount_args *margs)
{
struct fs_info *fip;
+ struct vfsops *vfsops;
struct mount *mp;
int error;
@@ -95,13 +96,18 @@ mount(struct mount_args *margs)
return error;
}
+ vfsops = fip->vfsops;
+ if (vfsops->mount == NULL) {
+ return -ENOTSUP;
+ }
+
mp = kalloc(sizeof(*mp));
if (mp == NULL) {
return -ENOMEM;
}
mp->fip = fip;
- error = vnode_init(&mp->vp, VDIR);
+ error = vfsops->mount(fip, mp);
if (error < 0) {
kfree(mp);
return error;