From 93aa4fdb14bcab95f591859f287b8b2d6b795031 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 27 Aug 2012 19:55:01 -0400 Subject: [PATCH] --- yaml --- r: 329015 b: refs/heads/master c: a5b470ba06aa3f96999ede5feba178df6bdb134a h: refs/heads/master i: 329013: 28883e448f88a68425dcaa483b8956446f2282ea 329011: 3c140e05511035604d3f02909a449fc4c90050a5 329007: 0023f2c049be0666b78ac6e30b487871010d1f59 v: v3 --- [refs] | 2 +- trunk/include/linux/file.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 85206adc9f7e..60272e48de12 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2a117354b7bdfe13750a64307755e75436fb157a +refs/heads/master: a5b470ba06aa3f96999ede5feba178df6bdb134a diff --git a/trunk/include/linux/file.h b/trunk/include/linux/file.h index 6eee54aea279..c38bfbff4647 100644 --- a/trunk/include/linux/file.h +++ b/trunk/include/linux/file.h @@ -26,8 +26,34 @@ static inline void fput_light(struct file *file, int fput_needed) fput(file); } +struct fd { + struct file *file; + int need_put; +}; + +static inline void fdput(struct fd fd) +{ + if (fd.need_put) + fput(fd.file); +} + extern struct file *fget(unsigned int fd); extern struct file *fget_light(unsigned int fd, int *fput_needed); + +static inline struct fd fdget(unsigned int fd) +{ + int b; + struct file *f = fget_light(fd, &b); + return (struct fd){f,b}; +} + +static inline struct fd fdget_raw(unsigned int fd) +{ + int b; + struct file *f = fget_raw_light(fd, &b); + return (struct fd){f,b}; +} + extern struct file *fget_raw(unsigned int fd); extern struct file *fget_raw_light(unsigned int fd, int *fput_needed); extern int f_dupfd(unsigned int from, struct file *file, unsigned flags);