summaryrefslogtreecommitdiffstats
path: root/fs/file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-15 21:06:33 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-26 21:08:55 -0400
commitf869e8a7f753e3fd43d6483e796774776f645edb (patch)
tree3b215f30a040812eb7488bd4596a5c3ae0b50e51 /fs/file.c
parent56007cae94f349387c088e738c7dcb6bc513063b (diff)
downloadop-kernel-dev-f869e8a7f753e3fd43d6483e796774776f645edb.zip
op-kernel-dev-f869e8a7f753e3fd43d6483e796774776f645edb.tar.gz
expose a low-level variant of fd_install() for binder
Similar situation to that of __alloc_fd(); do not use unless you really have to. You should not touch any descriptor table other than your own; it's a sure sign of a really bad API design. As with __alloc_fd(), you *must* use a first-class reference to struct files_struct; something obtained by get_files_struct(some task) (let alone direct task->files) will not do. It must be either current->files, or obtained by get_files_struct(current) by the owner of that sucker and given to you. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/file.c')
-rw-r--r--fs/file.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/file.c b/fs/file.c
index 78cf88f..0d1bf05 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -599,11 +599,18 @@ EXPORT_SYMBOL(put_unused_fd);
*
* It should never happen - if we allow dup2() do it, _really_ bad things
* will follow.
+ *
+ * NOTE: __fd_install() variant is really, really low-level; don't
+ * use it unless you are forced to by truly lousy API shoved down
+ * your throat. 'files' *MUST* be either current->files or obtained
+ * by get_files_struct(current) done by whoever had given it to you,
+ * or really bad things will happen. Normally you want to use
+ * fd_install() instead.
*/
-void fd_install(unsigned int fd, struct file *file)
+void __fd_install(struct files_struct *files, unsigned int fd,
+ struct file *file)
{
- struct files_struct *files = current->files;
struct fdtable *fdt;
spin_lock(&files->file_lock);
fdt = files_fdtable(files);
@@ -612,4 +619,9 @@ void fd_install(unsigned int fd, struct file *file)
spin_unlock(&files->file_lock);
}
+void fd_install(unsigned int fd, struct file *file)
+{
+ __fd_install(current->files, fd, file);
+}
+
EXPORT_SYMBOL(fd_install);
OpenPOWER on IntegriCloud