~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/file.h

Version: ~ [ linux-5.9-rc5 ] ~ [ linux-5.8.10 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.66 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.146 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.198 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.236 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.236 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp