diff options
Diffstat (limited to 'include/linux/file.h')
-rw-r--r-- | include/linux/file.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/include/linux/file.h b/include/linux/file.h index cbacf4faf447..4d69123377a2 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -28,33 +28,36 @@ static inline void fput_light(struct file *file, int fput_needed) | |||
28 | 28 | ||
29 | struct fd { | 29 | struct fd { |
30 | struct file *file; | 30 | struct file *file; |
31 | int need_put; | 31 | unsigned int flags; |
32 | }; | 32 | }; |
33 | #define FDPUT_FPUT 1 | ||
34 | #define FDPUT_POS_UNLOCK 2 | ||
33 | 35 | ||
34 | static inline void fdput(struct fd fd) | 36 | static inline void fdput(struct fd fd) |
35 | { | 37 | { |
36 | if (fd.need_put) | 38 | if (fd.flags & FDPUT_FPUT) |
37 | fput(fd.file); | 39 | fput(fd.file); |
38 | } | 40 | } |
39 | 41 | ||
40 | extern struct file *fget(unsigned int fd); | 42 | extern struct file *fget(unsigned int fd); |
41 | extern struct file *fget_light(unsigned int fd, int *fput_needed); | 43 | extern struct file *fget_raw(unsigned int fd); |
44 | extern unsigned long __fdget(unsigned int fd); | ||
45 | extern unsigned long __fdget_raw(unsigned int fd); | ||
46 | extern unsigned long __fdget_pos(unsigned int fd); | ||
42 | 47 | ||
43 | static inline struct fd fdget(unsigned int fd) | 48 | static inline struct fd __to_fd(unsigned long v) |
44 | { | 49 | { |
45 | int b; | 50 | return (struct fd){(struct file *)(v & ~3),v & 3}; |
46 | struct file *f = fget_light(fd, &b); | ||
47 | return (struct fd){f,b}; | ||
48 | } | 51 | } |
49 | 52 | ||
50 | extern struct file *fget_raw(unsigned int fd); | 53 | static inline struct fd fdget(unsigned int fd) |
51 | extern struct file *fget_raw_light(unsigned int fd, int *fput_needed); | 54 | { |
55 | return __to_fd(__fdget(fd)); | ||
56 | } | ||
52 | 57 | ||
53 | static inline struct fd fdget_raw(unsigned int fd) | 58 | static inline struct fd fdget_raw(unsigned int fd) |
54 | { | 59 | { |
55 | int b; | 60 | return __to_fd(__fdget_raw(fd)); |
56 | struct file *f = fget_raw_light(fd, &b); | ||
57 | return (struct fd){f,b}; | ||
58 | } | 61 | } |
59 | 62 | ||
60 | extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); | 63 | extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); |