diff options
-rw-r--r-- | include/linux/file.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/file.h b/include/linux/file.h index 6eee54aea279..c38bfbff4647 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -26,8 +26,34 @@ static inline void fput_light(struct file *file, int fput_needed) | |||
26 | fput(file); | 26 | fput(file); |
27 | } | 27 | } |
28 | 28 | ||
29 | struct fd { | ||
30 | struct file *file; | ||
31 | int need_put; | ||
32 | }; | ||
33 | |||
34 | static inline void fdput(struct fd fd) | ||
35 | { | ||
36 | if (fd.need_put) | ||
37 | fput(fd.file); | ||
38 | } | ||
39 | |||
29 | extern struct file *fget(unsigned int fd); | 40 | extern struct file *fget(unsigned int fd); |
30 | extern struct file *fget_light(unsigned int fd, int *fput_needed); | 41 | extern struct file *fget_light(unsigned int fd, int *fput_needed); |
42 | |||
43 | static inline struct fd fdget(unsigned int fd) | ||
44 | { | ||
45 | int b; | ||
46 | struct file *f = fget_light(fd, &b); | ||
47 | return (struct fd){f,b}; | ||
48 | } | ||
49 | |||
50 | static inline struct fd fdget_raw(unsigned int fd) | ||
51 | { | ||
52 | int b; | ||
53 | struct file *f = fget_raw_light(fd, &b); | ||
54 | return (struct fd){f,b}; | ||
55 | } | ||
56 | |||
31 | extern struct file *fget_raw(unsigned int fd); | 57 | extern struct file *fget_raw(unsigned int fd); |
32 | extern struct file *fget_raw_light(unsigned int fd, int *fput_needed); | 58 | extern struct file *fget_raw_light(unsigned int fd, int *fput_needed); |
33 | extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); | 59 | extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); |