Replacement of getname api

52 views
Skip to first unread message

Deepika Singh

unread,
Aug 22, 2019, 1:54:10 AM8/22/19
to kernel-meet...@googlegroups.com
Hi,

Do anyone know replacement of getname api, it is no more exported by kernel.

CVS

unread,
Aug 22, 2019, 8:42:44 AM8/22/19
to Deepika Singh, Kernel Meetup Bangalore
> Do anyone know replacement of getname api, it is no more exported by kernel.
Hmmm... i still see that the function is available within the Linux kernel

CVS

unread,
Aug 22, 2019, 8:46:57 AM8/22/19
to Deepika Singh, Kernel Meetup Bangalore
Sorry for the previous incomplete email. fat fingers :-) :-)

> Do anyone know replacement of getname api, it is no more exported by kernel.
Hmmm... i still see that the function is available within the Linux
kernel as getname_kernel()
https://elixir.bootlin.com/linux/latest/ident/getname_kernel

Maybe can try getting a handle to call the function using
kallsyms_lookup_name() ?
as described in the answers to this question
https://stackoverflow.com/q/32965535/319204

regards
CVS

CVS

unread,
Aug 22, 2019, 9:02:18 AM8/22/19
to Deepika Singh, Kernel Meetup Bangalore
> > Do anyone know replacement of getname api, it is no more exported by kernel.
> Hmmm... i still see that the function is available within the Linux
> kernel as getname_kernel()
> https://elixir.bootlin.com/linux/latest/ident/getname_kernel
Diggin some more...

Here it is still available in v3.13.x
https://elixir.bootlin.com/linux/v3.13.11/source/fs/namei.c#L212

Going through the history of fs/namei.c,
it appears that the function getname() stopped being exported
sometime in Linux kernel v3.14.

Not quite sure why though...

> Maybe can try getting a handle to call the function using
> kallsyms_lookup_name() ?
> as described in the answers to this question
> https://stackoverflow.com/q/32965535/319204

So currently, if writing a kernel module,
and need access to getname()
maybe call it by obtaining a function pointer to getname() using
kallsyms_lookup_name()

regards
CVS

CVS

unread,
Aug 22, 2019, 10:11:47 AM8/22/19
to Kernel Meetup Bangalore, Deepika Singh
> Going through the history of fs/namei.c,
> it appears that the function getname() stopped being exported
> sometime in Linux kernel v3.14.
>
> Not quite sure why though...

Did a little bit of archaeology using the "pickaxe" feature of git.

~/repos/linux () $ g l -G "EXPORT_SYMBOL\(getname\)" fs/namei.c
9115eac2c788 2014-01-27 vfs: unexport the getname() symbol [author=Jeff Layton] [committer=Al Viro]
91a27b2a7567 2012-10-10 vfs: define struct filename and have getname() return it [author=Jeff Layton] [committer=Al Viro]
8e377d15078a 2012-10-10 vfs: unexport getname and putname symbols [author=Jeff Layton] [committer=Al Viro]
1da177e4c3f4 2005-04-16 (tag: v2.6.12-rc2) Linux-2.6.12-rc2 [author=Linus Torvalds] [committer=Linus Torvalds]


We see that getname()
- was exported originally in 2005, in v2.6.12
- was then unexported (alongwith putname()) by Jeff in 2012 stating - "I see no callers in module code."
- was then exported back in another commit the same day
- was finally unexported in 2014 stating - "Leaving getname() exported when putname() isn't, is a bad idea."

Fun Fact :
The newer commit 91a27b2a7567
has a timestamp that is ~80minutes *before*
the older commit 8e377d15078a !

commit 91a27b2a7567
Author: Jeff Layton <jla...@redhat.com>
Date:   Wed Oct 10 15:25:28 2012 -0400

commit 8e377d15078a
Author: Jeff Layton <jla...@redhat.com>
Date:   Wed Oct 10 16:43:13 2012 -0400


Does this mean Jeff has a time machine?
Or was Jeff flying west that day?
Anyone else has any other theories what could have happened here?

regards
CVS
Reply all
Reply to author
Forward
0 new messages