Commit df1729e3 authored by Pavel Emelyanov's avatar Pavel Emelyanov

util: Ability to ignore errno when opening proc

When run from regular user criu will get EACCES/EPERM from
opening proc, but in some situations criu will now how to
deal with it. So this patch makes it possible not to print
error message in logs for such cases.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Looks-good-to-me: Andrew Vagin <avagin@virtuozzo.com>
parent 70681dd8
...@@ -75,11 +75,11 @@ extern int set_proc_fd(int fd); ...@@ -75,11 +75,11 @@ extern int set_proc_fd(int fd);
extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...); extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
#define __open_proc(pid, flags, fmt, ...) \ #define __open_proc(pid, ier, flags, fmt, ...) \
({ \ ({ \
int __fd = do_open_proc(pid, flags, \ int __fd = do_open_proc(pid, flags, \
fmt, ##__VA_ARGS__); \ fmt, ##__VA_ARGS__); \
if (__fd < 0) \ if (__fd < 0 && (errno != ier)) \
pr_perror("Can't open %d/" fmt " on procfs", \ pr_perror("Can't open %d/" fmt " on procfs", \
pid, ##__VA_ARGS__); \ pid, ##__VA_ARGS__); \
\ \
...@@ -88,14 +88,14 @@ extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...); ...@@ -88,14 +88,14 @@ extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
/* int open_proc(pid_t pid, const char *fmt, ...); */ /* int open_proc(pid_t pid, const char *fmt, ...); */
#define open_proc(pid, fmt, ...) \ #define open_proc(pid, fmt, ...) \
__open_proc(pid, O_RDONLY, fmt, ##__VA_ARGS__) __open_proc(pid, 0, O_RDONLY, fmt, ##__VA_ARGS__)
/* int open_proc_rw(pid_t pid, const char *fmt, ...); */ /* int open_proc_rw(pid_t pid, const char *fmt, ...); */
#define open_proc_rw(pid, fmt, ...) \ #define open_proc_rw(pid, fmt, ...) \
__open_proc(pid, O_RDWR, fmt, ##__VA_ARGS__) __open_proc(pid, 0, O_RDWR, fmt, ##__VA_ARGS__)
#define open_proc_path(pid, fmt, ...) \ #define open_proc_path(pid, fmt, ...) \
__open_proc(pid, O_PATH, fmt, ##__VA_ARGS__) __open_proc(pid, 0, O_PATH, fmt, ##__VA_ARGS__)
/* DIR *opendir_proc(pid_t pid, const char *fmt, ...); */ /* DIR *opendir_proc(pid_t pid, const char *fmt, ...); */
#define opendir_proc(pid, fmt, ...) \ #define opendir_proc(pid, fmt, ...) \
......
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