lkml.org 
[lkml]   [2000]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch-2.4.0-test6pre1] do_close(files, fd, release)
Dear Linus,

The patch below adds a 'struct files_struct *' argument to do_close() thus
allowing to close a descriptor from context other than current process
context as per suggestion expressed by Manfred quite some time ago. Note
that it also slightly optimizes sys_dup2().

Please consider it.

regards,
Tigran

diff -urN -X dontdiff linux/fs/fcntl.c doclose/fs/fcntl.c
--- linux/fs/fcntl.c Fri Jul 28 09:58:59 2000
+++ doclose/fs/fcntl.c Wed Aug 2 17:19:24 2000
@@ -132,7 +132,7 @@
struct file * file;
struct files_struct * files = current->files;

- write_lock(&current->files->file_lock);
+ write_lock(&files->file_lock);
if (!(file = fcheck(oldfd)))
goto out_unlock;
err = newfd;
@@ -158,7 +158,7 @@
FD_SET(newfd, files->open_fds);
write_unlock(&files->file_lock);

- do_close(newfd, 0);
+ do_close(files, newfd, 0);

write_lock(&files->file_lock);
allocate_fd(files, file, newfd);
diff -urN -X dontdiff linux/fs/open.c doclose/fs/open.c
--- linux/fs/open.c Tue Jul 11 19:26:50 2000
+++ doclose/fs/open.c Wed Aug 2 17:18:42 2000
@@ -804,11 +804,10 @@
* or not in the open-files bitmap. dup2 uses this to retain the fd
* without races.
*/
-int do_close(unsigned int fd, int release)
+int do_close(struct files_struct *files, unsigned int fd, int release)
{
int error;
struct file * filp;
- struct files_struct * files = current->files;

error = -EBADF;
write_lock(&files->file_lock);
@@ -829,7 +828,7 @@

asmlinkage long sys_close(unsigned int fd)
{
- return do_close(fd, 1);
+ return do_close(current->files, fd, 1);
}

/*
diff -urN -X dontdiff linux/include/linux/fs.h doclose/include/linux/fs.h
--- linux/include/linux/fs.h Fri Jul 28 09:59:00 2000
+++ doclose/include/linux/fs.h Wed Aug 2 17:22:26 2000
@@ -871,8 +871,8 @@
/* fs/open.c */

asmlinkage long sys_open(const char *, int, int);
-asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
-extern int do_close(unsigned int, int); /* yes, it's really unsigned */
+asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
+extern int do_close(struct files_struct *, unsigned int, int); /* yes, it's really unsigned */
extern int do_truncate(struct dentry *, loff_t start);

extern struct file *filp_open(const char *, int, int);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.034 / U:2.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site