Linux Kernel Mod?

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

  1. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    How do I use the Linux kernel in C?

  2. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
  3. unixfish

    unixfish Member

    Messages:
    43
    Likes Received:
    25
    Trophy Points:
    18
    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

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
    Well, are you going to leave us in suspense? What is the quote? :rolleyes:
    Haider92 likes this.
  5. unixfish

    unixfish Member

    Messages:
    43
    Likes Received:
    25
    Trophy Points:
    18
    "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

    Messages:
    1,273
    Likes Received:
    431
    Trophy Points:
    83
  7. nazukia

    nazukia New Member

    Messages:
    12
    Likes Received:
    3
    Trophy Points:
    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

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
    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

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

    GrumpyOldMan Active Member

    Messages:
    136
    Likes Received:
    44
    Trophy Points:
    28
    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

    Messages:
    1,273
    Likes Received:
    431
    Trophy Points:
    83
    I have to agree. Doing direct calls to hardware is not exactly safe...:)
  12. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    Thanks
  13. AVESH RAI

    AVESH RAI New Member

    Messages:
    4
    Likes Received:
    2
    Trophy Points:
    3
    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

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
    Good question. Unfortunately, I do not know enough about C programming to give you a specific answer.
  15. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    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