m68k: kill page walker compile warning
[wrt350n-kernel.git] / fs / bad_inode.c
blobf1c2ea8342f514c974539dd5a676b650efbf6e5f
1 /*
2 * linux/fs/bad_inode.c
4 * Copyright (C) 1997, Stephen Tweedie
6 * Provide stub functions for unreadable inodes
8 * Fabian Frederick : August 2003 - All file operations assigned to EIO
9 */
11 #include <linux/fs.h>
12 #include <linux/module.h>
13 #include <linux/stat.h>
14 #include <linux/time.h>
15 #include <linux/namei.h>
16 #include <linux/poll.h>
19 static loff_t bad_file_llseek(struct file *file, loff_t offset, int origin)
21 return -EIO;
24 static ssize_t bad_file_read(struct file *filp, char __user *buf,
25 size_t size, loff_t *ppos)
27 return -EIO;
30 static ssize_t bad_file_write(struct file *filp, const char __user *buf,
31 size_t siz, loff_t *ppos)
33 return -EIO;
36 static ssize_t bad_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
37 unsigned long nr_segs, loff_t pos)
39 return -EIO;
42 static ssize_t bad_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
43 unsigned long nr_segs, loff_t pos)
45 return -EIO;
48 static int bad_file_readdir(struct file *filp, void *dirent, filldir_t filldir)
50 return -EIO;
53 static unsigned int bad_file_poll(struct file *filp, poll_table *wait)
55 return POLLERR;
58 static int bad_file_ioctl (struct inode *inode, struct file *filp,
59 unsigned int cmd, unsigned long arg)
61 return -EIO;
64 static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd,
65 unsigned long arg)
67 return -EIO;
70 static long bad_file_compat_ioctl(struct file *file, unsigned int cmd,
71 unsigned long arg)
73 return -EIO;
76 static int bad_file_mmap(struct file *file, struct vm_area_struct *vma)
78 return -EIO;
81 static int bad_file_open(struct inode *inode, struct file *filp)
83 return -EIO;
86 static int bad_file_flush(struct file *file, fl_owner_t id)
88 return -EIO;
91 static int bad_file_release(struct inode *inode, struct file *filp)
93 return -EIO;
96 static int bad_file_fsync(struct file *file, struct dentry *dentry,
97 int datasync)
99 return -EIO;
102 static int bad_file_aio_fsync(struct kiocb *iocb, int datasync)
104 return -EIO;
107 static int bad_file_fasync(int fd, struct file *filp, int on)
109 return -EIO;
112 static int bad_file_lock(struct file *file, int cmd, struct file_lock *fl)
114 return -EIO;
117 static ssize_t bad_file_sendpage(struct file *file, struct page *page,
118 int off, size_t len, loff_t *pos, int more)
120 return -EIO;
123 static unsigned long bad_file_get_unmapped_area(struct file *file,
124 unsigned long addr, unsigned long len,
125 unsigned long pgoff, unsigned long flags)
127 return -EIO;
130 static int bad_file_check_flags(int flags)
132 return -EIO;
135 static int bad_file_dir_notify(struct file *file, unsigned long arg)
137 return -EIO;
140 static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl)
142 return -EIO;
145 static ssize_t bad_file_splice_write(struct pipe_inode_info *pipe,
146 struct file *out, loff_t *ppos, size_t len,
147 unsigned int flags)
149 return -EIO;
152 static ssize_t bad_file_splice_read(struct file *in, loff_t *ppos,
153 struct pipe_inode_info *pipe, size_t len,
154 unsigned int flags)
156 return -EIO;
159 static const struct file_operations bad_file_ops =
161 .llseek = bad_file_llseek,
162 .read = bad_file_read,
163 .write = bad_file_write,
164 .aio_read = bad_file_aio_read,
165 .aio_write = bad_file_aio_write,
166 .readdir = bad_file_readdir,
167 .poll = bad_file_poll,
168 .ioctl = bad_file_ioctl,
169 .unlocked_ioctl = bad_file_unlocked_ioctl,
170 .compat_ioctl = bad_file_compat_ioctl,
171 .mmap = bad_file_mmap,
172 .open = bad_file_open,
173 .flush = bad_file_flush,
174 .release = bad_file_release,
175 .fsync = bad_file_fsync,
176 .aio_fsync = bad_file_aio_fsync,
177 .fasync = bad_file_fasync,
178 .lock = bad_file_lock,
179 .sendpage = bad_file_sendpage,
180 .get_unmapped_area = bad_file_get_unmapped_area,
181 .check_flags = bad_file_check_flags,
182 .dir_notify = bad_file_dir_notify,
183 .flock = bad_file_flock,
184 .splice_write = bad_file_splice_write,
185 .splice_read = bad_file_splice_read,
188 static int bad_inode_create (struct inode *dir, struct dentry *dentry,
189 int mode, struct nameidata *nd)
191 return -EIO;
194 static struct dentry *bad_inode_lookup(struct inode *dir,
195 struct dentry *dentry, struct nameidata *nd)
197 return ERR_PTR(-EIO);
200 static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,
201 struct dentry *dentry)
203 return -EIO;
206 static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
208 return -EIO;
211 static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,
212 const char *symname)
214 return -EIO;
217 static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,
218 int mode)
220 return -EIO;
223 static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
225 return -EIO;
228 static int bad_inode_mknod (struct inode *dir, struct dentry *dentry,
229 int mode, dev_t rdev)
231 return -EIO;
234 static int bad_inode_rename (struct inode *old_dir, struct dentry *old_dentry,
235 struct inode *new_dir, struct dentry *new_dentry)
237 return -EIO;
240 static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
241 int buflen)
243 return -EIO;
246 static int bad_inode_permission(struct inode *inode, int mask,
247 struct nameidata *nd)
249 return -EIO;
252 static int bad_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
253 struct kstat *stat)
255 return -EIO;
258 static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)
260 return -EIO;
263 static int bad_inode_setxattr(struct dentry *dentry, const char *name,
264 const void *value, size_t size, int flags)
266 return -EIO;
269 static ssize_t bad_inode_getxattr(struct dentry *dentry, const char *name,
270 void *buffer, size_t size)
272 return -EIO;
275 static ssize_t bad_inode_listxattr(struct dentry *dentry, char *buffer,
276 size_t buffer_size)
278 return -EIO;
281 static int bad_inode_removexattr(struct dentry *dentry, const char *name)
283 return -EIO;
286 static const struct inode_operations bad_inode_ops =
288 .create = bad_inode_create,
289 .lookup = bad_inode_lookup,
290 .link = bad_inode_link,
291 .unlink = bad_inode_unlink,
292 .symlink = bad_inode_symlink,
293 .mkdir = bad_inode_mkdir,
294 .rmdir = bad_inode_rmdir,
295 .mknod = bad_inode_mknod,
296 .rename = bad_inode_rename,
297 .readlink = bad_inode_readlink,
298 /* follow_link must be no-op, otherwise unmounting this inode
299 won't work */
300 /* put_link returns void */
301 /* truncate returns void */
302 .permission = bad_inode_permission,
303 .getattr = bad_inode_getattr,
304 .setattr = bad_inode_setattr,
305 .setxattr = bad_inode_setxattr,
306 .getxattr = bad_inode_getxattr,
307 .listxattr = bad_inode_listxattr,
308 .removexattr = bad_inode_removexattr,
309 /* truncate_range returns void */
314 * When a filesystem is unable to read an inode due to an I/O error in
315 * its read_inode() function, it can call make_bad_inode() to return a
316 * set of stubs which will return EIO errors as required.
318 * We only need to do limited initialisation: all other fields are
319 * preinitialised to zero automatically.
323 * make_bad_inode - mark an inode bad due to an I/O error
324 * @inode: Inode to mark bad
326 * When an inode cannot be read due to a media or remote network
327 * failure this function makes the inode "bad" and causes I/O operations
328 * on it to fail from this point on.
331 void make_bad_inode(struct inode *inode)
333 remove_inode_hash(inode);
335 inode->i_mode = S_IFREG;
336 inode->i_atime = inode->i_mtime = inode->i_ctime =
337 current_fs_time(inode->i_sb);
338 inode->i_op = &bad_inode_ops;
339 inode->i_fop = &bad_file_ops;
341 EXPORT_SYMBOL(make_bad_inode);
344 * This tests whether an inode has been flagged as bad. The test uses
345 * &bad_inode_ops to cover the case of invalidated inodes as well as
346 * those created by make_bad_inode() above.
350 * is_bad_inode - is an inode errored
351 * @inode: inode to test
353 * Returns true if the inode in question has been marked as bad.
356 int is_bad_inode(struct inode *inode)
358 return (inode->i_op == &bad_inode_ops);
361 EXPORT_SYMBOL(is_bad_inode);
364 * iget_failed - Mark an under-construction inode as dead and release it
365 * @inode: The inode to discard
367 * Mark an under-construction inode as dead and release it.
369 void iget_failed(struct inode *inode)
371 make_bad_inode(inode);
372 unlock_new_inode(inode);
373 iput(inode);
375 EXPORT_SYMBOL(iget_failed);