[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1425936003-24544-5-git-send-email-zenczykowski@gmail.com>
Date: Mon, 9 Mar 2015 14:20:00 -0700
From: Maciej Żenczykowski <zenczykowski@...il.com>
To: Maciej Żenczykowski <maze@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>
Cc: Theodore Ts'o <tytso@....edu>, netdev@...r.kernel.org
Subject: [PATCH 5/8] fs/file: __alloc_fd takes extra argument: newfile
From: Maciej Żenczykowski <maze@...gle.com>
Signed-off-by: Maciej Żenczykowski <maze@...gle.com>
---
drivers/android/binder.c | 2 +-
fs/file.c | 10 ++++++----
include/linux/fdtable.h | 3 ++-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 33b09b6568a4..75ad6b604f2a 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -389,7 +389,7 @@ static int task_get_unused_fd_flags(struct binder_proc *proc, int flags)
rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE);
unlock_task_sighand(proc->tsk, &irqs);
- return __alloc_fd(files, 0, rlim_cur, flags);
+ return __alloc_fd(files, 0, rlim_cur, flags, NULL);
}
/*
diff --git a/fs/file.c b/fs/file.c
index ee738ea028fa..01b1e171ce0a 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -443,7 +443,8 @@ struct files_struct init_files = {
* allocate a file descriptor, mark it busy.
*/
int __alloc_fd(struct files_struct *files,
- unsigned start, unsigned end, unsigned flags)
+ unsigned start, unsigned end, unsigned flags,
+ struct file *newfile)
{
unsigned int fd;
int error;
@@ -491,9 +492,9 @@ repeat:
/* Sanity check */
if (rcu_access_pointer(fdt->fd[fd]) != NULL) {
printk(KERN_WARNING "alloc_fd: slot %d not NULL!\n", fd);
- rcu_assign_pointer(fdt->fd[fd], NULL);
}
#endif
+ rcu_assign_pointer(fdt->fd[fd], newfile);
out:
spin_unlock(&files->file_lock);
@@ -502,12 +503,13 @@ out:
static int alloc_fd(unsigned start, unsigned flags)
{
- return __alloc_fd(current->files, start, rlimit(RLIMIT_NOFILE), flags);
+ return __alloc_fd(current->files, start, rlimit(RLIMIT_NOFILE), flags,
+ NULL);
}
int get_unused_fd_flags(unsigned flags)
{
- return __alloc_fd(current->files, 0, rlimit(RLIMIT_NOFILE), flags);
+ return __alloc_fd(current->files, 0, rlimit(RLIMIT_NOFILE), flags, NULL);
}
EXPORT_SYMBOL(get_unused_fd_flags);
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 230f87bdf5ad..a4e0a98750c3 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -107,7 +107,8 @@ int iterate_fd(struct files_struct *, unsigned,
const void *);
extern int __alloc_fd(struct files_struct *files,
- unsigned start, unsigned end, unsigned flags);
+ unsigned start, unsigned end, unsigned flags,
+ struct file *newfile);
extern void __fd_install(struct files_struct *files,
unsigned int fd, struct file *file);
extern int __close_fd(struct files_struct *files,
--
2.2.0.rc0.207.ga3a616c
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists