All of
 help / color / mirror / Atom feed
From: Nikolay Amiantov <>
Cc: Shea Levy <>
Subject: Improvements in search of kernel modules directory
Date: Tue, 16 Aug 2016 03:50:28 +0300	[thread overview]
Message-ID: <> (raw)

These series of patches add more control over how kernel modules directory is

* Add an environment variable which allows to override kernel modules
* Allow to hardcode several paths which are searched in order for `uname -r`
* Add a configure option to set those paths, instead of hardcoding

We have used the first patch in NixOS[1] for a long time to point kmod to
kernel modules. While an environment variable is handy and has been solving our
problems, it doesn't cover all our cases. We have two directories:

* /run/current-system/kernel-modules/lib/modules
* /run/booted-system/kernel-modules/lib/modules

, which are symlinked to modules for current system configuration (i.e. after
an update) and the one which the system was booted with. It allows us to both
give users ability to install new modules and have their old kernel modules
accessible until a reboot (which is useful in case of kernel upgrade).

Before those patches the necessary logic (see if kernel modules for current
kernel version are available in current-system, if not then fall back to
booted-system) was implemented as a shell wrapper around kmod, which was
unwieldy and didn't work for applications that use kmod directly. It was
considered better to move this logic to kmod itself. Also, NixOS uses nixpkgs,
a set of distribution-agnostic packages (which run on e.g. Ubuntu and even Mac
OS X where applicable), so it was necessary to preserve /lib/modules as a
fallback directory in kmod for it to work on FHS distributions.

As a result a set of generic patches was written that implement necessary
behaviour while being potentially useful for upstream. Environment variable is
still used in several places (e.g. in automatic generation and running of
virtual machines) and is useful for us even with the rest of those patches.

A home of those patches can be found on GitHub[2] along with some
discussion, as can be related NixOS patches and discussion[3].

Big thanks to Shea Levy for the original patch, extensive code review and
useful advices.

Additionally, while working on those it was discovered that kmod makes use of
PATH_MAX. This constant is considered harmful[4] because it doesn't correspond
to real possible length of filesystem paths. This can be considered a bug, but
in those patches it was decided to follow upstream design decisions wherever
possible and so we also use it here.


             reply	other threads:[~2016-08-16  0:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16  0:50 Nikolay Amiantov [this message]
2016-08-16  0:50 ` [PATCH 1/4] libkmod: add MODULE_DIR to override kernel modules directory Nikolay Amiantov
2016-08-16  0:50 ` [PATCH 2/4] libkmod: allow hardcoding array of dirname prefixes Nikolay Amiantov
2016-08-16  0:50 ` [PATCH 3/4] static-nodes: use kmod to get modules directory Nikolay Amiantov
2016-08-16  0:50 ` [PATCH 4/4] libkmod: add --with-modulesdirs configure option Nikolay Amiantov
2016-11-11  2:13 ` Improvements in search of kernel modules directory Lucas De Marchi
2016-12-05  3:24 ` Lucas De Marchi
2016-12-05 12:35   ` Shea Levy
2016-12-07  7:06     ` Yauheni Kaliuta

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:

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

  git send-email \ \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.