Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 2039  / 2 Years ago, thu, may 5, 2022, 4:43:49

I need two files from the Linux kernel's source code, which I deleted by mistake:




  1. Option.c

  2. usb-wwan.h



I searched using these commands, but did not find them:



find -name Option.c
find -name usb-wwan.h


How can I get these files? (I do have access to an Ubuntu 12.04 installation disk.)


More From » kernel

 Answers
0

Obtaining Linux's Sources (For Ubuntu's Downstream Kernel)


You obtained the kernel sources somehow. You should redownload them, or redo whatever you did to get them.


In particular, if you're running Ubuntu 12.04, and either you don't know how you got your kernel sources or you got them by installing a package whose name starts with linux-source, then you can put back any deleted file by completely reinstalling the package:


sudo rm -rf /usr/src/linux-source-3.2.0/linux-source-3.2.0
sudo apt-get update
sudo apt-get --reinstall install linux-source-3.2.0
cd /usr/src/linux-source-3.2.0
sudo tar xvjf linux-source-3.2.0.tar.bz2

(Please note that it is intentional that linux-source-3.2.0 appears twice in the first command, which removes the manually extracted source directory, if any.)



  • You might also want to have the package linux-source (with no version number in the name) installed, so that you keep getting the source code for new kernels as they become available. But reinstalling linux-source with the above method will not replace missing files, as linux-source is just a metapackage that always depends on the most recent versioned linux-source- package in your Ubuntu release.


Searching For Files By Name In Kernel Sources


Now you should have the missing files, so search for them:


find /usr/src/linux-source-3.2.0/linux-source-3.2.0 -iname Option.c -or -iname usb-wwan.h

Please note that I've used the -iname option, which performs case-insensitive matching. (Option.c, with a capital O, is a somewhat unlikely name for a source file in the Linux kernel's sources.)


The output will look like:


/usr/src/linux-source-3.2.0/linux-source-3.2.0/drivers/usb/serial/option.c
/usr/src/linux-source-3.2.0/linux-source-3.2.0/drivers/usb/serial/usb-wwan.h

Please note that these files are from Ubuntu's downstream kernel, patched (i.e., modified) specially for Ubuntu, and its parent distribution, Debian. See this page (especially this section) for details. This is probably what you want, because it corresponds to the kernel that's likely to actually be installed on your machine. But depending on your specific needs, you might need a different kernel altogether.


[#36174] Friday, May 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
homerurhyth

Total Points: 338
Total Questions: 113
Total Answers: 105

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
;