0
votes

I'm trying to build a kernel as a hobby project by following the project part given in the book Operating System Concepts by Silberschatz, Galvin and Gagne. The book states:

The system call numbers for recent versions of the Linux kernel are listed in /usr/src/linux-2.x/include/asm-i386/unistd.h.

But I can not find this directory. There is no directory like linux-2.x; all are of the form linux-3.x.

1
That's because your book is describing Linux kernel 2.x and the current version is 4.9 (sayeth kernel.org on 2016-12-17). Your book is old, and therefore (at least mildly) misleading. Offhand, I don't know whether you need linux-4.x instead of linux-3.x or if they kept the 3.x despite the version change to 4.x. - Jonathan Leffler
I came across this too [ link ](csee.umbc.edu/courses/undergraduate/CMSC421/fall02/burt/…) It mentions almost same directories. So if i want to see the list of pointers to system-call handlers which file should i be looking for? - vishu rathore
'Fall 02' was about 14 years ago. At that time, the kernel version was 2.x. It isn't 2.x any more. If you want to build a 2.x kernel, you'll need to get the 2.x source and then you'll find the linux-2.x directory. Which edition of Silberschatz are you using? The 9th edition is dated 2012, which is long enough ago that it could have been 'almost current' when published but the kernel has moved on since then. - Jonathan Leffler
I'm using the 9th edition.Could you point to me some place with information on how to build a basic kernel in the latest version of linux? - vishu rathore
No; I've not studied how to build a Linux kernel. You'll need someone who has done it to help you. You can look at kernel.org (e.g. git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/about) but I'm not much wiser for having looked. In particular, I didn't find include/asm-i386, though I wasn't looking all that hard. - Jonathan Leffler

1 Answers

1
votes

These headers get automatically generated nowadays and the tables for that are in e.g.: linux-4.4.5/arch/x86/entry/syscalls/ . Depending on the distribution you might need to install the kernel headers separately, e.g.: with Ubuntu (packet linux-headers-$VERSION. Version must fit the kernel version!). I found them installed at /usr/src/linux-headers-3.13.0-37-generic/arch/x86/include/generated/asm/ (with Linux Mint which is based on Ubuntu) . The headers there get included from the regular unistd.h to be found (again for x86) in /usr/src/linux-headers-3.16.0-37/arch/x86/include/asm/unistd.h. (actual version of kernel may vary).

Last kernel with major version 2 is 2.6.39.4 from August 2011. You can try it but it won't boot on hardware more modern than an old Pentium. If you have such an old machine or have a machine with enough horsepower to run a virtual Pentium machine--go for it. But I would recommend to upgrade you book instead.

If you are wondering why you (and I) have a version 3 instead of the most recent 4.9: if your hardware runs with it, it has no grave security related bugs and you don't need any of the things in the most recent kernel, then use the one your distribution gave you, they know what they are doing (he said boldly).