From e853848b5b925e6536adf42432ceff3d1db35ccf Mon Sep 17 00:00:00 2001 From: Stanislav Kinsburskiy Date: Thu, 5 May 2016 19:48:06 +0300 Subject: [PATCH] autofs: rework pipe search logic a bit 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 Signed-off-by: Pavel Emelyanov --- criu/autofs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/criu/autofs.c b/criu/autofs.c index dede4e80f..75aff5948 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 */