diff options
Diffstat (limited to 'include/linux/file.h')
-rw-r--r-- | include/linux/file.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/include/linux/file.h b/include/linux/file.h index 4ba5311e8..0cb531c0c 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -13,16 +13,37 @@ extern inline struct file * fget(unsigned long fd) } extern int __fput(struct file *, struct inode *); +extern void insert_file_free(struct file *file); + +/* It does not matter which list it is on. */ +extern 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; +} extern inline int fput(struct file *file, struct inode *inode) { int count = file->f_count-1; int error = 0; - if (!count) + if (!count) { error = __fput(file, inode); - file->f_count = count; + file->f_count = 0; + remove_filp(file); + insert_file_free(file); + } else + file->f_count = count; return error; } +extern inline void put_filp(struct file *file) +{ + if(--file->f_count == 0) { + remove_filp(file); + insert_file_free(file); + } +} + #endif |