2

My interest is towards understanding the Linux kernel. Especially the filesystem. So what I'm doing is, I've placed "printk" statements in the files(such as inode.c, ialloc.c, etc.) in the fs/ext3/ folder in the kernel source code.

So now what I want is that instead of compiling the whole kernel, I want to compile only the part that is concerned with ext3 filesystem. Is there a way to compile only a part in which I have made changes in debian based systems (I'm using ubuntu 14.04). I have to wait for the whole kernel to compile unnecessarily though I've made changes only to a small part of it. Please help me in this regard.

P.S.- I've searched the internet and found some links too. But they are not satisfactory. Their steps indicate compiling the complete kernel instead.

AniketGM
  • 901
  • 1
  • 9
  • 17
  • 1
    Running make should only build the parts that are out of date. – Gil Hamilton Jun 01 '15 at 11:29
  • Yes I agree sir, but it builds the complete kernel. And what I want is to build just the part where I have made changes and add it to the existing kernel. Not build the entire kernel for a small change. – AniketGM Jun 01 '15 at 11:46
  • Maybe worth trying to figure out why make thinks all your objects are out-of-date. One possibility is that some of the kernel header files have timestamps on them that are later than the current system date-time. – Gil Hamilton Jun 01 '15 at 11:52

3 Answers3

0

I have assumed you have modified fs/ext3/inode.c

Suppose your kernel source directory is linux-x.x.x change the directory

cd linux-x.x.x

To compile particular file

make ./fs/ext3/inode.o

Only particular file will be compiled . Do same for all the files you have changed.

Punit Vara
  • 3,744
  • 1
  • 16
  • 30
  • This is a solution to a problem that shouldn't exist in the first place. `make` will automatically recompile modified files and skip compiling files that haven't changed. If it doesn't, there's something wrong with your setup and you should be fixing that instead of working around it. – tangrs Nov 05 '15 at 22:21
0

Yes I agree sir, but it builds the complete kernel. And what I want is to build just the part where I have made changes and add it to the existing kernel. Not build the entire kernel for a small change.

If I understand correctly, you want to compile the object code for the filesystem part of the kernel and somehow hack it into your current kernel.

Short answer:

It can't be done. Just compile the whole kernel. After the first compilation, make will ensure only changed files are recompiled so future builds will be fast.

Long answer:

If your currently running kernel has compiled EXT3 support as a module (I'm assuming this is possible - I haven't checked), you could try to compile your modified filesystem code as a module too and swap it into your running kernel by unloading the current filesystem module and loading yours in. Of course, you'll only be able to do this if you're not actually using the EXT3 driver at time of unloading.

Then, you'll run into the same issues as building and running OOT kernel modules. You'll almost certainly need the kernel headers, the same compiler version used to compile the current kernel and the kernel sources to match. You may also need to fiddle around with the Makefiles so the in-tree modules can be built as an OOT module.

Of course, this is all assuming your current kernel has been built with the EXT3 driver as a loadable kernel module which might not be the case.

If this isn't the case, you're pretty out of luck. If you're clever, you might be able to use some linker hackery to swap out the EXT3 subsystem with your modified object files in your current kernel. If that makes no sense to you, suffice to say it's impossible.

tangrs
  • 9,709
  • 1
  • 38
  • 53
0

To build individual module (ext3 in your case). try make M="path_to_module"

cd linux-src 
make M=fs/ext3
Shehbaz Jaffer
  • 1,944
  • 8
  • 23
  • 30