STRUCT CLASS(9)
π struct class(9) π
okay so bestie, welcome to the Kernel API Manual corner where we're meeting struct class, and it is literally giving device classes. No cap. π
β¨ NAME β¨
struct class β device classes. periodt. π
π¦ SYNOPSIS π¦
struct class {
const char *name;
const struct attribute_group *const *class_groups;
const struct attribute_group *const *dev_groups;
int (*dev_uevent)(const struct device *dev, struct kobj_uevent_env
*env);
char *(*devnode)(const struct device *dev, umode_t *mode);
void (*class_release)(const struct class *class);
void (*dev_release)(struct device *dev);
int (*shutdown_pre)(struct device *dev);
const struct kobj_ns_type_operations *ns_type;
const struct ns_common *(*namespace)(const struct device *dev);
void (*get_ownership)(const struct device *dev, kuid_t *uid, kgid_t
*gid);
const struct dev_pm_ops *pm;
};
π Members π
nameβ the name of the class.class_groupsβ default attributes of this class.dev_groupsβ default attributes of the devices that belong to the class.dev_ueventβ called when a device is added, removed from this class, or a few other things that generate uevents to add the environment variables.devnodeβ callback to provide the devtmpfs.class_releaseβ called to release this class.dev_releaseβ called to release the device.shutdown_preβ called at shut-down time before driver shutdown.ns_typeβ callbacks so sysfs can determine namespaces.namespaceβ namespace of the device belongs to this class.get_ownershipβ allows class to specify uid/gid of the sysfs directories for the devices belonging to the class. Usually tied to device's namespace.pmβ the default device power management operations of this class.
π Description π
okay so picture a class as a higher-level view of a device that abstracts out the low-level implementation details. Drivers may see a SCSI disk or an ATA disk, but at the class level, they are all simply disks. Classes allow user space to work with devices based on what they do, rather than how they are connected or how they work. it's giving "identity crisis? never heard of her." π¦
π SEE ALSO π
- Kernel file
./include/linux/device/class.h class_find_device_by_name(9)class_find_device_by_of_node(9)class_find_device_by_fwnode(9)class_find_device_by_devt(9)class_find_device_by_acpi_dev(9)
xoxo bestie π β this page comes from the ./include/linux/device source/version, dated October 2026. slay, read the kernel docs, hydrate, and stay iconic. π«Άπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms