source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/file.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 2.2 KB
RevLine 
[2]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
11/*
12 * The default fd array needs to be at least BITS_PER_LONG,
13 * as this is the granularity returned by copy_fdset().
14 */
15#define NR_OPEN_DEFAULT BITS_PER_LONG
16
17/*
18 * Open file table structure
19 */
20struct files_struct {
21        atomic_t count;
22        spinlock_t file_lock;     /* Protects all the below members.  Nests inside tsk->alloc_lock */
23        int max_fds;
24        int max_fdset;
25        int next_fd;
26        struct file ** fd;      /* current fd array */
27        fd_set *close_on_exec;
28        fd_set *open_fds;
29        fd_set close_on_exec_init;
30        fd_set open_fds_init;
31        struct file * fd_array[NR_OPEN_DEFAULT];
32};
33
34extern void FASTCALL(__fput(struct file *));
35extern void FASTCALL(fput(struct file *));
36
37static inline void fput_light(struct file *file, int fput_needed)
38{
39        if (unlikely(fput_needed))
40                fput(file);
41}
42
43extern struct file * FASTCALL(fget(unsigned int fd));
44extern struct file * FASTCALL(fget_light(unsigned int fd, int *fput_needed));
45extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag));
46extern void put_filp(struct file *);
47extern int get_unused_fd(void);
48extern void FASTCALL(put_unused_fd(unsigned int fd));
49struct kmem_cache_s;
50extern void filp_ctor(void * objp, struct kmem_cache_s *cachep, unsigned long cflags);
51extern void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags);
52
53extern struct file ** alloc_fd_array(int);
54extern void free_fd_array(struct file **, int);
55
56extern fd_set *alloc_fdset(int);
57extern void free_fdset(fd_set *, int);
58
59extern int expand_files(struct files_struct *, int nr);
60
61static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
62{
63        struct file * file = NULL;
64
65        if (fd < files->max_fds)
66                file = files->fd[fd];
67        return file;
68}
69
70/*
71 * Check whether the specified fd has an open file.
72 */
73#define fcheck(fd)      fcheck_files(current->files, fd)
74
75extern void FASTCALL(fd_install(unsigned int fd, struct file * file));
76
77struct task_struct;
78
79struct files_struct *get_files_struct(struct task_struct *);
80void FASTCALL(put_files_struct(struct files_struct *fs));
81
82#endif /* __LINUX_FILE_H */
Note: See TracBrowser for help on using the repository browser.