5
* @author Aleksey Zhmulin
13
#include <lib/libds/dlist.h>
16
void vfs_mount_point_get_first_bind(const struct inode *mount_point,
17
struct inode *lookup) {
18
memcpy(lookup, mount_point, sizeof(struct inode));
20
while (vfs_mount_point_get_prev_bind(lookup, lookup)) {}
23
void vfs_mount_point_get_first(const struct inode *mount_point,
24
struct inode *lookup) {
25
memcpy(lookup, mount_point, sizeof(struct inode));
27
while (vfs_mount_point_get_prev(lookup, lookup)) {}
30
void vfs_mount_point_get_last(const struct inode *mount_point,
31
struct inode *lookup) {
32
memcpy(lookup, mount_point, sizeof(struct inode));
34
while (vfs_mount_point_get_next(lookup, lookup)) {}
37
bool vfs_mount_point_get_next(const struct inode *mount_point,
38
struct inode *lookup) {
39
struct super_block *sb;
41
assert(!vfs_inode_is_bad(mount_point));
43
dlist_foreach_entry(sb, &mount_point->sb->mount_list, list_item) {
44
if (mount_point->ino == sb->mount_point.ino) {
45
lookup->ino = VFS_MPT_INO;
54
bool vfs_mount_point_get_prev(const struct inode *mount_point,
55
struct inode *lookup) {
56
assert(!vfs_inode_is_bad(mount_point));
58
if (!vfs_inode_is_mount_point(mount_point)
59
|| vfs_inode_is_root(mount_point)) {
63
memcpy(lookup, &mount_point->sb->mount_point, sizeof(struct inode));
68
bool vfs_mount_point_get_prev_bind(const struct inode *mount_point,
69
struct inode *lookup) {
70
assert(!vfs_inode_is_bad(mount_point));
72
if (!mount_point->sb->bind_mount) {
76
return vfs_mount_point_get_prev(mount_point, lookup);
79
void vfs_mount_point_add_next(const struct inode *mount_point,
80
struct super_block *sb) {
83
vfs_mount_point_get_last(mount_point, &mpt);
85
dlist_add_next(&sb->list_item, &mpt.sb->mount_list);
86
memcpy(&sb->mount_point, &mpt, sizeof(struct inode));