2 * Wrapper functions for accessing the file_struct fd array.
8 extern void __fput(struct file
*);
9 extern void insert_file_free(struct file
*file
);
12 * Check whether the specified task has the fd open. Since the task
13 * may not have a files_struct, we must test for p->files != NULL.
15 extern inline struct file
* fcheck_task(struct task_struct
*p
, unsigned int fd
)
17 struct file
* file
= NULL
;
19 if (p
->files
&& fd
< p
->files
->max_fds
)
20 file
= p
->files
->fd
[fd
];
25 * Check whether the specified fd has an open file.
27 extern inline struct file
* fcheck(unsigned int fd
)
29 struct file
* file
= NULL
;
31 if (fd
< current
->files
->max_fds
)
32 file
= current
->files
->fd
[fd
];
36 extern inline struct file
* fget(unsigned int fd
)
38 struct file
* file
= fcheck(fd
);
46 * Install a file pointer in the fd array.
48 extern inline void fd_install(unsigned int fd
, struct file
*file
)
50 current
->files
->fd
[fd
] = file
;
53 /* It does not matter which list it is on. */
54 extern inline void remove_filp(struct file
*file
)
57 file
->f_next
->f_pprev
= file
->f_pprev
;
58 *file
->f_pprev
= file
->f_next
;
61 extern inline void fput(struct file
*file
)
63 int count
= file
->f_count
-1;
66 locks_remove_flock(file
);
70 insert_file_free(file
);
72 file
->f_count
= count
;
75 extern inline void put_filp(struct file
*file
)
77 if(--file
->f_count
== 0) {
79 insert_file_free(file
);