aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/file.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/file.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/file.h')
-rw-r--r--include/linux/file.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/include/linux/file.h b/include/linux/file.h
new file mode 100644
index 000000000000..5206beb9a80e
--- /dev/null
+++ b/include/linux/file.h
@@ -0,0 +1,84 @@
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#include <asm/atomic.h>
9#include <linux/posix_types.h>
10#include <linux/compiler.h>
11#include <linux/spinlock.h>
12
13/*
14 * The default fd array needs to be at least BITS_PER_LONG,
15 * as this is the granularity returned by copy_fdset().
16 */
17#define NR_OPEN_DEFAULT BITS_PER_LONG
18
19/*
20 * Open file table structure
21 */
22struct files_struct {
23 atomic_t count;
24 spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
25 int max_fds;
26 int max_fdset;
27 int next_fd;
28 struct file ** fd; /* current fd array */
29 fd_set *close_on_exec;
30 fd_set *open_fds;
31 fd_set close_on_exec_init;
32 fd_set open_fds_init;
33 struct file * fd_array[NR_OPEN_DEFAULT];
34};
35
36extern void FASTCALL(__fput(struct file *));
37extern void FASTCALL(fput(struct file *));
38
39static inline void fput_light(struct file *file, int fput_needed)
40{
41 if (unlikely(fput_needed))
42 fput(file);
43}
44
45extern struct file * FASTCALL(fget(unsigned int fd));
46extern struct file * FASTCALL(fget_light(unsigned int fd, int *fput_needed));
47extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag));
48extern void put_filp(struct file *);
49extern int get_unused_fd(void);
50extern void FASTCALL(put_unused_fd(unsigned int fd));
51struct kmem_cache_s;
52extern void filp_ctor(void * objp, struct kmem_cache_s *cachep, unsigned long cflags);
53extern void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags);
54
55extern struct file ** alloc_fd_array(int);
56extern void free_fd_array(struct file **, int);
57
58extern fd_set *alloc_fdset(int);
59extern void free_fdset(fd_set *, int);
60
61extern int expand_files(struct files_struct *, int nr);
62
63static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
64{
65 struct file * file = NULL;
66
67 if (fd < files->max_fds)
68 file = files->fd[fd];
69 return file;
70}
71
72/*
73 * Check whether the specified fd has an open file.
74 */
75#define fcheck(fd) fcheck_files(current->files, fd)
76
77extern void FASTCALL(fd_install(unsigned int fd, struct file * file));
78
79struct task_struct;
80
81struct files_struct *get_files_struct(struct task_struct *);
82void FASTCALL(put_files_struct(struct files_struct *fs));
83
84#endif /* __LINUX_FILE_H */