Import 2.3.9pre7
[davej-history.git] / include / linux / file.h
blob5efa992964112311ccba234278f0b8f1a5b6ac2d
1 /*
2 * Wrapper functions for accessing the file_struct fd array.
3 */
5 #ifndef __LINUX_FILE_H
6 #define __LINUX_FILE_H
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];
20 return file;
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)
33 file = files->fd[fd];
34 read_unlock(&files->file_lock);
35 return file;
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) {
45 file = files->fd[fd];
46 if (file)
47 atomic_inc(&file->f_count);
49 read_unlock(&files->file_lock);
50 return file;
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);
61 files->fd[fd] = file;
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:
73 * 3756 (i386 arch)
75 * precious bytes from my kernel, even without counting all the code compiled
76 * as module!
78 * I suspect there are many other similar "optimizations" across the
79 * kernel...
81 extern void fput(struct file *);
82 extern void put_filp(struct file *);
84 #endif /* __LINUX_FILE_H */