diff options
author | Ingo Molnar <mingo@kernel.org> | 2012-12-07 12:15:33 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-12-07 12:15:33 +0100 |
commit | 222e82bef4bd520a31d48c31ab24e49dd46daa46 (patch) | |
tree | b6e73cad8e0b3a1c3e1acc537789e97aadaefa92 /fs/file.c | |
parent | 38ca9c927c7d3db61f57e3d3a9334958c3af6e9a (diff) | |
parent | 18a2f371f5edf41810f6469cb9be39931ef9deb9 (diff) |
Merge branch 'linus' into sched/core
Pick up the autogroups fix and other fixes.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/file.c')
-rw-r--r-- | fs/file.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/file.c b/fs/file.c index d3b5fa80b71b..eff23162485f 100644 --- a/fs/file.c +++ b/fs/file.c @@ -685,7 +685,6 @@ void do_close_on_exec(struct files_struct *files) struct fdtable *fdt; /* exec unshares first */ - BUG_ON(atomic_read(&files->count) != 1); spin_lock(&files->file_lock); for (i = 0; ; i++) { unsigned long set; @@ -900,7 +899,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags) return __close_fd(files, fd); if (fd >= rlimit(RLIMIT_NOFILE)) - return -EMFILE; + return -EBADF; spin_lock(&files->file_lock); err = expand_files(files, fd); @@ -926,7 +925,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags) return -EINVAL; if (newfd >= rlimit(RLIMIT_NOFILE)) - return -EMFILE; + return -EBADF; spin_lock(&files->file_lock); err = expand_files(files, newfd); @@ -995,16 +994,18 @@ int iterate_fd(struct files_struct *files, unsigned n, const void *p) { struct fdtable *fdt; - struct file *file; int res = 0; if (!files) return 0; spin_lock(&files->file_lock); - fdt = files_fdtable(files); - while (!res && n < fdt->max_fds) { - file = rcu_dereference_check_fdtable(files, fdt->fd[n++]); - if (file) - res = f(p, file, n); + for (fdt = files_fdtable(files); n < fdt->max_fds; n++) { + struct file *file; + file = rcu_dereference_check_fdtable(files, fdt->fd[n]); + if (!file) + continue; + res = f(p, file, n); + if (res) + break; } spin_unlock(&files->file_lock); return res; |