Re: "Permission denied" when using system-installed kernel headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 30, 2020 at 2:35 AM Anatol Pomozov <anatol.pomozov@xxxxxxxxx> wrote:
>
> Hi folks
>
> Here is a follow-up for this issue
> https://github.com/Open-CAS/open-cas-linux/issues/540
>
> opencas project builds an out-of-tree kernel module and uses
> system-level kernel header. In my case these headers are installed to
> /lib/modules/5.9.1-arch1-1/build
>
> So if I do
>
> $ cd /lib/modules/5.9.1-arch1-1/build
> $ make kernelversion
>
> I get following output:
>
> mkdir: cannot create directory ‘.tmp_86541’: Permission denied
> mkdir: cannot create directory ‘.tmp_86543’: Permission denied
> mkdir: cannot create directory ‘.tmp_86545’: Permission denied
> mkdir: cannot create directory ‘.tmp_86547’: Permission denied
> .......
> mkdir: cannot create directory ‘.tmp_86626’: Permission denied
> mkdir: cannot create directory ‘.tmp_86628’: Permission denied
> mkdir: cannot create directory ‘.tmp_86630’: Permission denied
> 5.9.1-arch1



This is because you did not pass M= option.



/lib/modules/$(uname -r)/build
is used for building external modules.

You cannot work in that directory
since it is usually read-only.


You need to pass M=<path-to-your-module>


This may work for you.



$ cd  /lib/modules/$(uname -r)/build
$ mkdir $HOME/foo
$ make M=$HOME/foo  kernelversion








>
> Quick debugging shows that it comes from scripts/Kbuild.include
> following lines in particular:
>
> # output directory for tests below
> TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$
>
> # try-run
> # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
> # Exit code chooses option. "$$TMP" serves as a temporary file and is
> # automatically cleaned up.
> try-run = $(shell set -e; \
> TMP=$(TMPOUT)/tmp; \
> TMPO=$(TMPOUT)/tmp.o; \
> mkdir -p $(TMPOUT); \
> trap "rm -rf $(TMPOUT)" EXIT; \
> if ($(1)) >/dev/null 2>&1; \
> then echo "$(2)"; \
> else echo "$(3)"; \
> fi)
>
>
>
> TMPOUT points to headers directory and in my case it is a part of /usr
> partition that restricts user writes.
>
>
> TMPOUT should avoid writing to headers dir and use `mktemp` instead.



--
Best Regards
Masahiro Yamada




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux