STRUCT CLASS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 πŸŽ€


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