Linux Kernel Mod?

Discussion in 'General Linux' started by bashcommando, Jan 30, 2014.

  1. bashcommando

    bashcommando Active Member

    Joined:
    Jan 28, 2014
    Messages:
    223
    Likes Received:
    49
    How do I use the Linux kernel in C?

     
  2. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Joined:
    May 21, 2013
    Messages:
    1,635
    Likes Received:
    1,285
    Haider92 likes this.
  3. unixfish

    unixfish Member

    Joined:
    Jan 8, 2014
    Messages:
    94
    Likes Received:
    50
    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.
     
  4. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Joined:
    May 21, 2013
    Messages:
    1,635
    Likes Received:
    1,285
    Well, are you going to leave us in suspense? What is the quote? :rolleyes:
     
    Haider92 likes this.
  5. unixfish

    unixfish Member

    Joined:
    Jan 8, 2014
    Messages:
    94
    Likes Received:
    50
    "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.
     
    DevynCJohnson likes this.
  6. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Joined:
    Aug 4, 2012
    Messages:
    1,868
    Likes Received:
    659
  7. nazukia

    nazukia New Member

    Joined:
    Feb 3, 2014
    Messages:
    12
    Likes Received:
    3
    Hi,

    I am still a beginner, and Im probably wrong.

    Anyway... :rolleyes:

    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 :'( ]

    so :

    Google search for linux system call in C

    :)
     
  8. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Joined:
    May 21, 2013
    Messages:
    1,635
    Likes Received:
    1,285
    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
     
    Haider92 likes this.
  9. nazukia

    nazukia New Member

    Joined:
    Feb 3, 2014
    Messages:
    12
    Likes Received:
    3
    I mean, that he have vi and the source code, not that the source code include vi.
     
  10. GrumpyOldMan

    GrumpyOldMan Active Member

    Joined:
    Oct 30, 2013
    Messages:
    220
    Likes Received:
    62
    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().
     
    DevynCJohnson and ryanvade like this.
  11. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Joined:
    Aug 4, 2012
    Messages:
    1,868
    Likes Received:
    659
    I have to agree. Doing direct calls to hardware is not exactly safe...:)
     
  12. bashcommando

    bashcommando Active Member

    Joined:
    Jan 28, 2014
    Messages:
    223
    Likes Received:
    49
    Thanks
     
  13. AVESH RAI

    AVESH RAI New Member

    Joined:
    Apr 14, 2014
    Messages:
    4
    Likes Received:
    2
    Hello Everyone
    How to make new system calls and modify the existing one?
    Where exactly we have to enter in the directory of Kernel ?

    Thank u
     
    Ayush Garg likes this.
  14. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Joined:
    May 21, 2013
    Messages:
    1,635
    Likes Received:
    1,285
    Good question. Unfortunately, I do not know enough about C programming to give you a specific answer.
     
  15. bashcommando

    bashcommando Active Member

    Joined:
    Jan 28, 2014
    Messages:
    223
    Likes Received:
    49
    By system calls do you mean shell script? You can do that in C by using:
    Code:
    #include <studio.h>
    
    int main(void)
    {
        system("echo 'Hi'");
    }
    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.
     
    DevynCJohnson likes this.

Share This Page