10
KIRIN Observation: Most Indirect Calls(~90%) in Linux Kernel
Use Well Defined Interface
Observation: kernel has well defined interface to connect different component together
Filesystem
struct file_operations {
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t,
loff_t *);
ssize_t (*write) (struct file *, char __user *, size_t,
loff_t *);
int (*open) (struct inode *, struct file *);
int (*release) (struct inode *, struct file *);
…
}
Network protocol
struct proto_ops {
int (*connect) (struct socket *sock, struct sockaddr
*vaddr, int sockaddr_len, int flags);
int (*listen) (struct socket *sock, int len);
int (*sendmsg) (struct socket *sock, struct msghdr
*m, size_t total_len);
int (*recvmsg) (struct socket *sock, struct msghdr
*m, size_t total_len, int flags);
…
}