It isn't difficult to put all the policy in one place using
macros. Something like (not tested of course):
#define null_checked(struc,op,args...) \
extern inline int struc##_##op##_invoke(struct *struc, args)\
{ \
return struc->op ? struc->op(args) : -EWHAT?; \
} \
\
extern inline struc##_##op##_replace(struct *struc) \
{ \
}
#define defl_checked(struc,op,args...) \
extern inline int struc##_##op##_invoke(struct *struc, args)\
{ \
return struc->op(args); \
} \
\
extern inline struc##_##op##_replace(struct *struc) \
{ \
if (!struc->op) \
struc->op = default_##struc##_##op; \
}
struct inode_operations {
struct file_operations * default_file_ops;
int (*create) (struct inode *,struct dentry *,int);
int (*lookup) (struct inode *,struct dentry *);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
int (*symlink) (struct inode *,struct dentry *,const char *);
int (*mkdir) (struct inode *,struct dentry *,int);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (struct inode *,struct dentry *,int,int);
...
}
null_checked(inode_operations, create, struct inode *,struct dentry *,int)
null_checked(inode_operations, lookup, struct inode *,struct dentry *)
defl_checked(inode_operations, mknod, struct inode *,struct dentry *,int,int)
...
You would use the xxx_replace routines to replace appropriate
NULL-entries during registering of filesystems, and the xxx_invoke
routines to invoke functions. Of course, to be efficient, this relies
on a non-braindead compiler.
Btw, this is backwards compatible.
astor
-- Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway http://www.guardian.no/- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html