From: Wu Zhenyu <wuzhenyu@ustc.edu>
To: linux-modules@vger.kernel.org
Cc: Lucas De Marchi <lucas.de.marchi@gmail.com>
Subject: Re: [PATCH] libkmod: use realpath
Date: Wed, 4 Oct 2023 21:07:41 +0800 [thread overview]
Message-ID: <2gfubiqrbq5lhu3znkas3eglk35s6wbl4ss6bh4wpfirzrsqfa@vf3gd4kmc3ty> (raw)
Forgot to mention. This commit can be modified freely to statisfy the maintainers :)
From: Wu Zhenyu <wuzhenyu@ustc.edu>
To: linux-modules@vger.kernel.org
Subject: [PATCH] libkmod: use realpath
Date: Wed, 4 Oct 2023 21:04:08 +0800
Message-ID: <20231004130426.1673502-1-wuzhenyu@ustc.edu>
X-Mailer: git-send-email 2.42.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
$ modinfo ../Linux-Device-Driver/eg_07_ioctl/ioctl.ko | head -n1
filename: /home/wzy/Desktop/kmod/../Linux-Device-Driver/eg_07_ioctl/ioctl.ko
$ tools/modinfo ../Linux-Device-Driver/eg_07_ioctl/ioctl.ko | head -n1
filename: /home/wzy/Desktop/Linux-Device-Driver/eg_07_ioctl/ioctl.ko
---
libkmod/libkmod-module.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 585da41..bdc1427 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -794,15 +794,17 @@ KMOD_EXPORT const char *kmod_module_get_name(const struct kmod_module *mod)
*/
KMOD_EXPORT const char *kmod_module_get_path(const struct kmod_module *mod)
{
- char *line;
+ char *line, *path;
if (mod == NULL)
return NULL;
DBG(mod->ctx, "name='%s' path='%s'\n", mod->name, mod->path);
- if (mod->path != NULL)
- return mod->path;
+ if (mod->path != NULL) {
+ path = malloc(strlen(mod->path));
+ return realpath(mod->path, path);
+ }
if (mod->init.dep)
return NULL;
--
2.42.0
reply other threads:[~2023-10-04 13:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2gfubiqrbq5lhu3znkas3eglk35s6wbl4ss6bh4wpfirzrsqfa@vf3gd4kmc3ty \
--to=wuzhenyu@ustc.edu \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.de.marchi@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).