2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

util.c: introduce open_proc_rw()

To be used by the next patch

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
Kir Kolyshkin
2012-02-17 01:39:33 +04:00
committed by Cyrill Gorcunov
parent 389bd830f1
commit 03294077af
2 changed files with 9 additions and 3 deletions

11
util.c
View File

@@ -217,7 +217,7 @@ int open_pid_proc(pid_t pid)
return fd;
}
#define do_open_proc(pid_dir_fd, fmt) \
#define do_open_proc(pid_dir_fd, fmt, flags) \
({ \
char fname[64]; \
va_list args; \
@@ -226,12 +226,17 @@ int open_pid_proc(pid_t pid)
vsnprintf(fname, sizeof(fname), fmt, args); \
va_end(args); \
\
openat(pid_dir_fd, fname, O_RDONLY); \
openat(pid_dir_fd, fname, flags); \
})
int open_proc(int pid_dir_fd, char *fmt, ...)
{
return do_open_proc(pid_dir_fd, fmt);
return do_open_proc(pid_dir_fd, fmt, O_RDONLY);
}
int open_proc_rw(int pid_dir_fd, char *fmt, ...)
{
return do_open_proc(pid_dir_fd, fmt, O_RDWR);
}
DIR *opendir_proc(int pid_dir_fd, char *fmt, ...)