Fix semaphores in modules.
[linux-2.6/linux-mips.git] / fs / bad_inode.c
blobadb26f415fb90c2de8a0e2544177415c3d325fa2
1 /*
2 * linux/fs/bad_inode.c
4 * Copyright (C) 1997, Stephen Tweedie
6 * Provide stub functions for unreadable inodes
7 */
9 #include <linux/fs.h>
10 #include <linux/stat.h>
11 #include <linux/sched.h>
14 * The follow_link operation is special: it must behave as a no-op
15 * so that a bad root inode can at least be unmounted. To do this
16 * we must dput() the base and return the dentry with a dget().
18 static struct dentry * bad_follow_link(struct dentry *dent, struct dentry *base, unsigned int follow)
20 dput(base);
21 return dget(dent);
24 static int return_EIO(void)
26 return -EIO;
29 #define EIO_ERROR ((void *) (return_EIO))
31 static struct file_operations bad_file_ops =
33 llseek: EIO_ERROR,
34 read: EIO_ERROR,
35 write: EIO_ERROR,
36 readdir: EIO_ERROR,
37 poll: EIO_ERROR,
38 ioctl: EIO_ERROR,
39 mmap: EIO_ERROR,
40 open: EIO_ERROR,
41 flush: EIO_ERROR,
42 release: EIO_ERROR,
43 fsync: EIO_ERROR,
44 fasync: EIO_ERROR,
45 lock: EIO_ERROR,
48 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: bad_follow_link,
61 truncate: EIO_ERROR,
62 permission: EIO_ERROR,
63 revalidate: EIO_ERROR,
67 /*
68 * When a filesystem is unable to read an inode due to an I/O error in
69 * its read_inode() function, it can call make_bad_inode() to return a
70 * set of stubs which will return EIO errors as required.
72 * We only need to do limited initialisation: all other fields are
73 * preinitialised to zero automatically.
75 void make_bad_inode(struct inode * inode)
77 inode->i_mode = S_IFREG;
78 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
79 inode->i_op = &bad_inode_ops;
80 inode->i_fop = &bad_file_ops;
84 * This tests whether an inode has been flagged as bad. The test uses
85 * &bad_inode_ops to cover the case of invalidated inodes as well as
86 * those created by make_bad_inode() above.
88 int is_bad_inode(struct inode * inode)
90 return (inode->i_op == &bad_inode_ops);