[CRIU] [PATCH 1/2] autofs: rework pipe search logic a bit
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Thu May 5 09:48:06 PDT 2016
No not return error from autofs_find_pipe_read_end, if pipe end wasn't found,
because read_fd remains negative.
There is another explicit check in the caller of this function for read_fd and
proper messages are printed in such a case.
Return -ENOENT in case of read end of the pipe doesn't exist to distinguish
with other error types (will be used later).
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
criu/autofs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/criu/autofs.c b/criu/autofs.c
index 8e56e99..09c057c 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -141,21 +141,23 @@ static int autofs_find_pipe_read_end(int pgrp, long ino, int *read_fd)
if (fstatat(dirfd(dir), de->d_name, &buf, 0) < 0) {
pr_perror("Failed to fstatat");
- break;
+ goto out;
}
fd = atoi(de->d_name);
found = autofs_check_fd_stat(&buf, pgrp, fd, ino, &mode);
if (found < 0)
- break;
+ goto out;
if (found && (mode == O_RDONLY)) {
*read_fd = fd;
- ret = 0;
break;
}
}
+ ret = 0;
+
+out:
closedir(dir);
close_pid_proc();
@@ -177,7 +179,7 @@ static int autofs_find_read_fd(int pgrp, long pipe_ino)
pr_err("Master %d doesn't have a read end of the pipe with "
"inode %ld opened\n", pgrp, pipe_ino);
pr_err("Abandoned mount or control was delegated to child?\n");
- return -1;
+ return -ENOENT;
}
/* Let's check, that read end is empty */
More information about the CRIU
mailing list