"There is little in the way of type safety here; a function cannot know that it was actually passed a pointer to the right sort of inode."
Is there no type tag in the inode structs?
Edit: Looking at its definition I don't see the problem.
Is there no type tag in the inode structs?
Edit: Looking at its definition I don't see the problem.
int (*link) (struct dentry *,struct inode *,struct dentry *);
Let's then look at the ext4 implementation of the link() operation: static int ext4_link(struct dentry *old_dentry,
struct inode *dir, struct dentry *dentry)
{
...
if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
(!projid_eq(EXT4_I(dir)->i_projid,
EXT4_I(old_dentry->d_inode)->i_projid)))
return -EXDEV;
....
In particular that calls EXT4_I(): static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
{
return container_of(inode, struct ext4_inode_info, vfs_inode);
}
Which is basically just direct unchecked pointer type conversion. So, calling ext4_link() on any non-ext4 created struct inode will blow up badly.