From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] lib: Fix kernel module detection on BusyBox
Date: Tue, 19 Jan 2021 22:48:46 +0100 [thread overview]
Message-ID: <YAdTvomK8qSjpD0l@pevik> (raw)
In-Reply-To: <YAc5hMnHm0GIQJ96@google.com>
Hi Sandeep,
thanks for your comments!
> > + SAFE_ASPRINTF(NULL, &path, "/lib/modules/%s/%s", uts.release, file);
> This is just the ramdisk location, the on-disk location is
> /vendor/lib/modules/. I also think that the ramdisk one goes away after we
> switch over 2nd stage init. Is there a test I can run that uses these
> functions now to make sure this works?
Any C based test which defines needs_drivers (e.g. fsetxattr02, ioctl08,
uevent01, ...) (or shell based tests with TST_NEEDS_DRIVERS, but you probably
don't run any shell test).
> Also, unfortunately (and sadly) we may have to do something Android specific
> downstream as the /vendor/lib/modules and /lib/modules only started to appear
> as of android 11 :(.
Feel free to send a patch upstream. If not that much complicated and you're
willing to maintain it, it might get to upstream (depends on other maintainers,
but we're quite open).
> Once you share how I can test, I'm happy to test and add my Tested-by for
> Android.
> +cc: kernel-team@android.com
> > +
> > + if (stat(path, &st) || !(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))) {
> > + tst_resm(TWARN, "expected file %s does not exist or not a file", path);
> > + return -1;
> > + }
> > +
> > + if (access(path, R_OK)) {
> > + tst_resm(TWARN, "file %s cannot be read", path);
> > + return -1;
> > + }
> > +
> > + SAFE_ASPRINTF(NULL, &search, "/%s.ko", driver);
> > +
> > + f = SAFE_FOPEN(NULL, path, "r");
> > +
> > + while (fgets(buf, sizeof(buf), f)) {
> > + if (sscanf(buf, "%s", module) != 1)
> > + continue;
> > +
> > + if (strstr(module, search) != NULL) {
> > + SAFE_FCLOSE(NULL, f);
> > + return 0;
> > + }
> > + }
> > +
> > + SAFE_FCLOSE(NULL, f);
> > +
> > + return -1;
> > +}
> > +
> > +int tst_check_driver_(const char *driver)
> > +{
> > + if (!tst_search_driver(driver, "modules.dep") ||
> > + !tst_search_driver(driver, "modules.builtin"))
> > + return 0;
> > +
> > + return 1;
> > +}
> > +
> > +int tst_check_driver(const char *driver)
> > +{
> > +#ifdef __ANDROID__
> > + /*
> > + * Android may not have properly installed modules.* files. We could
> > + * search modules in /system/lib/modules, but to to determine built-in
> the appropriate location would be /lib/modules OR /vendor/lib/modules.
OK. I tested only old aosp (Oreo, Nougat and KitKat).
Out of curiosity, does have Android 11 modules.{builtin,dep}? If yes, it'd make
sense to treat it as Linux (apply "modules always available" approach only if
files aren't available).
Kind regards,
Petr
> > + * drivers we need modules.builtin. Therefore assume all drivers are
> > + * available.
> > */
> > return 0;
> > #endif
next prev parent reply other threads:[~2021-01-19 21:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 16:03 [LTP] [PATCH v3 0/2] kernel module detection (own implementation) Petr Vorel
2021-01-19 16:03 ` [LTP] [PATCH v3 1/2] lib: Fix kernel module detection on BusyBox Petr Vorel
2021-01-19 19:56 ` Sandeep Patil
2021-01-19 21:48 ` Petr Vorel [this message]
2021-01-20 12:16 ` Petr Vorel
2021-01-20 14:14 ` Cyril Hrubis
2021-01-20 15:21 ` Petr Vorel
2021-01-20 15:28 ` Cyril Hrubis
2021-01-20 19:27 ` Petr Vorel
2021-01-19 16:03 ` [LTP] [PATCH v3 2/2] zram: Fix " Petr Vorel
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=YAdTvomK8qSjpD0l@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/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