fs/bad_inode.c 64bit fix
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / bad_inode.c
blob9f24a4738b00b2deb9171c9d053c31bd07829fcf
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>
17 #include <linux/poll.h>
20 static loff_t bad_file_llseek(struct file *file, loff_t offset, int origin)
22 return -EIO;
25 static ssize_t bad_file_read(struct file *filp, char __user *buf,
26 size_t size, loff_t *ppos)
28 return -EIO;
31 static ssize_t bad_file_write(struct file *filp, const char __user *buf,
32 size_t siz, loff_t *ppos)
34 return -EIO;
37 static ssize_t bad_file_aio_read(struct kiocb *iocb, char __user *buf,
38 size_t siz, loff_t pos)
40 return -EIO;
43 static ssize_t bad_file_aio_write(struct kiocb *iocb, const char __user *buf,
44 size_t siz, loff_t pos)
46 return -EIO;
49 static int bad_file_readdir(struct file *filp, void *dirent, filldir_t filldir)
51 return -EIO;
54 static unsigned int bad_file_poll(struct file *filp, poll_table *wait)
56 return POLLERR;
59 static int bad_file_ioctl (struct inode *inode, struct file *filp,
60 unsigned int cmd, unsigned long arg)
62 return -EIO;
65 static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd,
66 unsigned long arg)
68 return -EIO;
71 static long bad_file_compat_ioctl(struct file *file, unsigned int cmd,
72 unsigned long arg)
74 return -EIO;
77 static int bad_file_mmap(struct file *file, struct vm_area_struct *vma)
79 return -EIO;
82 static int bad_file_open(struct inode *inode, struct file *filp)
84 return -EIO;
87 static int bad_file_flush(struct file *file)
89 return -EIO;
92 static int bad_file_release(struct inode *inode, struct file *filp)
94 return -EIO;
97 static int bad_file_fsync(struct file *file, struct dentry *dentry,
98 int datasync)
100 return -EIO;
103 static int bad_file_aio_fsync(struct kiocb *iocb, int datasync)
105 return -EIO;
108 static int bad_file_fasync(int fd, struct file *filp, int on)
110 return -EIO;
113 static int bad_file_lock(struct file *file, int cmd, struct file_lock *fl)
115 return -EIO;
118 static ssize_t bad_file_readv(struct file *file, const struct iovec *iv,
119 unsigned long count, loff_t *pos)
121 return -EIO;
124 static ssize_t bad_file_writev(struct file *file, const struct iovec *iv,
125 unsigned long count, loff_t *pos)
127 return -EIO;
130 static ssize_t bad_file_sendfile(struct file *in_file, loff_t *ppos,
131 size_t count, read_actor_t actor, void *target)
133 return -EIO;
136 static ssize_t bad_file_sendpage(struct file *file, struct page *page,
137 int off, size_t len, loff_t *pos, int more)
139 return -EIO;
142 static unsigned long bad_file_get_unmapped_area(struct file *file,
143 unsigned long addr, unsigned long len,
144 unsigned long pgoff, unsigned long flags)
146 return -EIO;
149 static int bad_file_check_flags(int flags)
151 return -EIO;
154 static int bad_file_dir_notify(struct file *file, unsigned long arg)
156 return -EIO;
159 static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl)
161 return -EIO;
164 static struct file_operations bad_file_ops =
166 .llseek = bad_file_llseek,
167 .read = bad_file_read,
168 .write = bad_file_write,
169 .aio_read = bad_file_aio_read,
170 .aio_write = bad_file_aio_write,
171 .readdir = bad_file_readdir,
172 .poll = bad_file_poll,
173 .ioctl = bad_file_ioctl,
174 .unlocked_ioctl = bad_file_unlocked_ioctl,
175 .compat_ioctl = bad_file_compat_ioctl,
176 .mmap = bad_file_mmap,
177 .open = bad_file_open,
178 .flush = bad_file_flush,
179 .release = bad_file_release,
180 .fsync = bad_file_fsync,
181 .aio_fsync = bad_file_aio_fsync,
182 .fasync = bad_file_fasync,
183 .lock = bad_file_lock,
184 .readv = bad_file_readv,
185 .writev = bad_file_writev,
186 .sendfile = bad_file_sendfile,
187 .sendpage = bad_file_sendpage,
188 .get_unmapped_area = bad_file_get_unmapped_area,
189 .check_flags = bad_file_check_flags,
190 .dir_notify = bad_file_dir_notify,
191 .flock = bad_file_flock,
194 static int bad_inode_create (struct inode *dir, struct dentry *dentry,
195 int mode, struct nameidata *nd)
197 return -EIO;
200 static struct dentry *bad_inode_lookup(struct inode *dir,
201 struct dentry *dentry, struct nameidata *nd)
203 return ERR_PTR(-EIO);
206 static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,
207 struct dentry *dentry)
209 return -EIO;
212 static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
214 return -EIO;
217 static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,
218 const char *symname)
220 return -EIO;
223 static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,
224 int mode)
226 return -EIO;
229 static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
231 return -EIO;
234 static int bad_inode_mknod (struct inode *dir, struct dentry *dentry,
235 int mode, dev_t rdev)
237 return -EIO;
240 static int bad_inode_rename (struct inode *old_dir, struct dentry *old_dentry,
241 struct inode *new_dir, struct dentry *new_dentry)
243 return -EIO;
246 static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
247 int buflen)
249 return -EIO;
252 static int bad_inode_permission(struct inode *inode, int mask,
253 struct nameidata *nd)
255 return -EIO;
258 static int bad_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
259 struct kstat *stat)
261 return -EIO;
264 static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)
266 return -EIO;
269 static int bad_inode_setxattr(struct dentry *dentry, const char *name,
270 const void *value, size_t size, int flags)
272 return -EIO;
275 static ssize_t bad_inode_getxattr(struct dentry *dentry, const char *name,
276 void *buffer, size_t size)
278 return -EIO;
281 static ssize_t bad_inode_listxattr(struct dentry *dentry, char *buffer,
282 size_t buffer_size)
284 return -EIO;
287 static int bad_inode_removexattr(struct dentry *dentry, const char *name)
289 return -EIO;
292 static struct inode_operations bad_inode_ops =
294 .create = bad_inode_create,
295 .lookup = bad_inode_lookup,
296 .link = bad_inode_link,
297 .unlink = bad_inode_unlink,
298 .symlink = bad_inode_symlink,
299 .mkdir = bad_inode_mkdir,
300 .rmdir = bad_inode_rmdir,
301 .mknod = bad_inode_mknod,
302 .rename = bad_inode_rename,
303 .readlink = bad_inode_readlink,
304 /* follow_link must be no-op, otherwise unmounting this inode
305 won't work */
306 /* put_link returns void */
307 /* truncate returns void */
308 .permission = bad_inode_permission,
309 .getattr = bad_inode_getattr,
310 .setattr = bad_inode_setattr,
311 .setxattr = bad_inode_setxattr,
312 .getxattr = bad_inode_getxattr,
313 .listxattr = bad_inode_listxattr,
314 .removexattr = bad_inode_removexattr,
315 /* truncate_range returns void */
320 * When a filesystem is unable to read an inode due to an I/O error in
321 * its read_inode() function, it can call make_bad_inode() to return a
322 * set of stubs which will return EIO errors as required.
324 * We only need to do limited initialisation: all other fields are
325 * preinitialised to zero automatically.
329 * make_bad_inode - mark an inode bad due to an I/O error
330 * @inode: Inode to mark bad
332 * When an inode cannot be read due to a media or remote network
333 * failure this function makes the inode "bad" and causes I/O operations
334 * on it to fail from this point on.
337 void make_bad_inode(struct inode *inode)
339 remove_inode_hash(inode);
341 inode->i_mode = S_IFREG;
342 inode->i_atime = inode->i_mtime = inode->i_ctime =
343 current_fs_time(inode->i_sb);
344 inode->i_op = &bad_inode_ops;
345 inode->i_fop = &bad_file_ops;
347 EXPORT_SYMBOL(make_bad_inode);
350 * This tests whether an inode has been flagged as bad. The test uses
351 * &bad_inode_ops to cover the case of invalidated inodes as well as
352 * those created by make_bad_inode() above.
356 * is_bad_inode - is an inode errored
357 * @inode: inode to test
359 * Returns true if the inode in question has been marked as bad.
362 int is_bad_inode(struct inode *inode)
364 return (inode->i_op == &bad_inode_ops);
367 EXPORT_SYMBOL(is_bad_inode);