2 * Wrapper functions for accessing the file_struct fd array.
8 extern void __fput(struct file
*);
11 * Check whether the specified task has the fd open. Since the task
12 * may not have a files_struct, we must test for p->files != NULL.
14 extern inline struct file
* fcheck_task(struct task_struct
*p
, unsigned int fd
)
16 struct file
* file
= NULL
;
18 if (p
->files
&& fd
< p
->files
->max_fds
)
19 file
= p
->files
->fd
[fd
];
24 * Check whether the specified fd has an open file.
26 extern inline struct file
* fcheck(unsigned int fd
)
28 struct file
* file
= NULL
;
29 struct files_struct
*files
= current
->files
;
31 read_lock(&files
->file_lock
);
32 if (fd
< files
->max_fds
)
34 read_unlock(&files
->file_lock
);
38 extern inline struct file
* fget(unsigned int fd
)
40 struct file
* file
= NULL
;
41 struct files_struct
*files
= current
->files
;
43 read_lock(&files
->file_lock
);
44 if (fd
< files
->max_fds
) {
47 atomic_inc(&file
->f_count
);
49 read_unlock(&files
->file_lock
);
54 * Install a file pointer in the fd array.
56 extern inline void fd_install(unsigned int fd
, struct file
* file
)
58 struct files_struct
*files
= current
->files
;
60 write_lock(&files
->file_lock
);
62 write_unlock(&files
->file_lock
);
66 * 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>:
68 * Since those functions where calling other functions, it was compleatly
69 * bogous to make them all "extern inline".
71 * The removal of this pseudo optimization saved me scandaleous:
75 * precious bytes from my kernel, even without counting all the code compiled
78 * I suspect there are many other similar "optimizations" across the
81 extern void fput(struct file
*);
82 extern void put_filp(struct file
*);
84 #endif /* __LINUX_FILE_H */