forked from rubenslte/android_kernel_samsung_msm8226
new helpers: fdget()/fdput()
Signed-off-bs: Al Viro <viro@zeniv.linux.org.uk> Issue: SEC-2677 [Backport: move up declaration of fget_raw_light to before it's used.] Change-Id: I52cd7555021d13f9c73481ea9a4f2562190524ec (cherry picked from commit a5b470ba06aa3f96999ede5feba178df6bdb134a)
This commit is contained in:
committed by
Francescodario Cuzzocrea
parent
5064b71d09
commit
e1b124fb2e
@@ -26,10 +26,36 @@ static inline void fput_light(struct file *file, int fput_needed)
|
|||||||
fput(file);
|
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(unsigned int fd);
|
||||||
extern struct file *fget_light(unsigned int fd, int *fput_needed);
|
extern struct file *fget_light(unsigned int fd, int *fput_needed);
|
||||||
extern struct file *fget_raw(unsigned int fd);
|
extern struct file *fget_raw(unsigned int fd);
|
||||||
extern struct file *fget_raw_light(unsigned int fd, int *fput_needed);
|
extern struct file *fget_raw_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 void set_close_on_exec(unsigned int fd, int flag);
|
extern void set_close_on_exec(unsigned int fd, int flag);
|
||||||
extern void put_filp(struct file *);
|
extern void put_filp(struct file *);
|
||||||
extern int alloc_fd(unsigned start, unsigned flags);
|
extern int alloc_fd(unsigned start, unsigned flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user