- The script inserts new methods into the inode operations vector that
access the object's fields.
For example, in the case of i_mode, the script adds the following
function declarations to the inode operations structure:
umode_t (*read_i_mode)(struct inode *inode);
void (*write_i_mode)(struct inode *inode, umode_t new_val);
-
For each inode field, the script adds inline functions to access the
inode's object. If the inode object has a method defined for that
field, then the object's own method is used. Otherwise, the object's
field is read directly.
For example, the script adds the following function to read the
i_mode field:
static inline umode_t read_i_mode(struct inode *inode)
{
if (inode->i_op && inode->i_op->read_i_mode)
return inode->i_op->read_i_mode(inode);
else
return inode->i_mode;
}
The script defines similar methods for updating other inode fields.
-
Every access to private inode fields is converted to use one of the
inline functions. For example,
inode->i_mode = mode;
is converted to
write_i_mode(inode, (mode));
Also, the script properly handles more complicated cases, such as
inode->i_nlink++;
which are converted into
write_i_nlink(inode, read_i_nlink(inode) + 1);