public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Patch, forward release() return values to the close() call
@ 2002-03-21  7:47 Axel Kittenberger
  2002-03-21  8:13 ` Jeff Garzik
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Axel Kittenberger @ 2002-03-21  7:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marcelo Tosatti

Here goes my liitle patchy, once again :o)

Whats it's about?

When close()ing an charcter device one expects the return value of the 
charcter drivers release() call to be forwarded to the close() called in 
userspace. However thats not the case, the kernel swallows the release() 
value, and always returns 0 to the userspace's close(). (tha char drivers 
release() function is called in fput() as it would have a void return value)

It may sound weired at first but there are actually device drivers than can 
fail on close(), in my case it's a driver to program a LCA, the userspace 
application signals end of data by closing the device, the driver finalizes 
the download, and the LCA reports if it has accepted it's new program, if not 
close() should return a non-zero value, indicating the operation did not 
complete successfully.

----

diff -r -u linux-2.4.18-orig/fs/file_table.c linux-2.4.18/fs/file_table.c
--- linux-2.4.18-orig/fs/file_table.c   Mon Sep 17 22:16:30 2001
+++ linux-2.4.18/fs/file_table.c        Wed Mar 20 16:35:34 2002
@@ -97,11 +97,12 @@
                return 0;
 }

-void fput(struct file * file)
+int fput(struct file * file)
 {
        struct dentry * dentry = file->f_dentry;
        struct vfsmount * mnt = file->f_vfsmnt;
        struct inode * inode = dentry->d_inode;
+       int retval = 0;

        if (atomic_dec_and_test(&file->f_count)) {
                locks_remove_flock(file);
@@ -110,7 +111,7 @@
                        free_kiovec(1, &file->f_iobuf);

                if (file->f_op && file->f_op->release)
-                       file->f_op->release(inode, file);
+                       retval = file->f_op->release(inode, file);
                fops_put(file->f_op);
                if (file->f_mode & FMODE_WRITE)
                        put_write_access(inode);
@@ -124,6 +125,7 @@
                dput(dentry);
                mntput(mnt);
        }
+       return retval;
 }

 struct file * fget(unsigned int fd)
diff -r -u linux-2.4.18-orig/fs/open.c linux-2.4.18/fs/open.c
--- linux-2.4.18-orig/fs/open.c Fri Oct 12 22:48:42 2001
+++ linux-2.4.18/fs/open.c      Wed Mar 20 16:34:12 2002
@@ -835,7 +835,10 @@
        }
        fcntl_dirnotify(0, filp, 0);
        locks_remove_posix(filp, id);
-       fput(filp);
+       if (retval == 0)
+               retval = fput(filp);
+       else
+               fput(filp);
        return retval;
 }

diff -r -u linux-2.4.18-orig/include/linux/file.h 
linux-2.4.18/include/linux/file.h
--- linux-2.4.18-orig/include/linux/file.h      Wed Aug 23 20:22:26 2000
+++ linux-2.4.18/include/linux/file.h   Wed Mar 20 16:32:36 2002
@@ -5,7 +5,7 @@
 #ifndef __LINUX_FILE_H
 #define __LINUX_FILE_H

-extern void FASTCALL(fput(struct file *));
+extern int FASTCALL(fput(struct file *));
 extern struct file * FASTCALL(fget(unsigned int fd));

 static inline int get_close_on_exec(unsigned int fd)

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-03-26  8:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1016697001.29134.linux-kernel2news@redhat.com>
     [not found] ` <200203211845.g2LIjTu22218@devserv.devel.redhat.com>
2002-03-22  8:06   ` Patch, forward release() return values to the close() call Axel Kittenberger
2002-03-22  8:53     ` Pete Zaitcev
2002-03-21  7:47 Axel Kittenberger
2002-03-21  8:13 ` Jeff Garzik
2002-03-21 16:32   ` David Brown
2002-03-22  7:58     ` Axel Kittenberger
2002-03-22 13:51       ` David Brown
2002-03-25  9:50         ` Axel Kittenberger
2002-03-25 13:33           ` David Brown
2002-03-26  8:52             ` Axel Kittenberger
2002-03-21  8:21 ` Jeff Garzik
2002-03-21  8:27 ` Jeff Garzik
2002-03-21  9:10   ` Oliver Neukum
2002-03-21  9:18     ` Jeff Garzik
2002-03-21 10:14       ` Oliver.Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox