Commit e2f1a0da authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

autofs: parse fsinfo stage introduced

Autofs uses packetized pipe (with O_DIRECT), migration of which is not
supported.
Luckely, because we support only empty autofs pipes, they can be collected
into some list and then explicitly treated as normal pipes on dump.

Note: packetized mode is set by kernel inself on mount operation. So, we don't
need to carry the flag at all.
Signed-off-by: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 4d31b38a
......@@ -77,6 +77,7 @@ obj-y += tun.o
obj-y += util.o
obj-y += uts_ns.o
obj-y += path.o
obj-y += autofs.o
ifeq ($(VDSO),y)
obj-y += pie-util-vdso.o
......
#include "proc_parse.h"
#include "autofs.h"
#include "util.h"
#include "mount.h"
#define AUTOFS_OPT_UNKNOWN INT_MIN
struct autofs_pipe_s {
struct list_head list;
unsigned long inode;
};
struct list_head autofs_pipes = LIST_HEAD_INIT(autofs_pipes);
bool is_autofs_pipe(unsigned long inode)
{
struct autofs_pipe_s *p;
list_for_each_entry(p, &autofs_pipes, list) {
if (p->inode == inode)
return true;
}
return false;
}
static int autofs_gather_pipe(unsigned long inode)
{
struct autofs_pipe_s *pipe;
pipe = xmalloc(sizeof(*pipe));
if (!pipe)
return -1;
pipe->inode = inode;
list_add_tail(&pipe->list, &autofs_pipes);
return 0;
}
int autofs_parse(struct mount_info *pm)
{
long pipe_ino = AUTOFS_OPT_UNKNOWN;
char **opts;
int nr_opts, i;
split(pm->options, ',', &opts, &nr_opts);
if (!opts)
return -1;
for (i = 0; i < nr_opts; i++) {
if (!strncmp(opts[i], "pipe_ino=", strlen("pipe_ino=")))
pipe_ino = atoi(opts[i] + strlen("pipe_ino="));
}
for (i = 0; i < nr_opts; i++)
xfree(opts[i]);
free(opts);
if (pipe_ino == AUTOFS_OPT_UNKNOWN) {
pr_err("Failed to find pipe_ino option (old kernel?)\n");
return -1;
}
return autofs_gather_pipe(pipe_ino);
}
......@@ -5,4 +5,9 @@
#define AUTOFS_MINOR 235
#endif
bool is_autofs_pipe(unsigned long inode);
struct mount_info;
int autofs_parse(struct mount_info *pm);
#endif
......@@ -29,6 +29,7 @@
#include "fs-magic.h"
#include "sysfs_parse.h"
#include "path.h"
#include "autofs.h"
#include "images/mnt.pb-c.h"
#include "images/binfmt-misc.pb-c.h"
......@@ -1715,6 +1716,12 @@ static struct fstype fstypes[] = {
.name = "overlay",
.code = FSTYPE__OVERLAYFS,
.parse = overlayfs_parse,
}, {
.name = "autofs",
.code = FSTYPE__AUTOFS,
.parse = autofs_parse,
.dump = always_fail,
.restore = always_fail,
},
};
......
......@@ -11,6 +11,7 @@
#include "files.h"
#include "pipes.h"
#include "util-pie.h"
#include "autofs.h"
#include "protobuf.h"
#include "images/pipe.pb-c.h"
......@@ -490,14 +491,14 @@ static int dump_one_pipe(int lfd, u32 id, const struct fd_parms *p)
pr_info("Dumping pipe %d with id %#x pipe_id %#x\n",
lfd, id, pipe_id(p));
if (p->flags & O_DIRECT) {
if ((p->flags & O_DIRECT) && !is_autofs_pipe(pipe_id(p))) {
pr_err("The packetized mode for pipes is not supported yet\n");
return -1;
}
pe.id = id;
pe.pipe_id = pipe_id(p);
pe.flags = p->flags;
pe.flags = p->flags & ~O_DIRECT;
pe.fown = (FownEntry *)&p->fown;
if (pb_write_one(img_from_set(glob_imgset, CR_FD_PIPES), &pe, PB_PIPE))
......
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