Discussion in 'General Linux' started by bashcommando, Jan 30, 2014.
How do I use the Linux kernel in C?
What do you mean by "use it in C"?
If you really want to start hacking the kernel, I would suggest you read The Magic Garden Explained by Benny Goodheart and James Cox. This covers System V release 4 - a bit outdated, but this book goes over the basics of the kernel, and will get you to the point you are ready to start work.
There are sayings / quotes at the beginning of each chapter. The quote that starts chapter 2 is a classic from Dennis Ritchie, and worth half the price of the book.
Well, are you going to leave us in suspense? What is the quote?
"UNIX is simple and coherent, but it takes a genius (or at any rate a programmer) to understand and appreciate the simplicity." -- Dennis Ritchie.
A friend of mine knew Dennis Ritchie and worked with him at Bell Labs (along with Mr. Kernigan and Pike). I have not spoken to my friend since before Mr. Ritchie passed away. I need to reconnect.
I am still a beginner, and Im probably wrong.
You question mean nothing for me. As I understand linux, its open source and mostly write in C... So you have the source, you have vi and bcc...?
But I have the feeling that what you are looking for are linux system call
take a look at :
[ I dont have suffisant privilege to add a link :'( ]
Google search for linux system call in C
I am not sure if I am understanding you correctly, but the source code for the Linux kernel does not include vi or other applications. The kernel's source code also includes the programming for the system calls.
You can include links by doing something like this -
linux dot or g
I mean, that he have vi and the source code, not that the source code include vi.
Generally, you don't make calls into the system, you use the user-space libraries. If you want to communicate with various devices (or more properly their device drivers) you use ioctl().
I have to agree. Doing direct calls to hardware is not exactly safe...
How to make new system calls and modify the existing one?
Where exactly we have to enter in the directory of Kernel ?
Good question. Unfortunately, I do not know enough about C programming to give you a specific answer.
By system calls do you mean shell script? You can do that in C by using:
And you cannot access the kernel directories. Its compiled to binary. How ever you can get the source of the kernel(even the directories you are looking for) at www.kernel.org then you can "update" the kernel with your new one BUT BE CAREFUL. A bug could mean that your system might not boot or just something will not work properly. Just to be safe you might want to use VirtualBox just in case of such an event.
Separate names with a comma.