Blame view
include/linux/file.h
1.98 KB
1da177e4c
|
1 2 3 4 5 6 |
/* * Wrapper functions for accessing the file_struct fd array. */ #ifndef __LINUX_FILE_H #define __LINUX_FILE_H |
1da177e4c
|
7 |
#include <linux/compiler.h> |
0c9e63fd3
|
8 |
#include <linux/types.h> |
9f3acc314
|
9 |
#include <linux/posix_types.h> |
1da177e4c
|
10 |
|
9f3acc314
|
11 |
struct file; |
8b7d91eb7
|
12 |
|
b3c975286
|
13 |
extern void fput(struct file *); |
1da177e4c
|
14 |
|
ce8d2cdf3
|
15 16 17 |
struct file_operations; struct vfsmount; struct dentry; |
2c48b9c45
|
18 19 20 |
struct path; extern struct file *alloc_file(struct path *, fmode_t mode, const struct file_operations *fop); |
ce8d2cdf3
|
21 |
|
1da177e4c
|
22 23 |
static inline void fput_light(struct file *file, int fput_needed) { |
c2b3e74b7
|
24 |
if (fput_needed) |
1da177e4c
|
25 26 |
fput(file); } |
a5b470ba0
|
27 28 |
struct fd { struct file *file; |
9c225f265
|
29 |
unsigned int flags; |
a5b470ba0
|
30 |
}; |
9c225f265
|
31 32 |
#define FDPUT_FPUT 1 #define FDPUT_POS_UNLOCK 2 |
a5b470ba0
|
33 34 35 |
static inline void fdput(struct fd fd) { |
9c225f265
|
36 |
if (fd.flags & FDPUT_FPUT) |
a5b470ba0
|
37 38 |
fput(fd.file); } |
b3c975286
|
39 |
extern struct file *fget(unsigned int fd); |
bd2a31d52
|
40 41 42 43 |
extern struct file *fget_raw(unsigned int fd); extern unsigned long __fdget(unsigned int fd); extern unsigned long __fdget_raw(unsigned int fd); extern unsigned long __fdget_pos(unsigned int fd); |
63b6df141
|
44 |
extern void __f_unlock_pos(struct file *); |
a5b470ba0
|
45 |
|
bd2a31d52
|
46 |
static inline struct fd __to_fd(unsigned long v) |
a5b470ba0
|
47 |
{ |
bd2a31d52
|
48 |
return (struct fd){(struct file *)(v & ~3),v & 3}; |
a5b470ba0
|
49 |
} |
bd2a31d52
|
50 51 52 53 |
static inline struct fd fdget(unsigned int fd) { return __to_fd(__fdget(fd)); } |
2903ff019
|
54 |
|
a5b470ba0
|
55 56 |
static inline struct fd fdget_raw(unsigned int fd) { |
bd2a31d52
|
57 |
return __to_fd(__fdget_raw(fd)); |
a5b470ba0
|
58 |
} |
63b6df141
|
59 60 61 62 63 64 65 66 67 68 69 |
static inline struct fd fdget_pos(int fd) { return __to_fd(__fdget_pos(fd)); } static inline void fdput_pos(struct fd f) { if (f.flags & FDPUT_POS_UNLOCK) __f_unlock_pos(f.file); fdput(f); } |
fe17f22d7
|
70 |
extern int f_dupfd(unsigned int from, struct file *file, unsigned flags); |
8280d1617
|
71 |
extern int replace_fd(unsigned fd, struct file *file, unsigned flags); |
b3c975286
|
72 |
extern void set_close_on_exec(unsigned int fd, int flag); |
fe17f22d7
|
73 |
extern bool get_close_on_exec(unsigned int fd); |
1da177e4c
|
74 |
extern void put_filp(struct file *); |
1a7bd2265
|
75 |
extern int get_unused_fd_flags(unsigned flags); |
b3c975286
|
76 |
extern void put_unused_fd(unsigned int fd); |
1da177e4c
|
77 |
|
b3c975286
|
78 |
extern void fd_install(unsigned int fd, struct file *file); |
1da177e4c
|
79 |
|
4a9d4b024
|
80 81 |
extern void flush_delayed_fput(void); extern void __fput_sync(struct file *); |
1da177e4c
|
82 |
#endif /* __LINUX_FILE_H */ |