123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #include "mount.h"
- #include "VFS.h"
- #include <common/glib.h>
- #include <common/string.h>
- static struct List mnt_list_head;
- int mount_init()
- {
- list_init(&mnt_list_head);
- return 0;
- }
- int do_mount(struct vfs_dir_entry_t *old_dentry, struct vfs_dir_entry_t *new_dentry)
- {
- struct mountpoint *mp = (struct mountpoint *)kzalloc(sizeof(struct mountpoint), 0);
- list_init(&mp->mnt_list);
- mp->dentry = old_dentry;
- mp->parent_dentry = old_dentry->parent;
-
- strncpy(new_dentry->name, old_dentry->name, old_dentry->name_length);
- kdebug("new_dentry->name=%s, old_dentry->name=%s, old_dentry->name_length=%d", new_dentry->name, old_dentry->name, old_dentry->name_length);
- new_dentry->d_flags |= VFS_DF_MOUNTED;
- list_init(&new_dentry->child_node_list);
- list_init(&new_dentry->subdirs_list);
- new_dentry->parent = old_dentry->parent;
-
- list_replace(&old_dentry->child_node_list, &new_dentry->child_node_list);
-
- list_append(&mnt_list_head, &mp->mnt_list);
- return 0;
- }
- int do_umount(struct vfs_dir_entry_t *dentry)
- {
-
- return 0;
- }
- struct mountpoint *mount_find_mnt_list_by_parent(struct vfs_dir_entry_t *dentry)
- {
- struct List *list = &mnt_list_head;
- struct mountpoint *ret = NULL;
- if (list_empty(list))
- return NULL;
- while (list_next(list) != &mnt_list_head)
- {
- list = list_next(list);
- struct mountpoint *tmp = container_of(list, struct mountpoint, mnt_list);
- if (dentry == tmp->parent_dentry)
- return tmp;
- }
- return NULL;
- }
- int mount_release_mountpoint(struct mountpoint *mp)
- {
- list_del(&mp->mnt_list);
- return kfree(mp);
- }
|