mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 09:39:13 +00:00
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>
38 lines
607 B
C
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;
|
|
}
|