Commit f58ab92c authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

mount: Add lookup_mnt_id and lookup_mnt_sdev helpers

We will need to lookup mount points by mount id
and device for fanotify restore.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2d4a16c6
......@@ -18,4 +18,8 @@ int prepare_mnt_ns(int pid);
extern int pivot_root(const char *new_root, const char *put_old);
struct mount_info;
extern struct mount_info *lookup_mnt_id(unsigned int id);
extern struct mount_info *lookup_mnt_sdev(unsigned int s_dev);
#endif /* __CR_MOUNT_H__ */
......@@ -50,7 +50,7 @@ int collect_mount_info(void)
return 0;
}
static struct mount_info *mnt_find_by_id(struct mount_info *list, int id)
static struct mount_info *__lookup_mnt_id(struct mount_info *list, int id)
{
struct mount_info *m;
......@@ -61,6 +61,22 @@ static struct mount_info *mnt_find_by_id(struct mount_info *list, int id)
return NULL;
}
struct mount_info *lookup_mnt_id(unsigned int id)
{
return __lookup_mnt_id(mntinfo, id);
}
struct mount_info *lookup_mnt_sdev(unsigned int s_dev)
{
struct mount_info *m;
for (m = mntinfo; m != NULL; m = m->next)
if (m->s_dev == s_dev)
return m;
return NULL;
}
static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
{
struct mount_info *m, *root = NULL;
......@@ -74,7 +90,7 @@ static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
struct mount_info *p;
pr_debug("\t\tWorking on %d->%d\n", m->mnt_id, m->parent_mnt_id);
p = mnt_find_by_id(list, m->parent_mnt_id);
p = __lookup_mnt_id(list, m->parent_mnt_id);
if (!p) {
/* This should be / */
if (root == NULL && !strcmp(m->mountpoint, "/")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment