0

I am currently studying device drivers in an operating systems course and am getting confused regarding the difference between the "inode" structs and "cdev" structs. Could someone clarify the differences between these two structures and what they're meant to achieve?

1 Answer 1

2

Your question doesn’t mention any specific context; this answer describes struct cdev and struct inode.

The two are fundamentally different.

struct cdev represents a character device, giving access to a driver; it points to the implementations of the various operations supported by a character device.

struct inode represents an inode, along with all the information the kernel needs to use it and keep track of it. An inode gives access to a file, and contains the file’s metadata: its ownership, permissions, ACLs, timestamps, size etc. The kernel needs to know which file system it’s tied to, where the implementations of the operations it supports are, what its state is, etc.

An instance of a struct inode can contain a pointer to a struct cdev, if the inode itself corresponds to a character device (e.g. the inode corresponding to /dev/null, once it’s instantiated in the kernel, is represented by a struct inode with i_cdev pointing to the relevant character device).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .