Blame view

include/linux/file.h 1.98 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
  /*
   * Wrapper functions for accessing the file_struct fd array.
   */
  
  #ifndef __LINUX_FILE_H
  #define __LINUX_FILE_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
  #include <linux/compiler.h>
0c9e63fd3   Eric Dumazet   [PATCH] Shrinks s...
8
  #include <linux/types.h>
9f3acc314   Al Viro   [PATCH] split lin...
9
  #include <linux/posix_types.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10

9f3acc314   Al Viro   [PATCH] split lin...
11
  struct file;
8b7d91eb7   Christoph Lameter   [PATCH] Move file...
12

b3c975286   Harvey Harrison   include/linux: Re...
13
  extern void fput(struct file *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14

ce8d2cdf3   Dave Hansen   r/o bind mounts: ...
15
16
17
  struct file_operations;
  struct vfsmount;
  struct dentry;
2c48b9c45   Al Viro   switch alloc_file...
18
19
20
  struct path;
  extern struct file *alloc_file(struct path *, fmode_t mode,
  	const struct file_operations *fop);
ce8d2cdf3   Dave Hansen   r/o bind mounts: ...
21

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
  static inline void fput_light(struct file *file, int fput_needed)
  {
c2b3e74b7   Steven Rostedt   fs: Remove unlike...
24
  	if (fput_needed)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
  		fput(file);
  }
a5b470ba0   Al Viro   new helpers: fdge...
27
28
  struct fd {
  	struct file *file;
9c225f265   Linus Torvalds   vfs: atomic f_pos...
29
  	unsigned int flags;
a5b470ba0   Al Viro   new helpers: fdge...
30
  };
9c225f265   Linus Torvalds   vfs: atomic f_pos...
31
32
  #define FDPUT_FPUT       1
  #define FDPUT_POS_UNLOCK 2
a5b470ba0   Al Viro   new helpers: fdge...
33
34
35
  
  static inline void fdput(struct fd fd)
  {
9c225f265   Linus Torvalds   vfs: atomic f_pos...
36
  	if (fd.flags & FDPUT_FPUT)
a5b470ba0   Al Viro   new helpers: fdge...
37
38
  		fput(fd.file);
  }
b3c975286   Harvey Harrison   include/linux: Re...
39
  extern struct file *fget(unsigned int fd);
bd2a31d52   Al Viro   get rid of fget_l...
40
41
42
43
  extern struct file *fget_raw(unsigned int fd);
  extern unsigned long __fdget(unsigned int fd);
  extern unsigned long __fdget_raw(unsigned int fd);
  extern unsigned long __fdget_pos(unsigned int fd);
63b6df141   Al Viro   give readdir(2)/g...
44
  extern void __f_unlock_pos(struct file *);
a5b470ba0   Al Viro   new helpers: fdge...
45

bd2a31d52   Al Viro   get rid of fget_l...
46
  static inline struct fd __to_fd(unsigned long v)
a5b470ba0   Al Viro   new helpers: fdge...
47
  {
bd2a31d52   Al Viro   get rid of fget_l...
48
  	return (struct fd){(struct file *)(v & ~3),v & 3};
a5b470ba0   Al Viro   new helpers: fdge...
49
  }
bd2a31d52   Al Viro   get rid of fget_l...
50
51
52
53
  static inline struct fd fdget(unsigned int fd)
  {
  	return __to_fd(__fdget(fd));
  }
2903ff019   Al Viro   switch simple cas...
54

a5b470ba0   Al Viro   new helpers: fdge...
55
56
  static inline struct fd fdget_raw(unsigned int fd)
  {
bd2a31d52   Al Viro   get rid of fget_l...
57
  	return __to_fd(__fdget_raw(fd));
a5b470ba0   Al Viro   new helpers: fdge...
58
  }
63b6df141   Al Viro   give readdir(2)/g...
59
60
61
62
63
64
65
66
67
68
69
  static inline struct fd fdget_pos(int fd)
  {
  	return __to_fd(__fdget_pos(fd));
  }
  
  static inline void fdput_pos(struct fd f)
  {
  	if (f.flags & FDPUT_POS_UNLOCK)
  		__f_unlock_pos(f.file);
  	fdput(f);
  }
fe17f22d7   Al Viro   take purely descr...
70
  extern int f_dupfd(unsigned int from, struct file *file, unsigned flags);
8280d1617   Al Viro   new helper: repla...
71
  extern int replace_fd(unsigned fd, struct file *file, unsigned flags);
b3c975286   Harvey Harrison   include/linux: Re...
72
  extern void set_close_on_exec(unsigned int fd, int flag);
fe17f22d7   Al Viro   take purely descr...
73
  extern bool get_close_on_exec(unsigned int fd);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74
  extern void put_filp(struct file *);
1a7bd2265   Al Viro   make get_unused_f...
75
  extern int get_unused_fd_flags(unsigned flags);
b3c975286   Harvey Harrison   include/linux: Re...
76
  extern void put_unused_fd(unsigned int fd);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77

b3c975286   Harvey Harrison   include/linux: Re...
78
  extern void fd_install(unsigned int fd, struct file *file);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79

4a9d4b024   Al Viro   switch fput to ta...
80
81
  extern void flush_delayed_fput(void);
  extern void __fput_sync(struct file *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
  #endif /* __LINUX_FILE_H */