--- zzzz-none-000/linux-2.6.13.1/fs/ramfs/inode.c 2005-09-10 02:42:58.000000000 +0000 +++ ohio-7170-487/linux-2.6.13.1/fs/ramfs/inode.c 2006-03-14 17:38:39.000000000 +0000 @@ -22,11 +22,13 @@ * to keep track of the virtual data: using the VFS * caches is sufficient. */ +#include #include #include #include #include +#include #include #include #include @@ -105,6 +107,7 @@ d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ error = 0; + dir->i_mtime = dir->i_ctime = CURRENT_TIME; } return error; } @@ -142,6 +145,85 @@ return error; } +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +#if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE) + +/*--- #define RAMFS_TRACE ---*/ + +#ifdef RAMFS_TRACE +#define TRACE(s, args...) printk(KERN_NOTICE "RAMFS: "s, ## args) +#else +#define TRACE(s, args...) {} +#endif + +struct dentry *ramfs_get_dentry(struct super_block *sb, void *data) { + + struct dentry *result = 0; + struct inode *inode; + __u32 *fh = data; + + TRACE("[ramfs_get_dentry] sb 0x%p inode %x\n", sb, fh[0]); + + inode = (struct inode *)fh[0]; + TRACE("[ramfs_get_dentry] i_ino %x generation 0x%x 0x%x\n", inode->i_ino, inode->i_generation, fh[2]); + + /*--- if (!inode || (inode->i_ino != fh[1]) || (inode->i_generation != fh[2]) || (inode->i_mtime.tv_sec != fh[3])) { ---*/ + if (!inode || (inode->i_ino != fh[1]) || (inode->i_generation != fh[2])) { + TRACE("[ramfs_get_dentry] \n", fh[3], inode->i_mtime.tv_sec); + return ERR_PTR(-ESTALE); + } + + atomic_inc(&inode->i_count); + + TRACE("[ramfs_get_dentry] inode->i_count %d\n", inode->i_count); + + result = d_alloc_anon(inode); + if (!result) { + iput(inode); + return ERR_PTR(-ENOMEM); + } + return result; +} + +static int ramfs_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable) { + + int len = *lenp; + struct inode *inode = de->d_inode; + + TRACE("[ramfs_encode_fh] fh 0x%p inode 0x%p i_ino 0x%x len %d\n", fh, inode, inode->i_ino, *lenp); + if (len < 4) + return 255; /* no room */ + + *lenp = 4; + fh[0] = (__u32)inode; + fh[1] = inode->i_ino; + fh[2] = inode->i_generation; + fh[3] = inode->i_mtime.tv_sec; + return 3; +} + +static struct dentry * ramfs_decode_fh(struct super_block *sb, __u32 *fh, int len, int fhtype, + int (*acceptable)(void *context, struct dentry *de), void *context) { + + TRACE("[ramfs_decode_fh] fh 0x%p fhtype %d len %d\n", fh, fhtype, len); + + if (fhtype != 3) + return ERR_PTR(-ESTALE); + if (len != 4) + return ERR_PTR(-ESTALE); + + return sb->s_export_op->find_exported_dentry(sb, fh, NULL, acceptable, context); +} + +static struct export_operations ramfs_export_ops = { + .decode_fh = ramfs_decode_fh, + .encode_fh = ramfs_encode_fh, + .get_dentry = ramfs_get_dentry, +}; +#endif + + static struct address_space_operations ramfs_aops = { .readpage = simple_readpage, .prepare_write = simple_prepare_write, @@ -176,6 +258,7 @@ static struct super_operations ramfs_ops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, + .read_inode = make_bad_inode, }; static int ramfs_fill_super(struct super_block * sb, void * data, int silent) @@ -199,6 +282,12 @@ return -ENOMEM; } sb->s_root = root; + +#if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE) + sb->s_export_op = &ramfs_export_ops; + TRACE("[ramfs_fill_super] super_block 0x%x\n", sb); +#endif + return 0; }