[PATCH 1/2] fs: add ability to attach and to allocate fd for non current tasks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrew Vagin <avagin@xxxxxxxxxx>
---
 fs/file.c            |    9 +++++++--
 fs/open.c            |    9 +++++++--
 include/linux/file.h |    4 ++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index 4c6992d..fbf2879 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -428,9 +428,9 @@ struct files_struct init_files = {
 /*
  * allocate a file descriptor, mark it busy.
  */
-int alloc_fd(unsigned start, unsigned flags)
+int alloc_task_fd(struct task_struct *tsk, unsigned start, unsigned flags)
 {
-	struct files_struct *files = current->files;
+	struct files_struct *files = tsk->files;
 	unsigned int fd;
 	int error;
 	struct fdtable *fdt;
@@ -479,6 +479,11 @@ out:
 	return error;
 }
 
+int alloc_fd(unsigned start, unsigned flags)
+{
+	return alloc_task_fd(current, start, flags);
+}
+
 int get_unused_fd(void)
 {
 	return alloc_fd(0, 0);
diff --git a/fs/open.c b/fs/open.c
index 22c41b5..9d340cc 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -864,9 +864,9 @@ EXPORT_SYMBOL(put_unused_fd);
  * will follow.
  */
 
-void fd_install(unsigned int fd, struct file *file)
+void fd_task_install(struct task_struct *tsk, unsigned int fd, struct file *file)
 {
-	struct files_struct *files = current->files;
+	struct files_struct *files = tsk->files;
 	struct fdtable *fdt;
 	spin_lock(&files->file_lock);
 	fdt = files_fdtable(files);
@@ -875,6 +875,11 @@ void fd_install(unsigned int fd, struct file *file)
 	spin_unlock(&files->file_lock);
 }
 
+void fd_install(unsigned int fd, struct file *file)
+{
+	return fd_task_install(current, fd, file);
+}
+
 EXPORT_SYMBOL(fd_install);
 
 static inline int build_open_flags(int flags, int mode, struct open_flags *op)
diff --git a/include/linux/file.h b/include/linux/file.h
index 21a7995..0250cf4 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -34,10 +34,14 @@ extern struct file *fget_raw_light(unsigned int fd, int *fput_needed);
 extern void set_close_on_exec(unsigned int fd, int flag);
 extern void put_filp(struct file *);
 extern int alloc_fd(unsigned start, unsigned flags);
+struct task_struct;
+extern int alloc_task_fd(struct task_struct *tsk, unsigned start, unsigned flags);
 extern int get_unused_fd(void);
 #define get_unused_fd_flags(flags) alloc_fd(0, (flags))
 extern void put_unused_fd(unsigned int fd);
 
+extern void fd_task_install(struct task_struct *tsk,
+				unsigned int fd, struct file *file);
 extern void fd_install(unsigned int fd, struct file *file);
 
 #endif /* __LINUX_FILE_H */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux