This source file includes following definitions.
- bad_file_open
- bad_inode_create
- bad_inode_lookup
- bad_inode_link
- bad_inode_unlink
- bad_inode_symlink
- bad_inode_mkdir
- bad_inode_rmdir
- bad_inode_mknod
- bad_inode_rename2
- bad_inode_readlink
- bad_inode_permission
- bad_inode_getattr
- bad_inode_setattr
- bad_inode_listxattr
- bad_inode_get_link
- bad_inode_get_acl
- bad_inode_fiemap
- bad_inode_update_time
- bad_inode_atomic_open
- bad_inode_tmpfile
- bad_inode_set_acl
- make_bad_inode
- is_bad_inode
- iget_failed
1
2
3
4
5
6
7
8
9
10
11
12 #include <linux/fs.h>
13 #include <linux/export.h>
14 #include <linux/stat.h>
15 #include <linux/time.h>
16 #include <linux/namei.h>
17 #include <linux/poll.h>
18
19 static int bad_file_open(struct inode *inode, struct file *filp)
20 {
21 return -EIO;
22 }
23
24 static const struct file_operations bad_file_ops =
25 {
26 .open = bad_file_open,
27 };
28
29 static int bad_inode_create (struct inode *dir, struct dentry *dentry,
30 umode_t mode, bool excl)
31 {
32 return -EIO;
33 }
34
35 static struct dentry *bad_inode_lookup(struct inode *dir,
36 struct dentry *dentry, unsigned int flags)
37 {
38 return ERR_PTR(-EIO);
39 }
40
41 static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,
42 struct dentry *dentry)
43 {
44 return -EIO;
45 }
46
47 static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
48 {
49 return -EIO;
50 }
51
52 static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,
53 const char *symname)
54 {
55 return -EIO;
56 }
57
58 static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,
59 umode_t mode)
60 {
61 return -EIO;
62 }
63
64 static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
65 {
66 return -EIO;
67 }
68
69 static int bad_inode_mknod (struct inode *dir, struct dentry *dentry,
70 umode_t mode, dev_t rdev)
71 {
72 return -EIO;
73 }
74
75 static int bad_inode_rename2(struct inode *old_dir, struct dentry *old_dentry,
76 struct inode *new_dir, struct dentry *new_dentry,
77 unsigned int flags)
78 {
79 return -EIO;
80 }
81
82 static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
83 int buflen)
84 {
85 return -EIO;
86 }
87
88 static int bad_inode_permission(struct inode *inode, int mask)
89 {
90 return -EIO;
91 }
92
93 static int bad_inode_getattr(const struct path *path, struct kstat *stat,
94 u32 request_mask, unsigned int query_flags)
95 {
96 return -EIO;
97 }
98
99 static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)
100 {
101 return -EIO;
102 }
103
104 static ssize_t bad_inode_listxattr(struct dentry *dentry, char *buffer,
105 size_t buffer_size)
106 {
107 return -EIO;
108 }
109
110 static const char *bad_inode_get_link(struct dentry *dentry,
111 struct inode *inode,
112 struct delayed_call *done)
113 {
114 return ERR_PTR(-EIO);
115 }
116
117 static struct posix_acl *bad_inode_get_acl(struct inode *inode, int type)
118 {
119 return ERR_PTR(-EIO);
120 }
121
122 static int bad_inode_fiemap(struct inode *inode,
123 struct fiemap_extent_info *fieinfo, u64 start,
124 u64 len)
125 {
126 return -EIO;
127 }
128
129 static int bad_inode_update_time(struct inode *inode, struct timespec64 *time,
130 int flags)
131 {
132 return -EIO;
133 }
134
135 static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,
136 struct file *file, unsigned int open_flag,
137 umode_t create_mode)
138 {
139 return -EIO;
140 }
141
142 static int bad_inode_tmpfile(struct inode *inode, struct dentry *dentry,
143 umode_t mode)
144 {
145 return -EIO;
146 }
147
148 static int bad_inode_set_acl(struct inode *inode, struct posix_acl *acl,
149 int type)
150 {
151 return -EIO;
152 }
153
154 static const struct inode_operations bad_inode_ops =
155 {
156 .create = bad_inode_create,
157 .lookup = bad_inode_lookup,
158 .link = bad_inode_link,
159 .unlink = bad_inode_unlink,
160 .symlink = bad_inode_symlink,
161 .mkdir = bad_inode_mkdir,
162 .rmdir = bad_inode_rmdir,
163 .mknod = bad_inode_mknod,
164 .rename = bad_inode_rename2,
165 .readlink = bad_inode_readlink,
166 .permission = bad_inode_permission,
167 .getattr = bad_inode_getattr,
168 .setattr = bad_inode_setattr,
169 .listxattr = bad_inode_listxattr,
170 .get_link = bad_inode_get_link,
171 .get_acl = bad_inode_get_acl,
172 .fiemap = bad_inode_fiemap,
173 .update_time = bad_inode_update_time,
174 .atomic_open = bad_inode_atomic_open,
175 .tmpfile = bad_inode_tmpfile,
176 .set_acl = bad_inode_set_acl,
177 };
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198 void make_bad_inode(struct inode *inode)
199 {
200 remove_inode_hash(inode);
201
202 inode->i_mode = S_IFREG;
203 inode->i_atime = inode->i_mtime = inode->i_ctime =
204 current_time(inode);
205 inode->i_op = &bad_inode_ops;
206 inode->i_opflags &= ~IOP_XATTR;
207 inode->i_fop = &bad_file_ops;
208 }
209 EXPORT_SYMBOL(make_bad_inode);
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224 bool is_bad_inode(struct inode *inode)
225 {
226 return (inode->i_op == &bad_inode_ops);
227 }
228
229 EXPORT_SYMBOL(is_bad_inode);
230
231
232
233
234
235
236
237 void iget_failed(struct inode *inode)
238 {
239 make_bad_inode(inode);
240 unlock_new_inode(inode);
241 iput(inode);
242 }
243 EXPORT_SYMBOL(iget_failed);