diff options
Diffstat (limited to 'include/linux/fdtable.h')
-rw-r--r-- | include/linux/fdtable.h | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 82163c4b32c9..158a41eed314 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h | |||
@@ -21,23 +21,45 @@ | |||
21 | */ | 21 | */ |
22 | #define NR_OPEN_DEFAULT BITS_PER_LONG | 22 | #define NR_OPEN_DEFAULT BITS_PER_LONG |
23 | 23 | ||
24 | /* | ||
25 | * The embedded_fd_set is a small fd_set, | ||
26 | * suitable for most tasks (which open <= BITS_PER_LONG files) | ||
27 | */ | ||
28 | struct embedded_fd_set { | ||
29 | unsigned long fds_bits[1]; | ||
30 | }; | ||
31 | |||
32 | struct fdtable { | 24 | struct fdtable { |
33 | unsigned int max_fds; | 25 | unsigned int max_fds; |
34 | struct file __rcu **fd; /* current fd array */ | 26 | struct file __rcu **fd; /* current fd array */ |
35 | fd_set *close_on_exec; | 27 | unsigned long *close_on_exec; |
36 | fd_set *open_fds; | 28 | unsigned long *open_fds; |
37 | struct rcu_head rcu; | 29 | struct rcu_head rcu; |
38 | struct fdtable *next; | 30 | struct fdtable *next; |
39 | }; | 31 | }; |
40 | 32 | ||
33 | static inline void __set_close_on_exec(int fd, struct fdtable *fdt) | ||
34 | { | ||
35 | __set_bit(fd, fdt->close_on_exec); | ||
36 | } | ||
37 | |||
38 | static inline void __clear_close_on_exec(int fd, struct fdtable *fdt) | ||
39 | { | ||
40 | __clear_bit(fd, fdt->close_on_exec); | ||
41 | } | ||
42 | |||
43 | static inline bool close_on_exec(int fd, const struct fdtable *fdt) | ||
44 | { | ||
45 | return test_bit(fd, fdt->close_on_exec); | ||
46 | } | ||
47 | |||
48 | static inline void __set_open_fd(int fd, struct fdtable *fdt) | ||
49 | { | ||
50 | __set_bit(fd, fdt->open_fds); | ||
51 | } | ||
52 | |||
53 | static inline void __clear_open_fd(int fd, struct fdtable *fdt) | ||
54 | { | ||
55 | __clear_bit(fd, fdt->open_fds); | ||
56 | } | ||
57 | |||
58 | static inline bool fd_is_open(int fd, const struct fdtable *fdt) | ||
59 | { | ||
60 | return test_bit(fd, fdt->open_fds); | ||
61 | } | ||
62 | |||
41 | /* | 63 | /* |
42 | * Open file table structure | 64 | * Open file table structure |
43 | */ | 65 | */ |
@@ -53,8 +75,8 @@ struct files_struct { | |||
53 | */ | 75 | */ |
54 | spinlock_t file_lock ____cacheline_aligned_in_smp; | 76 | spinlock_t file_lock ____cacheline_aligned_in_smp; |
55 | int next_fd; | 77 | int next_fd; |
56 | struct embedded_fd_set close_on_exec_init; | 78 | unsigned long close_on_exec_init[1]; |
57 | struct embedded_fd_set open_fds_init; | 79 | unsigned long open_fds_init[1]; |
58 | struct file __rcu * fd_array[NR_OPEN_DEFAULT]; | 80 | struct file __rcu * fd_array[NR_OPEN_DEFAULT]; |
59 | }; | 81 | }; |
60 | 82 | ||