3 ms·
"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
by rightbyte 3y ago
"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.
- actionfromafar 3y agoMaybe it meant know at compile time?
- dezgeg 3y agoLet's have a concrete example, link() in struct inode_operations is defined as: 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.