2 * Wrapper functions for accessing the file_struct fd array.
8 extern void FASTCALL(fput(struct file *));
9 extern struct file * FASTCALL(fget(unsigned int fd));
11 static inline int get_close_on_exec(unsigned int fd)
13 struct files_struct *files = current->files;
15 read_lock(&files->file_lock);
16 res = FD_ISSET(fd, files->close_on_exec);
17 read_unlock(&files->file_lock);
21 static inline void set_close_on_exec(unsigned int fd, int flag)
23 struct files_struct *files = current->files;
24 write_lock(&files->file_lock);
26 FD_SET(fd, files->close_on_exec);
28 FD_CLR(fd, files->close_on_exec);
29 write_unlock(&files->file_lock);
32 static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
34 struct file * file = NULL;
36 if (fd < files->max_fds)
42 * Check whether the specified fd has an open file.
44 static inline struct file * fcheck(unsigned int fd)
46 struct file * file = NULL;
47 struct files_struct *files = current->files;
49 if (fd < files->max_fds)
54 extern void put_filp(struct file *);
56 extern int get_unused_fd(void);
58 static inline void __put_unused_fd(struct files_struct *files, unsigned int fd)
60 FD_CLR(fd, files->open_fds);
61 if (fd < files->next_fd)
65 static inline void put_unused_fd(unsigned int fd)
67 struct files_struct *files = current->files;
69 write_lock(&files->file_lock);
70 __put_unused_fd(files, fd);
71 write_unlock(&files->file_lock);
74 void fd_install(unsigned int fd, struct file * file);
75 void put_files_struct(struct files_struct *fs);
77 #endif /* __LINUX_FILE_H */