sys_datacopy keeps returning "bad address" error - Minix

This is a discussion on sys_datacopy keeps returning "bad address" error - Minix ; Hello! For the purposes of testing something I have, I've set kernel/table.c to allow "init" children to call any system call they want to call in order to do some hacking, and I have a test program that calls sys_datacopy(). ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: sys_datacopy keeps returning "bad address" error

  1. sys_datacopy keeps returning "bad address" error

    Hello!

    For the purposes of testing something I have, I've set kernel/table.c
    to allow "init" children to call any system call they want to call in
    order to do some hacking, and I have a test program that calls
    sys_datacopy().

    In my program, I setup two character pointers called "source" and
    "sink", with "source" initialized with some data. However, whenever I
    do "sys_datacopy(SELF, source, SELF, sink, strlen(source))", I get
    error code -14 returned, which is an EFAULT and means "bad address".

    Is there something special I have to do with those addresses in order
    to get sys_datacopy() to work with them? I'd really like to know,
    because when I implement a new OS server, I'm going to need to use
    sys_datacopy() in order to transfer large amounts of data to clients at
    a time.

    Thank you so very much in advance, and happy holidays!


  2. Re: sys_datacopy keeps returning "bad address" error

    Actually, it's really weird. When I made a very small straightfoward
    test, I could get sys_datacopy() to work just fine. However, when I
    run my larger code that is actually a set of unit tests, it fails. I
    guess I will just have to step through it slowly.

    Speaking of stepping through code, I don't have gdb installed. The GCC
    4.1.1 package did not include gdb. Is there some other debugger I can
    use on programs compiled with GCC under Minix?

    Also, I'm very sorry that I continue to respond to my own posts. It's
    just that I get stuck for hours on something and finally come here
    after lots of searching. Then I have a light bulb that just flashes
    and I discover the answer in no time.

    Thanks!

    P.S.: Where is a debugger I can use with GCC compiled code on Minix?
    GDB is not installed with the GCC 4.1.1 package.


  3. Re: sys_datacopy keeps returning "bad address" error

    Here is the test code that works, by the way:

    ======== BEGIN CODE PASTE =========

    #include
    #include
    #include
    #include
    #include
    #include

    #include

    int main()
    {
    using namespace std;
    //char *source = new char[50], *sink = new char[50];
    char source[50], sink[50];
    memcpy(source, "test", strlen("test")+1);
    printf("%s\n", source);
    int ret = sys_datacopy(SELF, (long)source, SELF, (long)sink,
    strlen(source)+1);
    if (ret < 0) {
    perror(__func__);
    return ret;
    }
    printf("%d %s %s\n", ret, source, sink);
    delete [] source;
    delete [] sink;
    return 0;
    }


+ Reply to Thread