[PATCH] ioremap balanced with iounmap for drivers/serial/ioc4_serial.c
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / bad_inode.c
blob34e6d7b220c322b9399c32a701fe4910c256946f
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/smp_lock.h>
16 #include <linux/namei.h>
18 static int return_EIO(void)
20 return -EIO;
23 #define EIO_ERROR ((void *) (return_EIO))
25 static const struct file_operations bad_file_ops =
27 .llseek = EIO_ERROR,
28 .aio_read = EIO_ERROR,
29 .read = EIO_ERROR,
30 .write = EIO_ERROR,
31 .aio_write = EIO_ERROR,
32 .readdir = EIO_ERROR,
33 .poll = EIO_ERROR,
34 .ioctl = EIO_ERROR,
35 .mmap = EIO_ERROR,
36 .open = EIO_ERROR,
37 .flush = EIO_ERROR,
38 .release = EIO_ERROR,
39 .fsync = EIO_ERROR,
40 .aio_fsync = EIO_ERROR,
41 .fasync = EIO_ERROR,
42 .lock = EIO_ERROR,
43 .sendfile = EIO_ERROR,
44 .sendpage = EIO_ERROR,
45 .get_unmapped_area = EIO_ERROR,
48 static struct inode_operations bad_inode_ops =
50 .create = EIO_ERROR,
51 .lookup = EIO_ERROR,
52 .link = EIO_ERROR,
53 .unlink = EIO_ERROR,
54 .symlink = EIO_ERROR,
55 .mkdir = EIO_ERROR,
56 .rmdir = EIO_ERROR,
57 .mknod = EIO_ERROR,
58 .rename = EIO_ERROR,
59 .readlink = EIO_ERROR,
60 /* follow_link must be no-op, otherwise unmounting this inode
61 won't work */
62 .truncate = EIO_ERROR,
63 .permission = EIO_ERROR,
64 .getattr = EIO_ERROR,
65 .setattr = EIO_ERROR,
66 .setxattr = EIO_ERROR,
67 .getxattr = EIO_ERROR,
68 .listxattr = EIO_ERROR,
69 .removexattr = EIO_ERROR,
74 * When a filesystem is unable to read an inode due to an I/O error in
75 * its read_inode() function, it can call make_bad_inode() to return a
76 * set of stubs which will return EIO errors as required.
78 * We only need to do limited initialisation: all other fields are
79 * preinitialised to zero automatically.
82 /**
83 * make_bad_inode - mark an inode bad due to an I/O error
84 * @inode: Inode to mark bad
86 * When an inode cannot be read due to a media or remote network
87 * failure this function makes the inode "bad" and causes I/O operations
88 * on it to fail from this point on.
91 void make_bad_inode(struct inode * inode)
93 remove_inode_hash(inode);
95 inode->i_mode = S_IFREG;
96 inode->i_atime = inode->i_mtime = inode->i_ctime =
97 current_fs_time(inode->i_sb);
98 inode->i_op = &bad_inode_ops;
99 inode->i_fop = &bad_file_ops;
101 EXPORT_SYMBOL(make_bad_inode);
104 * This tests whether an inode has been flagged as bad. The test uses
105 * &bad_inode_ops to cover the case of invalidated inodes as well as
106 * those created by make_bad_inode() above.
110 * is_bad_inode - is an inode errored
111 * @inode: inode to test
113 * Returns true if the inode in question has been marked as bad.
116 int is_bad_inode(struct inode * inode)
118 return (inode->i_op == &bad_inode_ops);
121 EXPORT_SYMBOL(is_bad_inode);