All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikolaj Ch <mikich7777@gmail.com>
To: yamada.masahiro@socionext.com, michal.lkml@markovi.net
Cc: linux-kbuild@vger.kernel.org
Subject: scripts/Makefile.modinst: removing module path M from module destination is not working for some cases
Date: Thu, 8 Nov 2018 12:26:27 +0100	[thread overview]
Message-ID: <CAMBOaT3wpJ3RTX8XQeLkK2v9sxKUCUqe++ULAbYAOCrsjqDihg@mail.gmail.com> (raw)

Hi,

I noticed a problem while installing external module with command:
make M=dir modules_install

For me it appeared in two separate cases:
- when 'dir' includes symbolic link
- when 'dir' includes double slash.

For this two cases module is installed to:
lib/modules/<kernel_version>/extra/<'dir>'/<module_name>.ko
instead of
lib/modules/<kernel_version/extra/<module_name>.ko

I've traced the problem and it appeared to be in:
scripts/Makefile.modinst in line:

in line 12 the path to module is taken from MODVERDIR/*.mod file:
__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard
$(MODVERDIR)/*.mod)))

and then directory part of this path is going to be removed with subst
function in line 30:
ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst
%/,%,$(KBUILD_EXTMOD)),,$(@D))

but it fails since KBUILD_EXTMOD is not evaluated path (can include
symlink or double slash) and @D is direct/evaluated path from *.mod
file.

-------------------------
the same in more details:
-------------------------

In kernel Makefile the following variables are set:
KBUILD_EXTMOD = $M
MODVERDIR = $KBUILD_EXTMOD/.tmp_versions


in scripts/Makefile.modinst in lines:
__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard
$(MODVERDIR)/*.mod)))
modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))

The path in $MODVERDIR is evaluated correctly by shell (symbolic link
is followed and double slash is interpreted as single slash)
and the path to the module $modules is taken form $(MODVERDIR)/*.mod file).

The $modules is then passed to __modinst function as $@ where in line:
ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst
%/,%,$(KBUILD_EXTMOD)),,$(@D))

subst function substitutes text from $KBUILD_EXTMOD to empty string in
directory part of $@ (@D) but here KBUILD_EXTMOD is different then @D.


Can't directory part be remove differently if using absolute paths to
avoid such problems ?

Regards,
  Mikolaj Chadzynski

             reply	other threads:[~2018-11-08 21:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08 11:26 Mikolaj Ch [this message]
2018-11-12  5:31 ` scripts/Makefile.modinst: removing module path M from module destination is not working for some cases Masahiro Yamada
2018-11-12 12:54   ` Mikolaj Ch

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=CAMBOaT3wpJ3RTX8XQeLkK2v9sxKUCUqe++ULAbYAOCrsjqDihg@mail.gmail.com \
    --to=mikich7777@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=yamada.masahiro@socionext.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 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.