Messages in this thread Patch in this message | | | Date | Wed, 17 Sep 1997 14:14:45 -0400 | From | Bill Hawes <> | Subject | patch to add bad_inode to 2.1.56 |
| |
I've made a slightly modifed version of Stephen Tweedie's bad_inode code from 2.0.31 to use in 2.1.56. I'm using this to solve the "inode changing modes" problem in smbfs, and it will also be applicable to nfs client for the same purpose.
As far as I can tell, follow_link is the only i_op function with a required cleanup operation on its arguments; the others can just bail out with an -EIO return.
Regards, Bill--- linux-2.1.56/fs/bad_inode.c.old Wed Sep 17 13:49:24 1997 +++ linux-2.1.56/fs/bad_inode.c Wed Sep 17 11:16:28 1997 @@ -0,0 +1,88 @@ +/* + * linux/fs/bad_inode.c + * + * Copyright (C) 1997, Stephen Tweedie + * + * Provide stub functions for unreadable inodes + */ + +#include <linux/fs.h> +#include <linux/stat.h> +#include <linux/sched.h> + +/* + * The follow_symlink operation must dput() the base. + */ +static struct dentry * bad_follow_link(struct inode * ino, struct dentry *base) +{ + dput(base); + return ERR_PTR(-EIO); +} + +static int return_EIO() +{ + return -EIO; +} + +#define EIO_ERROR ((void *) (return_EIO)) + +static struct file_operations bad_file_ops = +{ + EIO_ERROR, /* lseek */ + EIO_ERROR, /* read */ + EIO_ERROR, /* write */ + EIO_ERROR, /* readdir */ + EIO_ERROR, /* select */ + EIO_ERROR, /* ioctl */ + EIO_ERROR, /* mmap */ + EIO_ERROR, /* open */ + EIO_ERROR, /* release */ + EIO_ERROR, /* fsync */ + EIO_ERROR, /* fasync */ + EIO_ERROR, /* check_media_change */ + EIO_ERROR /* revalidate */ +}; + +struct inode_operations bad_inode_ops = +{ + &bad_file_ops, /* default file operations */ + EIO_ERROR, /* create */ + EIO_ERROR, /* lookup */ + EIO_ERROR, /* link */ + EIO_ERROR, /* unlink */ + EIO_ERROR, /* symlink */ + EIO_ERROR, /* mkdir */ + EIO_ERROR, /* rmdir */ + EIO_ERROR, /* mknod */ + EIO_ERROR, /* rename */ + EIO_ERROR, /* readlink */ + bad_follow_link, /* follow_link */ + EIO_ERROR, /* readpage */ + EIO_ERROR, /* writepage */ + EIO_ERROR, /* bmap */ + EIO_ERROR, /* truncate */ + EIO_ERROR, /* permission */ + EIO_ERROR /* smap */ +}; + + +/* + * When a filesystem is unable to read an inode due to an I/O error in + * its read_inode() function, it can call make_bad_inode() to return a + * set of stubs which will return EIO errors as required. + * + * We only need to do limited initialisation: all other fields are + * preinitialised to zero automatically. + */ +void make_bad_inode(struct inode * inode) +{ + inode->i_mode = S_IFREG; +#if 0 + inode->i_flags = S_BAD_INODE; +#endif + inode->i_atime = CURRENT_TIME; + inode->i_mtime = CURRENT_TIME; + inode->i_ctime = CURRENT_TIME; + inode->i_op = &bad_inode_ops; +} + --- linux-2.1.56/fs/Makefile.old Sat Jul 19 08:11:58 1997 +++ linux-2.1.56/fs/Makefile Wed Sep 17 10:57:28 1997 @@ -13,7 +13,7 @@ O_OBJS = open.o read_write.o devices.o file_table.o buffer.o \ super.o block_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ ioctl.o readdir.o select.o fifo.o locks.o filesystems.o \ - inode.o dcache.o attr.o $(BINFMTS) + inode.o dcache.o attr.o bad_inode.o $(BINFMTS) MOD_LIST_NAME := FS_MODULES ALL_SUB_DIRS = minix ext2 fat msdos vfat proc isofs nfs umsdos \ | |