aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/file.h23
-rw-r--r--include/linux/init_task.h13
2 files changed, 24 insertions, 12 deletions
diff --git a/include/linux/file.h b/include/linux/file.h
index 5206beb9a80e..db372230848e 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -16,23 +16,29 @@
16 */ 16 */
17#define NR_OPEN_DEFAULT BITS_PER_LONG 17#define NR_OPEN_DEFAULT BITS_PER_LONG
18 18
19struct fdtable {
20 unsigned int max_fds;
21 int max_fdset;
22 int next_fd;
23 struct file ** fd; /* current fd array */
24 fd_set *close_on_exec;
25 fd_set *open_fds;
26};
27
19/* 28/*
20 * Open file table structure 29 * Open file table structure
21 */ 30 */
22struct files_struct { 31struct files_struct {
23 atomic_t count; 32 atomic_t count;
24 spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ 33 spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
25 int max_fds; 34 struct fdtable fdtab;
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; 35 fd_set close_on_exec_init;
32 fd_set open_fds_init; 36 fd_set open_fds_init;
33 struct file * fd_array[NR_OPEN_DEFAULT]; 37 struct file * fd_array[NR_OPEN_DEFAULT];
34}; 38};
35 39
40#define files_fdtable(files) (&(files)->fdtab)
41
36extern void FASTCALL(__fput(struct file *)); 42extern void FASTCALL(__fput(struct file *));
37extern void FASTCALL(fput(struct file *)); 43extern void FASTCALL(fput(struct file *));
38 44
@@ -63,9 +69,10 @@ extern int expand_files(struct files_struct *, int nr);
63static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) 69static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
64{ 70{
65 struct file * file = NULL; 71 struct file * file = NULL;
72 struct fdtable *fdt = files_fdtable(files);
66 73
67 if (fd < files->max_fds) 74 if (fd < fdt->max_fds)
68 file = files->fd[fd]; 75 file = fdt->fd[fd];
69 return file; 76 return file;
70} 77}
71 78
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index c727c195a91a..94aefa54a1b5 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -3,16 +3,21 @@
3 3
4#include <linux/file.h> 4#include <linux/file.h>
5 5
6#define INIT_FILES \ 6#define INIT_FDTABLE \
7{ \ 7{ \
8 .count = ATOMIC_INIT(1), \
9 .file_lock = SPIN_LOCK_UNLOCKED, \
10 .max_fds = NR_OPEN_DEFAULT, \ 8 .max_fds = NR_OPEN_DEFAULT, \
11 .max_fdset = __FD_SETSIZE, \ 9 .max_fdset = __FD_SETSIZE, \
12 .next_fd = 0, \ 10 .next_fd = 0, \
13 .fd = &init_files.fd_array[0], \ 11 .fd = &init_files.fd_array[0], \
14 .close_on_exec = &init_files.close_on_exec_init, \ 12 .close_on_exec = &init_files.close_on_exec_init, \
15 .open_fds = &init_files.open_fds_init, \ 13 .open_fds = &init_files.open_fds_init, \
14}
15
16#define INIT_FILES \
17{ \
18 .count = ATOMIC_INIT(1), \
19 .file_lock = SPIN_LOCK_UNLOCKED, \
20 .fdtab = INIT_FDTABLE, \
16 .close_on_exec_init = { { 0, } }, \ 21 .close_on_exec_init = { { 0, } }, \
17 .open_fds_init = { { 0, } }, \ 22 .open_fds_init = { { 0, } }, \
18 .fd_array = { NULL, } \ 23 .fd_array = { NULL, } \