mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
mount: Helper for auto-ext entry creation
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
46
criu/mount.c
46
criu/mount.c
@@ -35,6 +35,11 @@
|
|||||||
#include "images/mnt.pb-c.h"
|
#include "images/mnt.pb-c.h"
|
||||||
#include "images/binfmt-misc.pb-c.h"
|
#include "images/binfmt-misc.pb-c.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put a : in here since those are invalid on
|
||||||
|
* the cli, so we know it's autogenerated in
|
||||||
|
* debugging.
|
||||||
|
*/
|
||||||
#define AUTODETECTED_MOUNT "CRIU:AUTOGENERATED"
|
#define AUTODETECTED_MOUNT "CRIU:AUTOGENERATED"
|
||||||
#define MS_PROPAGATE (MS_SHARED | MS_PRIVATE | MS_UNBINDABLE | MS_SLAVE)
|
#define MS_PROPAGATE (MS_SHARED | MS_PRIVATE | MS_UNBINDABLE | MS_SLAVE)
|
||||||
|
|
||||||
@@ -79,6 +84,19 @@ static struct ext_mount *ext_mount_lookup(char *key)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct ext_mount *ext_mount_make_auto(char *key, char *val)
|
||||||
|
{
|
||||||
|
struct ext_mount *em;
|
||||||
|
|
||||||
|
em = xmalloc(sizeof(*em));
|
||||||
|
if (em) {
|
||||||
|
em->key = key;
|
||||||
|
em->val = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return em;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Single linked list of mount points get from proc/images
|
* Single linked list of mount points get from proc/images
|
||||||
*/
|
*/
|
||||||
@@ -817,7 +835,6 @@ static int resolve_external_mounts(struct mount_info *info)
|
|||||||
for (m = info; m; m = m->next) {
|
for (m = info; m; m = m->next) {
|
||||||
int ret;
|
int ret;
|
||||||
char *p, *cut_root;
|
char *p, *cut_root;
|
||||||
struct ext_mount *em;
|
|
||||||
struct mount_info *match;
|
struct mount_info *match;
|
||||||
|
|
||||||
if (m->parent == NULL || m->is_ns_root)
|
if (m->parent == NULL || m->is_ns_root)
|
||||||
@@ -861,17 +878,16 @@ static int resolve_external_mounts(struct mount_info *info)
|
|||||||
if (!p)
|
if (!p)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
em = xmalloc(sizeof(struct ext_mount));
|
m->external = ext_mount_make_auto(p, AUTODETECTED_MOUNT);
|
||||||
if (!em) {
|
if (!m->external) {
|
||||||
free(p);
|
free(p);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
em->val = AUTODETECTED_MOUNT;
|
/*
|
||||||
em->key = p;
|
* Put the guessed name in source. It will be picked up
|
||||||
|
* as auto-root in get_mp_root() on restore.
|
||||||
m->external = em;
|
*/
|
||||||
|
|
||||||
xfree(m->source);
|
xfree(m->source);
|
||||||
m->source = p;
|
m->source = p;
|
||||||
|
|
||||||
@@ -3086,18 +3102,14 @@ static int get_mp_root(MntEntry *me, struct mount_info *mi)
|
|||||||
* Make up an external mount entry for this
|
* Make up an external mount entry for this
|
||||||
* mount point, since we couldn't find a user
|
* mount point, since we couldn't find a user
|
||||||
* supplied one.
|
* supplied one.
|
||||||
|
*
|
||||||
|
* The 'val' was put into mi->source during
|
||||||
|
* dump by resolve_external_mounts().
|
||||||
*/
|
*/
|
||||||
em = xmalloc(sizeof(struct ext_mount));
|
|
||||||
|
em = ext_mount_make_auto(AUTODETECTED_MOUNT, mi->source);
|
||||||
if (!em)
|
if (!em)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
|
||||||
* Put a : in here since those are invalid on
|
|
||||||
* the cli, so we know it's autogenerated in
|
|
||||||
* debugging.
|
|
||||||
*/
|
|
||||||
em->key = AUTODETECTED_MOUNT;
|
|
||||||
em->val = mi->source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mi->external = em;
|
mi->external = em;
|
||||||
|
Reference in New Issue
Block a user