2 * Wrapper functions for accessing the file_struct fd array.
8 #include <asm/atomic.h>
9 #include <linux/posix_types.h>
10 #include <linux/compiler.h>
11 #include <linux/spinlock.h>
14 * The default fd array needs to be at least BITS_PER_LONG,
15 * as this is the granularity returned by copy_fdset().
17 #define NR_OPEN_DEFAULT BITS_PER_LONG
20 * Open file table structure
24 rwlock_t file_lock
; /* Protects all the below members. Nests inside tsk->alloc_lock */
28 struct file
** fd
; /* current fd array */
29 fd_set
*close_on_exec
;
31 fd_set close_on_exec_init
;
33 struct file
* fd_array
[NR_OPEN_DEFAULT
];
36 extern void FASTCALL(__fput(struct file
*));
37 extern void FASTCALL(fput(struct file
*));
38 extern struct file
* FASTCALL(fget(unsigned int fd
));
39 extern void FASTCALL(set_close_on_exec(unsigned int fd
, int flag
));
40 extern void put_filp(struct file
*);
41 extern int get_unused_fd(void);
42 extern void FASTCALL(put_unused_fd(unsigned int fd
));
44 extern struct file
** alloc_fd_array(int);
45 extern int expand_fd_array(struct files_struct
*, int nr
);
46 extern void free_fd_array(struct file
**, int);
48 extern fd_set
*alloc_fdset(int);
49 extern int expand_fdset(struct files_struct
*, int nr
);
50 extern void free_fdset(fd_set
*, int);
52 static inline struct file
* fcheck_files(struct files_struct
*files
, unsigned int fd
)
54 struct file
* file
= NULL
;
56 if (fd
< files
->max_fds
)
62 * Check whether the specified fd has an open file.
64 #define fcheck(fd) fcheck_files(current->files, fd)
66 extern void FASTCALL(fd_install(unsigned int fd
, struct file
* file
));
67 void FASTCALL(put_files_struct(struct files_struct
*fs
));
69 #endif /* __LINUX_FILE_H */