4 * Copyright (C) 1997, Stephen Tweedie
6 * Provide stub functions for unreadable inodes
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
)
24 static int return_EIO(void)
29 #define EIO_ERROR ((void *) (return_EIO))
31 static struct file_operations bad_file_ops
=
48 struct inode_operations bad_inode_ops
=
50 &bad_file_ops
, /* default file operations */
51 EIO_ERROR
, /* create */
52 EIO_ERROR
, /* lookup */
54 EIO_ERROR
, /* unlink */
55 EIO_ERROR
, /* symlink */
56 EIO_ERROR
, /* mkdir */
57 EIO_ERROR
, /* rmdir */
58 EIO_ERROR
, /* mknod */
59 EIO_ERROR
, /* rename */
60 EIO_ERROR
, /* readlink */
61 bad_follow_link
, /* follow_link */
62 EIO_ERROR
, /* truncate */
63 EIO_ERROR
, /* permission */
64 EIO_ERROR
/* revalidate */
69 * When a filesystem is unable to read an inode due to an I/O error in
70 * its read_inode() function, it can call make_bad_inode() to return a
71 * set of stubs which will return EIO errors as required.
73 * We only need to do limited initialisation: all other fields are
74 * preinitialised to zero automatically.
76 void make_bad_inode(struct inode
* inode
)
78 inode
->i_mode
= S_IFREG
;
79 inode
->i_atime
= inode
->i_mtime
= inode
->i_ctime
= CURRENT_TIME
;
80 inode
->i_op
= &bad_inode_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
);