1
2
3
4
5
6
7
8
9#include <linux/fs.h>
10#include <linux/stat.h>
11#include <linux/sched.h>
12
13
14
15
16
17
18static int bad_follow_link(struct dentry *dent, struct nameidata *nd)
19{
20 return vfs_follow_link(nd, ERR_PTR(-EIO));
21}
22
23static int return_EIO(void)
24{
25 return -EIO;
26}
27
28#define EIO_ERROR ((void *) (return_EIO))
29
30static struct file_operations bad_file_ops =
31{
32 llseek: EIO_ERROR,
33 read: EIO_ERROR,
34 write: EIO_ERROR,
35 readdir: EIO_ERROR,
36 poll: EIO_ERROR,
37 ioctl: EIO_ERROR,
38 mmap: EIO_ERROR,
39 open: EIO_ERROR,
40 flush: EIO_ERROR,
41 release: EIO_ERROR,
42 fsync: EIO_ERROR,
43 fasync: EIO_ERROR,
44 lock: EIO_ERROR,
45};
46
47struct inode_operations bad_inode_ops =
48{
49 create: EIO_ERROR,
50 lookup: EIO_ERROR,
51 link: EIO_ERROR,
52 unlink: EIO_ERROR,
53 symlink: EIO_ERROR,
54 mkdir: EIO_ERROR,
55 rmdir: EIO_ERROR,
56 mknod: EIO_ERROR,
57 rename: EIO_ERROR,
58 readlink: EIO_ERROR,
59 follow_link: bad_follow_link,
60 truncate: EIO_ERROR,
61 permission: EIO_ERROR,
62 revalidate: EIO_ERROR,
63};
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84void make_bad_inode(struct inode * inode)
85{
86 inode->i_mode = S_IFREG;
87 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
88 inode->i_op = &bad_inode_ops;
89 inode->i_fop = &bad_file_ops;
90}
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105int is_bad_inode(struct inode * inode)
106{
107 return (inode->i_op == &bad_inode_ops);
108}
109