mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lk Sii <lk_sii@163.com>
To: Alexander Aring <aahringo@redhat.com>,
	Greg KH <gregkh@linuxfoundation.org>
Cc: rafael@kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	gfs2 <gfs2@lists.linux.dev>, David Teigland <teigland@redhat.com>
Subject: Re: udev kset_create_and_add() with own struct kobj_type?
Date: Tue, 16 Jul 2024 20:07:16 +0800	[thread overview]
Message-ID: <3353d6c1-54ce-46c0-8b65-a0383c8da324@163.com> (raw)
In-Reply-To: <CAK-6q+jSBjuFaFqGLQcfVLMUwRcJJMHk2oUnSgMObwz+OAih6g@mail.gmail.com>

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

not sure if this info is helpful for your requirements.

> So kset_create_and_add() does not allow me to add my own
> ".child_ns_type" callback for the kset that is required for me to have
> my sysfs "kernel/dlm" directory separated by each net-namespace
> without breaking any backwards compatibility.
> 
> My current solution is that I mostly copy&pasted the code of
> kset_create_and_add()/kset_create() to have a way to tell my own
> struct kobj_type that contains the implemented my own ".child_ns_type"
> callback.
> 
> I am writing this mail to get some advice on what I can do here
> without doing the copy&pasted code?
> Add a parameter to kset_create_and_add() that allows me to set an
> "struct kobj_type"?
> Introducing a new function that does allow me to set the new parameter
> (I probably like that because then I don't need to update all other
> users)?
> 
> Thanks in advance for any advice.
> 
> - Alex
> 
> 


  parent reply	other threads:[~2024-07-16 12:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 15:27 Alexander Aring
2024-07-15 15:33 ` Greg KH
2024-07-15 16:57   ` Alexander Aring
2024-07-16 12:07 ` Lk Sii [this message]
2024-07-16 13:10   ` Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3353d6c1-54ce-46c0-8b65-a0383c8da324@163.com \
    --to=lk_sii@163.com \
    --cc=aahringo@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=teigland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®