linux kernel - add attribute to an existing kobject -


i'm working on porting driver i've written 2.6.x kernel series 3.x (i.e. rh el 6 -> rh el 7). driver solution comes in 2 modules: modified form of ahci.c (from kernel tree) , own upper-layer character driver access ahci registers , executing commands against drive.

in porting centos 7, i've run interesting problem. changes drivers i'm building on remove access scsi_host attributes in sysfs. question is, can append attributes onto devices existing in sysfs? every example i've come across shows making attributes @ point of device creation, e.g.:

static ssize_t port_show(struct kobject *kobj, struct kobj_attribute *attr,                          char *buff); static struct kobj_attribute pxclb_attr = __attr(pxclb, 0664, port_show, null); static struct attribute *attrs[] = {     &pxclb_attr.attr,     null, };  static struct attribute_group port_group = {     .attrs = attrs, };  /* other code */  sysfs_create_group(&kobj, &port_group); 

this example comes character driver. searches i've done google, , referencing linux foundation drivers class book, show attribute creation done @ time of device creation. can add them @ time? seem 1 call sysfs_create_group() @ time. true?

you can add attribute in sysfs @ anytime like.

the reason drivers add attribute in probe userspace has strict expectations on when attributes created. when new device registered in kernel, uevent generated notify userspace (like udev) new device available. if attributes added after device registered, userspace won't notified , userspace not know new attributes.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

mysql - FireDac error 314 - but DLLs are in program directory -