I wanna write a kernel module to replace readdir function.
but when i compiled it, error came out :

make -C /usr/src/linux-2.6.17/ M=`pwd` modules
make[1]: Entering directory `/usr/src/linux-2.6.17'
CC [M] /root/work/hidefile/hidefile.o
/root/work/hidefile/hidefile.c: In function 'hide_init':
/root/work/hidefile/hidefile.c:45: error: assignment of read-only member 'readdir'
/root/work/hidefile/hidefile.c: In function 'hide_exit':
/root/work/hidefile/hidefile.c:49: error: assignment of read-only member 'readdir'
make[2]: *** [/root/work/hidefile/hidefile.o] Error 1
make[1]: *** [_module_/root/work/hidefile] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.17'
the file is as below:

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/fs.h>
#include <linux/dirent.h>
#include <linux/dcache.h>

static char *filename = NULL;
static int ino = 0;
module_param(filename, charp, 0);
module_param(ino, int, 0);

struct getdents_callback64 {
struct linux_dirent64 * current_dir;
struct linux_dirent64 * previous;
int count;
int error;

int (*old_readdir)(struct file *filp, void *dirent, filldir_t filldir);

struct inode *inode;

int new_readdir(struct file *filp, void *dirent, filldir_t filldir)
int count, i, j;
count = ((struct getdents_callback64 *)dirent)->count;
i = (*old_readdir)(filp, dirent, filldir);
j = ((struct getdents_callback64 *)dirent)->count;
printk("\tcount: %d\ti: %d\tj: %d\n", count, i, j);
return i;
static int hide_init(void)
struct dentry *dentry;

dentry = dget(current->fs->pwd);
inode = iget(dentry->d_sb, ino);
return -1;
old_readdir = inode->i_fop->readdir;
inode->i_fop->readdir = new_readdir;
static void hide_exit(void)
inode->i_fop->readdir = old_readdir;


ask for your help, no idea about these errors! why it's read-only. it seems ok in 2.6.8.