aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/file.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/file.h')
-rw-r--r--include/linux/file.h27
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
29struct fd { 29struct 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
34static inline void fdput(struct fd fd) 36static 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
40extern struct file *fget(unsigned int fd); 42extern struct file *fget(unsigned int fd);
41extern struct file *fget_light(unsigned int fd, int *fput_needed); 43extern struct file *fget_raw(unsigned int fd);
44extern unsigned long __fdget(unsigned int fd);
45extern unsigned long __fdget_raw(unsigned int fd);
46extern unsigned long __fdget_pos(unsigned int fd);
42 47
43static inline struct fd fdget(unsigned int fd) 48static 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
50extern struct file *fget_raw(unsigned int fd); 53static inline struct fd fdget(unsigned int fd)
51extern struct file *fget_raw_light(unsigned int fd, int *fput_needed); 54{
55 return __to_fd(__fdget(fd));
56}
52 57
53static inline struct fd fdget_raw(unsigned int fd) 58static 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
60extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); 63extern int f_dupfd(unsigned int from, struct file *file, unsigned flags);