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