criu/pie/util.c
Cyrill Gorcunov c75c92db1d pie: Move send_fds/recv_fds helpers into separate pie/util-fd.c
We will need to reuse this code in criu library, where libc calls
are present thus we will be compiling it in shared mode.

Because internal syscalls library won't be needed we wrap them
with __sys macro which would hide the details of invocation depending
on CR_NOGLIBC preprocessor variable passed from command line.

Original-patch-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-29 14:48:10 +04:00

38 lines
607 B
C

#include <sys/socket.h>
#include <sys/un.h>
#include <sys/mount.h>
#include <errno.h>
#include "compiler.h"
#include "asm/string.h"
#include "asm/types.h"
#include "syscall.h"
#include "log.h"
#include "util-pie.h"
int open_detach_mount(char *dir)
{
int fd;
fd = sys_open(dir, O_RDONLY | O_DIRECTORY, 0);
if (fd < 0)
pr_perror("Can't open directory");
if (sys_umount2(dir, MNT_DETACH)) {
pr_perror("Can't detach mount");
goto err_close;
}
if (sys_rmdir(dir)) {
pr_perror("Can't remove tmp dir");
goto err_close;
}
return fd;
err_close:
if (fd >= 0)
sys_close(fd);
return -1;
}