patch-2.2.0-pre1 linux/fs/file_table.c
Next file: linux/fs/hfs/ChangeLog
Previous file: linux/fs/fat/inode.c
Back to the patch index
Back to the overall index
- Lines: 52
- Date:
Wed Dec 23 11:57:17 1998
- Orig file:
v2.1.132/linux/fs/file_table.c
- Orig date:
Thu Nov 19 09:56:28 1998
diff -u --recursive --new-file v2.1.132/linux/fs/file_table.c linux/fs/file_table.c
@@ -20,7 +20,7 @@
/* Free list management, if you are here you must have f_count == 0 */
static struct file * free_filps = NULL;
-void insert_file_free(struct file *file)
+static void insert_file_free(struct file *file)
{
if((file->f_next = free_filps) != NULL)
free_filps->f_pprev = &file->f_next;
@@ -40,6 +40,15 @@
file->f_pprev = &inuse_filps;
}
+/* It does not matter which list it is on. */
+static inline void remove_filp(struct file *file)
+{
+ if(file->f_next)
+ file->f_next->f_pprev = file->f_pprev;
+ *file->f_pprev = file->f_next;
+}
+
+
void __init file_table_init(void)
{
filp_cache = kmem_cache_create("filp", sizeof(struct file),
@@ -115,4 +124,26 @@
return filp->f_op->open(dentry->d_inode, filp);
else
return 0;
+}
+
+void fput(struct file *file)
+{
+ int count = file->f_count-1;
+
+ if (!count) {
+ locks_remove_flock(file);
+ __fput(file);
+ file->f_count = 0;
+ remove_filp(file);
+ insert_file_free(file);
+ } else
+ file->f_count = count;
+}
+
+void put_filp(struct file *file)
+{
+ if(--file->f_count == 0) {
+ remove_filp(file);
+ insert_file_free(file);
+ }
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov