3

I want to locate the kernel's signal.c source code on my machine, to study the differences (if exist) between what I have and this source code. I tried following this post suggestion, but didn't get far.

I guess I need more specific instructions. I'm working with ubuntu 14.04, x86_64, linux-source-3.13.0 (last one is an output from apt-cache search linux-source).

1 Answers1

1

If you followed the instructions, you have installed a kernel source package, named linux-source-3.13.0, e.g., by

sudo apt-get install linux-source-3.13.0

or

sudo apt-get install linux-source

which installs a virtual package that installs the versioned package as a dependency.

Having done that, you can find the file you were looking for (using the package name):

dpkg -L linux-source-3.13.0 |grep -F signal.c

and get the pathname(s) of any files in that package named "signal.c"

If the package was actually a tarball of the sources, you would have to extract those files, e.g., using tar. In that case, dpkg -L linux-source would only list the tarball (and the grep would return nothing).

For the case of a tarball, you could do this:

tar tvf $(dpkg -L linux-source-3.13.0) |grep -F signal.c

if it contained only one file. But supposing you had something like

/usr
/usr/src
/usr/src/linux-patch-3.13-rt.patch.bz2
/usr/src/linux-source-3.13.tar.bz2
/usr/share
/usr/share/doc
/usr/share/doc/linux-source-3.13
/usr/share/doc/linux-source-3.13/copyright
/usr/share/doc/linux-source-3.13/changelog.Debian.gz
/usr/share/doc/linux-source-3.13/README.Debian

then the file you are looking for would be in the "tar.bz2" file, so...

tar tvf $(dpkg -L linux-source-3.13.0|grep -F .tar.bz2) |grep -F signal.c

would show the pathnames within that tarball for "signal.c"

Further reading:

Thomas Dickey
  • 76,765
  • Am I supposed to replace linux-source with something else? I get the output: package 'linux-source' is not installed. I tried replacing it with linux-image-extra-3.19.0-65-generic, without results. – HelterSkelter Jul 31 '16 at 18:05
  • How can I determine if the package need to be extracted? – HelterSkelter Jul 31 '16 at 18:06
  • I'd start with "dpkg -L linux-source |less" and see what it has in it. – Thomas Dickey Jul 31 '16 at 18:08
  • Once again, I got: dpkg-query: package 'linux-source' is not installed – HelterSkelter Jul 31 '16 at 18:09
  • Sounds like you're looking for this command: sudo apt-get source linux-image-$(uname -r) – Chef Pharaoh Aug 01 '16 at 16:05
  • Even with Debian, it's possible that the running kernel does not match the latest source. However, if OP recalls which package they installed, they can look at its contents. – Thomas Dickey Aug 01 '16 at 20:19
  • |1.| @ThomasDickey, I didn't use sudo apt-get install linux-source-3.13.0. If I would, will it reinstall the current Kernel? I don't want that.

    |2.| @ChefPharaoh, I executed what you suggested. What should I do next? dpkg -L linux-source still results in the above message. I did, however, tried dpkg -L linux-image-$(uname -r), and the output looks similiar to @ThomasDickey's output, but with no .bz2 files.

    |3.| In examining the output of ``sudo apt-get install linux-source-3.13.0, I do see this:linux-lts-vivid-3.19.0/kernel/signal.c`. But I can't find it on my pc.

    – HelterSkelter Aug 03 '16 at 07:11
  • @HelterSkelter The package linux-source... provides the source files; linux-image... provides the kernel. Did you run apt-get install linux-source-...? Your comment says that |1.| you didn't, and |3.| you did (and examined the output). – JigglyNaga Aug 03 '16 at 09:31
  • @JigglyNaga, sorry, my |3.| is wrong; It should be: "in examining the output of sudo apt-get source linux-image-$(uname -r) " – HelterSkelter Aug 03 '16 at 12:28
  • Update: Now I did executed sudo apt-get install linux-source-3.13.0, and then tried dpkg -L linux-source, and again got the message: package 'linux-source' is not installed. – HelterSkelter Aug 03 '16 at 12:33
  • That's expected: you installed the version-specific package, which doesn't pull in the (redundant) virtual package. – Thomas Dickey Aug 03 '16 at 20:15
  • @ThomasDickey, so what else can I try? – HelterSkelter Aug 04 '16 at 06:55