This one walks the 'plain' image file, i.e. the one with straignt <magi>[<size><entry>]*
format, and prints each message. Saves lots of lines of code.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
1. Mountinfo should be collected after we have forked into new namespace (strictly
speaking this is so)
2. When restoring a mnt ns we can reuse the collected mntinfos rather than reading
them again.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Only support virtual filesystems mount. No bindmounts or disk fs
due to non trivial resolving of devices names and binmount sources.
Will be implemented later.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Two walkers -- in forward and reverse directions -- are required
for correct (u)mounting of subtrees. Implement them using a helper
macro which walks the tree in both directions.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Namespace restore goes in two steps -- first, clean old mountpoints
(except root) that are left after clone(CLONE_NEWNS) call. Next,
repopulate the namespace with new mountpoints (except root) read
from the image file.
This patch adds the skeleton for the above -- reading the mountpoints
from current proc and image and calling for mount/umount. The real
action will come in further patches.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Build a tree of mountpoins that can be (u)mounted in a straight
(forward or backward) order without EBUSY errors.
The tree is built in two steps -- first create hierarchy based
on mount iDs. Next -- resort siblings in the path depth order.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Encode it in u32 since we have to check filesystem name anyway
(not everyone ie easily migratable).
Dump _any_ root fs as we need the root entry on restore though
do not mount it then -- it should be provided before crtools
restore start.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Dumping is straightforward -- just copy all the mount_info
fields into the new image file. Dump everything but fstype,
this one will come in a separate patch.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This structure will be used on restore and will be created
from the image, thus the name proc_ is not suitable.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Make the proc_mountinfo obtaned after parse form a single linked list.
That's much easier to handle and doesn't have an artificial limitation
of 64 items...
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
What is stored there is the path to mountpoint. The root
is the field previously named "parent root".
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v2:
- open_mount is cleaned up
- byte-stream hex conversion remains untouched since
strtol is flipping numbers to LE manner
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
At moment only open_mnt_root is there, which is
needed for inotify restore.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>