editing the linux kernel - Help

This is a discussion on editing the linux kernel - Help ; I am trying to change the kernel (redhat, linux-2.4.20-8) so that it backs up a file every time the file is open as writable. To do this, I added the following code to sys_open() in open.c: if (flags&O_RDWR == O_RDWR){ ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: editing the linux kernel

  1. editing the linux kernel

    I am trying to change the kernel (redhat, linux-2.4.20-8) so that it
    backs up a file every time the file is open as writable. To do this, I
    added the following code to sys_open() in open.c:

    if (flags&O_RDWR == O_RDWR){
    char buff[100];
    char file2[100];
    int size;
    sprintf(file2, filename, ",v1");
    int fd2;
    fd2 = sys_open(file2, O_WRONLY|O_CREAT|O_TRUNC, 0600);
    size = sys_read(fd, buff, 4096);
    sys_write(fd2, buff, size);
    sys_close(fd2);
    }

    However, this code does not do anything. When I open a file, it does
    not even create a backup. Does anyone have any idea why this code does
    not work, or even what I could do to get it to work? I appreciate any
    advice. Thanks.

  2. Re: editing the linux kernel

    On 26 Nov 2003 15:52:09 -0800, Muddlie2@aol.com (Emily) wrote:

    > However, this code does not do anything. When I open a file, it does
    > not even create a backup. Does anyone have any idea why this code does
    > not work, or even what I could do to get it to work?


    .... yea, get the book: "Understanding the Linux Kernel"
    http://www.oreilly.com/catalog/linuxkernel2/
    ..
    --
    /// Michael J. Tobler: motorcyclist, surfer, skydiver, \\\
    \\\ and author: "Inside Linux", "C++ HowTo", "C++ Unleashed" ///
    By trying, we can easily learn to endure adversity -- another
    man's, I mean. - Mark Twain

  3. Re: editing the linux kernel

    mjt wrote in message news:...
    > On 26 Nov 2003 15:52:09 -0800, Muddlie2@aol.com (Emily) wrote:
    >
    > > However, this code does not do anything. When I open a file, it does
    > > not even create a backup. Does anyone have any idea why this code does
    > > not work, or even what I could do to get it to work?

    >
    > ... yea, get the book: "Understanding the Linux Kernel"
    > http://www.oreilly.com/catalog/linuxkernel2/
    > .



    Thanks, but I actually already have that book. I read through the
    section explaining sys_open, sys_read, sys_write, and sys_close. It
    was helpful, but it just explains each line of the function. I still
    can't figure out why it doesn't work when I call these functions.

+ Reply to Thread