[CRIU] [PATCH 1/3] Open proc helper fds with O_PATH

Pavel Emelyanov xemul at parallels.com
Fri Nov 6 01:00:28 PST 2015


These descriptors are purely used for openat()-s, so having
them opened with O_PATH is OK and saves a little bit operations
in the kernel space.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util.c b/util.c
index 337b0ed..ecf74c6 100644
--- a/util.c
+++ b/util.c
@@ -227,7 +227,7 @@ static int open_proc_sfd(char *path)
 	int fd, ret;
 
 	close_proc();
-	fd = open(path, O_DIRECTORY | O_RDONLY);
+	fd = open(path, O_DIRECTORY | O_PATH);
 	if (fd == -1) {
 		pr_perror("Can't open %s", path);
 		return -1;
@@ -271,7 +271,7 @@ inline int open_pid_proc(pid_t pid)
 	else
 		snprintf(path, sizeof(path), "%d", pid);
 
-	fd = openat(dfd, path, O_RDONLY);
+	fd = openat(dfd, path, O_PATH);
 	if (fd < 0) {
 		pr_perror("Can't open %s", path);
 		set_cr_errno(ESRCH);
-- 
1.9.3



More information about the CRIU mailing list