views:

212

answers:

1

Hi everyone,

I'm trying to compile a simple Kernel program that read and write from a proc file.

I'm trying to set permission to that file by overriding the permission fp in inode_operations struct (.permission)

static int module_permission(struct inode *inode, int op, struct nameidata *foo)

{ . . . }

static struct inode_operations Inode_Ops_4_Our_Proc_File = {
    .permission = module_permission,        /* check for permissions */

};

Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File;

For some reason, when I compile this i get -> warning: initialization from incompatible pointer type on the following line:

        .permission = module_permission,        /* check for permissions */

Any idea how to solve this?

Thanks!

+1  A: 

What kernel version are you using ? I am on 2.6.33 and this is how inode_operations is declared :

struct inode_operations {
    ...
int (*permission) (struct inode *, int);
    int (*check_acl)(struct inode *, int);
int (*setattr) (struct dentry *, struct iattr *);
    int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
    ...
}

If your kernel has the same thing, then the function signature of your module_permission function is (struct inode *, int, struct nameidata *) where as .permission expects (struct inode *, int)

Bandan
Linux ubuntu 2.6.28-18-generic #59-Ubuntu SMPYou are right, I was looking at the wrong file system header (fs.h)int (*permission) (struct inode *, int);Thanks alot!
djTeller