Commit e853848b authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

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: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 9f899374
...@@ -141,21 +141,23 @@ static int autofs_find_pipe_read_end(int pgrp, long ino, int *read_fd) ...@@ -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) { if (fstatat(dirfd(dir), de->d_name, &buf, 0) < 0) {
pr_perror("Failed to fstatat"); pr_perror("Failed to fstatat");
break; goto out;
} }
fd = atoi(de->d_name); fd = atoi(de->d_name);
found = autofs_check_fd_stat(&buf, pgrp, fd, ino, &mode); found = autofs_check_fd_stat(&buf, pgrp, fd, ino, &mode);
if (found < 0) if (found < 0)
break; goto out;
if (found && (mode == O_RDONLY)) { if (found && (mode == O_RDONLY)) {
*read_fd = fd; *read_fd = fd;
ret = 0;
break; break;
} }
} }
ret = 0;
out:
closedir(dir); closedir(dir);
close_pid_proc(); close_pid_proc();
...@@ -177,7 +179,7 @@ static int autofs_find_read_fd(int pgrp, long pipe_ino) ...@@ -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 " pr_err("Master %d doesn't have a read end of the pipe with "
"inode %ld opened\n", pgrp, pipe_ino); "inode %ld opened\n", pgrp, pipe_ino);
pr_err("Abandoned mount or control was delegated to child?\n"); pr_err("Abandoned mount or control was delegated to child?\n");
return -1; return -ENOENT;
} }
/* Let's check, that read end is empty */ /* Let's check, that read end is empty */
......
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