[32] | 1 | /*
|
---|
| 2 | * Wrapper functions for accessing the file_struct fd array.
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifndef __LINUX_FILE_H
|
---|
| 6 | #define __LINUX_FILE_H
|
---|
| 7 |
|
---|
[679] | 8 | #include <linux/types.h>
|
---|
| 9 |
|
---|
| 10 | struct fd {
|
---|
| 11 | struct file *file;
|
---|
| 12 | int need_put;
|
---|
| 13 | };
|
---|
| 14 |
|
---|
[32] | 15 | extern void _fput(struct file *);
|
---|
| 16 |
|
---|
| 17 | /*
|
---|
| 18 | * Check whether the specified task has the fd open. Since the task
|
---|
| 19 | * may not have a files_struct, we must test for p->files != NULL.
|
---|
| 20 | */
|
---|
| 21 | extern struct file * fcheck_task(struct task_struct *p, unsigned int fd);
|
---|
| 22 |
|
---|
| 23 | /*
|
---|
| 24 | * Check whether the specified fd has an open file.
|
---|
| 25 | */
|
---|
| 26 | extern inline struct file * fcheck(unsigned int fd);
|
---|
| 27 |
|
---|
| 28 | extern inline struct file * frip(unsigned int fd);
|
---|
| 29 |
|
---|
| 30 | extern inline struct file * fget(unsigned int fd);
|
---|
| 31 |
|
---|
| 32 | /*
|
---|
| 33 | * 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>:
|
---|
| 34 | *
|
---|
| 35 | * Since those functions where calling other functions, it was compleatly
|
---|
| 36 | * bogous to make them all "extern inline".
|
---|
| 37 | *
|
---|
| 38 | * The removal of this pseudo optimization saved me scandaleous:
|
---|
| 39 | *
|
---|
| 40 | * 3756 (i386 arch)
|
---|
| 41 | *
|
---|
| 42 | * precious bytes from my kernel, even without counting all the code compiled
|
---|
| 43 | * as module!
|
---|
| 44 | *
|
---|
| 45 | * I suspect there are many other similar "optimizations" across the
|
---|
| 46 | * kernel...
|
---|
| 47 | */
|
---|
| 48 | extern inline void fput(struct file * file);
|
---|
| 49 | extern void put_filp(struct file *);
|
---|
| 50 |
|
---|
| 51 | /*
|
---|
| 52 | * Install a file pointer in the fd array.
|
---|
| 53 | *
|
---|
| 54 | * The VFS is full of places where we drop the files lock between
|
---|
| 55 | * setting the open_fds bitmap and installing the file in the file
|
---|
| 56 | * array. At any such point, we are vulnerable to a dup2() race
|
---|
| 57 | * installing a file in the array before us. We need to detect this and
|
---|
| 58 | * fput() the struct file we are about to overwrite in this case.
|
---|
| 59 | */
|
---|
| 60 |
|
---|
| 61 | extern inline void fd_install(unsigned int fd, struct file * file);
|
---|
| 62 |
|
---|
| 63 | #endif /* __LINUX_FILE_H */
|
---|