Commit 3ae67d7b authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

mount: Move mount_info and ext_mount to mount.h

It's quite unclean while this structure lives
in proc_parse.h, which only have to fill this
structure on procfs read, but real handling
is inside mount.c. Move it as appropriate.

Same time ext_mount structure should be moved
into a header as well with sane @list name
used instead of @l.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 291e632e
#ifndef __CR_MOUNT_H__ #ifndef __CR_MOUNT_H__
#define __CR_MOUNT_H__ #define __CR_MOUNT_H__
#include <sys/types.h>
#include "asm/types.h"
#include "list.h"
struct proc_mountinfo; struct proc_mountinfo;
struct pstree_item; struct pstree_item;
struct mount_info; struct fstype;
struct cr_imgset;
struct ns_id; struct ns_id;
/*
* Structure to keep external mount points resolving info.
*
* On dump the key is the mountpoint as seen from the mount
* namespace, the val is some name that will be put into image
* instead of the mount point's root path.
*
* On restore the key is the name from the image (the one
* mentioned above) and the val is the path in criu's mount
* namespace that will become the mount point's root, i.e. --
* be bind mounted to the respective mountpoint.
*/
struct ext_mount {
struct list_head list;
char *key;
char *val;
};
struct mount_info {
int mnt_id;
int parent_mnt_id;
unsigned int s_dev;
char *root;
/*
* During dump mountpoint contains path with dot at the
* beginning. It allows to use openat, statat, etc without
* creating a temporary copy of the path.
*
* On restore mountpoint is prepended with so called ns
* root path -- it's a place in fs where the namespace
* mount tree is constructed. Check mnt_roots for details.
* The ns_mountpoint contains path w/o this prefix.
*/
char *mountpoint;
char *ns_mountpoint;
unsigned flags;
int master_id;
int shared_id;
struct fstype *fstype;
char *source;
char *options;
union {
bool mounted;
bool dumped;
};
bool need_plugin;
int is_file;
bool is_ns_root;
struct mount_info *next;
struct ns_id *nsid;
struct ext_mount *external;
bool internal_sharing;
/* tree linkage */
struct mount_info *parent;
struct mount_info *bind;
struct list_head children;
struct list_head siblings;
struct list_head mnt_bind; /* circular list of derivatives of one real mount */
struct list_head mnt_share; /* circular list of shared mounts */
struct list_head mnt_slave_list; /* list of slave mounts */
struct list_head mnt_slave; /* slave list entry */
struct mount_info *mnt_master; /* slave is on master->mnt_slave_list */
struct list_head postpone;
void *private; /* associated filesystem data */
};
extern struct mount_info *mntinfo; extern struct mount_info *mntinfo;
extern struct ns_desc mnt_ns_desc; extern struct ns_desc mnt_ns_desc;
extern struct mount_info *mnt_entry_alloc();
extern void mnt_entry_free(struct mount_info *mi);
extern int __mntns_get_root_fd(pid_t pid); extern int __mntns_get_root_fd(pid_t pid);
extern int mntns_get_root_fd(struct ns_id *ns); extern int mntns_get_root_fd(struct ns_id *ns);
extern int mntns_get_root_by_mnt_id(int mnt_id); extern int mntns_get_root_by_mnt_id(int mnt_id);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "image.h" #include "image.h"
#include "list.h" #include "list.h"
#include "cgroup.h" #include "cgroup.h"
#include "mount.h"
#include "protobuf/eventfd.pb-c.h" #include "protobuf/eventfd.pb-c.h"
#include "protobuf/eventpoll.pb-c.h" #include "protobuf/eventpoll.pb-c.h"
...@@ -90,7 +91,6 @@ struct proc_status_creds { ...@@ -90,7 +91,6 @@ struct proc_status_creds {
bool proc_status_creds_eq(struct proc_status_creds *o1, struct proc_status_creds *o2); bool proc_status_creds_eq(struct proc_status_creds *o1, struct proc_status_creds *o2);
struct mount_info;
struct fstype { struct fstype {
char *name; char *name;
int code; int code;
...@@ -99,63 +99,6 @@ struct fstype { ...@@ -99,63 +99,6 @@ struct fstype {
int (*parse)(struct mount_info *pm); int (*parse)(struct mount_info *pm);
}; };
struct ext_mount;
struct mount_info {
int mnt_id;
int parent_mnt_id;
unsigned int s_dev;
char *root;
/*
* During dump mountpoint contains path with dot at the
* beginning. It allows to use openat, statat, etc without
* creating a temporary copy of the path.
*
* On restore mountpoint is prepended with so called ns
* root path -- it's a place in fs where the namespace
* mount tree is constructed. Check mnt_roots for details.
* The ns_mountpoint contains path w/o this prefix.
*/
char *mountpoint;
char *ns_mountpoint;
unsigned flags;
int master_id;
int shared_id;
struct fstype *fstype;
char *source;
char *options;
union {
bool mounted;
bool dumped;
};
bool need_plugin;
int is_file;
bool is_ns_root;
struct mount_info *next;
struct ns_id *nsid;
struct ext_mount *external;
bool internal_sharing;
/* tree linkage */
struct mount_info *parent;
struct mount_info *bind;
struct list_head children;
struct list_head siblings;
struct list_head mnt_bind; /* circular list of derivatives of one real mount */
struct list_head mnt_share; /* circular list of shared mounts */
struct list_head mnt_slave_list; /* list of slave mounts */
struct list_head mnt_slave; /* slave list entry */
struct mount_info *mnt_master; /* slave is on master->mnt_slave_list */
struct list_head postpone;
void *private; /* associated filesystem data */
};
extern struct mount_info *mnt_entry_alloc();
extern void mnt_entry_free(struct mount_info *mi);
struct vm_area_list; struct vm_area_list;
extern bool add_skip_mount(const char *mountpoint); extern bool add_skip_mount(const char *mountpoint);
......
...@@ -32,25 +32,6 @@ ...@@ -32,25 +32,6 @@
#define AUTODETECTED_MOUNT "CRIU:AUTOGENERATED" #define AUTODETECTED_MOUNT "CRIU:AUTOGENERATED"
/*
* Structure to keep external mount points resolving info.
*
* On dump the key is the mountpoint as seen from the mount
* namespace, the val is some name that will be put into image
* instead of the mount point's root path.
*
* On restore the key is the name from the image (the one
* mentioned above) and the val is the path in criu's mount
* namespace that will become the mount point's root, i.e. --
* be bind mounted to the respective mountpoint.
*/
struct ext_mount {
char *key;
char *val;
struct list_head l;
};
int ext_mount_add(char *key, char *val) int ext_mount_add(char *key, char *val)
{ {
struct ext_mount *em; struct ext_mount *em;
...@@ -61,7 +42,7 @@ int ext_mount_add(char *key, char *val) ...@@ -61,7 +42,7 @@ int ext_mount_add(char *key, char *val)
em->key = key; em->key = key;
em->val = val; em->val = val;
list_add_tail(&em->l, &opts.ext_mounts); list_add_tail(&em->list, &opts.ext_mounts);
pr_info("Added %s:%s ext mount mapping\n", key, val); pr_info("Added %s:%s ext mount mapping\n", key, val);
return 0; return 0;
} }
...@@ -71,7 +52,7 @@ static struct ext_mount *ext_mount_lookup(char *key) ...@@ -71,7 +52,7 @@ static struct ext_mount *ext_mount_lookup(char *key)
{ {
struct ext_mount *em; struct ext_mount *em;
list_for_each_entry(em, &opts.ext_mounts, l) list_for_each_entry(em, &opts.ext_mounts, list)
if (!strcmp(em->key, key)) if (!strcmp(em->key, key))
return em; return em;
......
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