On Wed, Dec 20, 2017 at 07:06:51PM +0300, Stanislav Kinsburskiy wrote: > This generic helper will be responsible for both SPFS manager start via > usernsd and socket request. > > Signed-off-by: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com> > --- > criu/spfs.c | 45 ++++++++++++++++++++++++++------------------- > 1 file changed, 26 insertions(+), 19 deletions(-) > > diff --git a/criu/spfs.c b/criu/spfs.c > index a5f6031..fff7b9f 100644 > --- a/criu/spfs.c > +++ b/criu/spfs.c > @@ -153,16 +153,38 @@ static int start_spfs_manager(void) > return sock; > } > > -static int get_spfs_mngr_sock(void *arg, int fd, pid_t pid) > +static int get_spfs_mngr_sock(void *start, int fd, pid_t pid) > { > int sock; > > sock = get_service_fd(SPFS_MNGR_SK); > - if (sock < 0) > + if (sock < 0 && start)
What does this start mean? You don't use its value. > sock = start_spfs_manager(); > return sock; > } > > +static int request_spfs_mngr_sock(bool *start_mngr) > +{ > + int ns_fd; > + int sock; > + > + ns_fd = open_proc(PROC_SELF, "ns"); > + if (ns_fd < 0) > + return ns_fd; Why do you need this ns fd? ^^^ > + > + sock = userns_call(get_spfs_mngr_sock, UNS_FDOUT, start_mngr, 0, ns_fd); > + > + close(ns_fd); > + return sock; > +} > + > +static int start_spfs_mngr(void) > +{ > + bool start; ^^^^^^^^^ ???? > + > + return request_spfs_mngr_sock(&start); > +} > + > static int spfs_request_mount(int sock, struct mount_info *mi, const char > *source, > const char *type, unsigned long mountflags) > { > @@ -268,15 +290,9 @@ int spfs_mount(struct mount_info *mi, const char *source, > const char *filesystemtype, unsigned long mountflags) > { > int ret; > - int ns_fd; > int sock; > > - ns_fd = open_proc(PROC_SELF, "ns"); > - if (ns_fd < 0) > - return ns_fd; > - > - sock = userns_call(get_spfs_mngr_sock, UNS_FDOUT, NULL, 0, ns_fd); > - close(ns_fd); > + sock = start_spfs_mngr(); > if (sock < 0) { > pr_err("failed to mount NFS to path %s\n", mi->mountpoint); > return sock; > @@ -345,16 +361,7 @@ int spfs_mngr_status(bool *active) > > int spfs_mngr_sock(void) > { > - int ns_fd, fd; > - > - ns_fd = open_proc(PROC_SELF, "ns"); > - if (ns_fd < 0) > - return ns_fd; > - > - fd = userns_call(spfs_service_fd, UNS_FDOUT, NULL, 0, ns_fd); > - > - close(ns_fd); > - return fd; > + return request_spfs_mngr_sock(NULL); > } > > int spfs_set_mode(int sock, const char *mode) > _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel