What's tha KOBJ_MAX action used for?

Garrit Franke garritfranke at gmail.com
Tue Jul 14 10:36:15 EDT 2020


Thanks for your replies. Also, thanks greg for your thorough review on my
corresponding patch (https://lkml.org/lkml/2020/7/14/84), I learned a lot!

I have been digging around about Kobjects a bit. They are nicely documented.
Still, no documentation exists about this KOBJ_MAX action.
This post on stackoverflow mentions that it's a "special" field that marks the
end of the enum (if I understand correctly):
https://stackoverflow.com/a/23149574/9046809
This lead me to think that this is a convention I'm not aware of, but
I could not find any
resources that described such a thing, so I discarded that idea.

If I understand correctly, this action can in fact be passed to userspace by the
kobject_uevent function, so it would be a bad idea to remove it. Is my
reasoning correct?

regards,
Garrit


Am Di., 14. Juli 2020 um 04:15 Uhr schrieb Valdis Klētnieks
<valdis.kletnieks at vt.edu>:
>
> On Mon, 13 Jul 2020 14:35:23 +0200, Greg KH said:
> > On Mon, Jul 13, 2020 at 01:17:25PM +0200, Garrit Franke wrote:
> > > Hi all,
> > >
> > > I was wondering, what the KOBJ_MAX action in the kobject.h file does.
> > > It is self explainatory what KOBJ_ADD, KOBJ_REMOVE etc. are used for, but KOBJ_MAX puzzles me.
>
> > > Can it maybe even be removed?
> >
> > Maybe it can, try it and see!
>
> I suspect that this line:
>         for (action = 0; action < ARRAY_SIZE(kobject_actions); action++) {
> in lib/kobject_uenvent.c:kobject_action_type()  combined with the fact that
> kobject_actions[] does *not* actually match the enum regardless of the comment
> above it, result in it being superfluous.
>
> Figuring out why is left as an exercise for the student.
>
> Oh, and if I had a dollar for every time I've been surprised by creative abuse of
> the cpp ## operator... :)
>



More information about the Kernelnewbies mailing list