diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-21 12:11:46 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-26 21:09:57 -0400 |
commit | 8280d16172243702ed43432f826ca6130edb4086 (patch) | |
tree | 020dff359c5b717a110432159bcc3ec1acf6594e /fs/exec.c | |
parent | fe17f22d7fd0e344ef6447238f799bb49f670c6f (diff) |
new helper: replace_fd()
analog of dup2(), except that it takes struct file * as source.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 11 |
1 files changed, 1 insertions, 10 deletions
@@ -2041,23 +2041,14 @@ static void wait_for_dump_helpers(struct file *file) | |||
2041 | static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) | 2041 | static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) |
2042 | { | 2042 | { |
2043 | struct file *files[2]; | 2043 | struct file *files[2]; |
2044 | struct fdtable *fdt; | ||
2045 | struct coredump_params *cp = (struct coredump_params *)info->data; | 2044 | struct coredump_params *cp = (struct coredump_params *)info->data; |
2046 | struct files_struct *cf = current->files; | ||
2047 | int err = create_pipe_files(files, 0); | 2045 | int err = create_pipe_files(files, 0); |
2048 | if (err) | 2046 | if (err) |
2049 | return err; | 2047 | return err; |
2050 | 2048 | ||
2051 | cp->file = files[1]; | 2049 | cp->file = files[1]; |
2052 | 2050 | ||
2053 | sys_close(0); | 2051 | replace_fd(0, files[0], 0); |
2054 | fd_install(0, files[0]); | ||
2055 | spin_lock(&cf->file_lock); | ||
2056 | fdt = files_fdtable(cf); | ||
2057 | __set_open_fd(0, fdt); | ||
2058 | __clear_close_on_exec(0, fdt); | ||
2059 | spin_unlock(&cf->file_lock); | ||
2060 | |||
2061 | /* and disallow core files too */ | 2052 | /* and disallow core files too */ |
2062 | current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1}; | 2053 | current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1}; |
2063 | 2054 | ||