Commit e2a0258d authored by Pavel Emelyanov's avatar Pavel Emelyanov

util: Use open_detahc_mount helper for proc service fd creation

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent cdce5d21
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "image.h" #include "image.h"
#include "util.h" #include "util.h"
#include "util-pie.h"
#include "log.h" #include "log.h"
#include "syscall.h" #include "syscall.h"
#include "restorer.h" #include "restorer.h"
...@@ -1053,7 +1054,7 @@ static void restore_pgid(void) ...@@ -1053,7 +1054,7 @@ static void restore_pgid(void)
static int mount_proc(void) static int mount_proc(void)
{ {
int ret; int fd, ret;
char proc_mountpoint[] = "crtools-proc.XXXXXX"; char proc_mountpoint[] = "crtools-proc.XXXXXX";
if (mkdtemp(proc_mountpoint) == NULL) { if (mkdtemp(proc_mountpoint) == NULL) {
...@@ -1064,21 +1065,14 @@ static int mount_proc(void) ...@@ -1064,21 +1065,14 @@ static int mount_proc(void)
pr_info("Mount procfs in %s\n", proc_mountpoint); pr_info("Mount procfs in %s\n", proc_mountpoint);
if (mount("proc", proc_mountpoint, "proc", MS_MGC_VAL, NULL)) { if (mount("proc", proc_mountpoint, "proc", MS_MGC_VAL, NULL)) {
pr_perror("mount failed"); pr_perror("mount failed");
ret = -1; rmdir(proc_mountpoint);
goto out_rmdir;
}
ret = set_proc_mountpoint(proc_mountpoint);
if (umount2(proc_mountpoint, MNT_DETACH) == -1) {
pr_perror("Can't umount %s", proc_mountpoint);
return -1; return -1;
} }
out_rmdir: ret = fd = open_detach_mount(proc_mountpoint);
if (rmdir(proc_mountpoint) == -1) { if (fd >= 0) {
pr_perror("Can't remove %s", proc_mountpoint); ret = set_proc_fd(fd);
return -1; close(fd);
} }
return ret; return ret;
......
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