Re: udev kset_create_and_add() with own struct kobj_type?

From: Alexander Aring
Date: Tue Jul 16 2024 - 09:10:35 EST


Hi,

On Tue, Jul 16, 2024 at 8:15 AM Lk Sii <lk_sii@xxxxxxx> wrote:
>
> On 2024/7/15 23:27, Alexander Aring wrote:
> > Hi,
> >
> > I am currently implementing namespace support into the fs/dlm
> > subsystem. The DLM subsystem uses kset_create_and_add("dlm",
> > &dlm_uevent_ops, kernel_kobj); to create the "dlm" sysfs directory.
> > Underneath it creates for each lockspace a subdirectory using
> > kobject_init_and_add() with a non-static name and being known during
> > runtime.
> >
> > Now I want to add namespace support and need to change the "default"
> > kset->kobj.ktype = &kset_ktype; that is set by
> > kset_create_and_add()->kset_create() to my own kobj_type because I
> > need to implement a different ".child_ns_type" callback before
> > kset_register() is called.
> >
> you maybe use kset_register() instead of kset_create_and_add().
> you maybe find example codes from below kernel files:
> fs/nfs/sysfs.c
> fs/f2fs/sysfs.c
> fs/ubifs/sysfs.c

looked into the first one, it looks like potential new users for such
a new helper. This is what I am currently doing and it works, but I
mostly copy&paste the code of kset_create_and_add() just to set a
different "kobj.ktype" in the kset and feeling bad about it.

Thanks.

- Alex