Commit 77443aa5 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

regfiles: Kill prepare_shared_reg_files()

This routine just initializes the remap open lock,
and there's already the code that initializes the
whole remap engine.

Re-arrange this part.

✓ travis-ci: success for Sanitize initialization bits
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 237bd269
...@@ -325,9 +325,6 @@ static int root_prepare_shared(void) ...@@ -325,9 +325,6 @@ static int root_prepare_shared(void)
pr_info("Preparing info about shared resources\n"); pr_info("Preparing info about shared resources\n");
if (prepare_shared_reg_files())
return -1;
if (prepare_remaps()) if (prepare_remaps())
return -1; return -1;
......
...@@ -67,6 +67,16 @@ static LIST_HEAD(ghost_files); ...@@ -67,6 +67,16 @@ static LIST_HEAD(ghost_files);
*/ */
static mutex_t *remap_open_lock; static mutex_t *remap_open_lock;
static inline int init_remap_lock(void)
{
remap_open_lock = shmalloc(sizeof(*remap_open_lock));
if (!remap_open_lock)
return -1;
mutex_init(remap_open_lock);
return 0;
}
static LIST_HEAD(remaps); static LIST_HEAD(remaps);
/* /*
...@@ -502,6 +512,10 @@ int prepare_remaps(void) ...@@ -502,6 +512,10 @@ int prepare_remaps(void)
struct remap_info *ri; struct remap_info *ri;
int ret = 0; int ret = 0;
ret = init_remap_lock();
if (ret)
return ret;
list_for_each_entry(ri, &remaps, list) { list_for_each_entry(ri, &remaps, list) {
ret = prepare_one_remap(ri); ret = prepare_one_remap(ri);
if (ret) if (ret)
...@@ -1723,16 +1737,6 @@ static struct collect_image_info reg_file_cinfo = { ...@@ -1723,16 +1737,6 @@ static struct collect_image_info reg_file_cinfo = {
.flags = COLLECT_SHARED, .flags = COLLECT_SHARED,
}; };
int prepare_shared_reg_files(void)
{
remap_open_lock = shmalloc(sizeof(*remap_open_lock));
if (!remap_open_lock)
return -1;
mutex_init(remap_open_lock);
return 0;
}
int collect_remaps_and_regfiles(void) int collect_remaps_and_regfiles(void)
{ {
if (collect_image(&reg_file_cinfo)) if (collect_image(&reg_file_cinfo))
......
...@@ -32,8 +32,6 @@ extern int open_path(struct file_desc *, int (*open_cb)(int ns_root_fd, ...@@ -32,8 +32,6 @@ extern int open_path(struct file_desc *, int (*open_cb)(int ns_root_fd,
struct reg_file_info *, void *), void *arg); struct reg_file_info *, void *), void *arg);
extern void clear_ghost_files(void); extern void clear_ghost_files(void);
extern int prepare_shared_reg_files(void);
extern const struct fdtype_ops regfile_dump_ops; extern const struct fdtype_ops regfile_dump_ops;
extern int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, void *arg); extern int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, void *arg);
extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p); extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
......
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