Thread: minix system call pls help for project

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    2

    minix system call pls help for project

    hey i managed to create a new system call.
    i want to give 1 argument which is a structure like this mysystemcall(&structure);
    next my system call makes some calculations and creates a new same type structure which now has the results.
    how can i return that structure in my main.c where i call my system call back to the original structure argument i gave.
    i tried a lot but i couldnt find a solution... i tried sys_datacopy() but when i try to printf the structure in my main.c i only get zeros..
    the main purpose here is to call the system call with an argument that will put the results there and printf them in main.c.
    pls someone help and thnx a lot..

  2. #2
    Registered User
    Join Date
    Jun 2009
    Posts
    2
    pls noone knows how to send a structure from the system call(kernel space) to the USER SPACE in minix ?

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Right, it's approximately 20 years since I read Tannenbaum's book.

    My first question is why you (feel that you) have to copy the structure, and then pass it back.
    Where are you copying the structure to?

    The method I would recommend is to pass in a structure that can hold both the input and the output content [possibly by storing the output values in the input values].

    But if you REALLY have to pass back a different structure, then you (probably) need to allocate space in the kernel code, then make sure that memory can be accessed by the current process, and finally pass that struct back - either by passing in a pointer to a pointer to be filled in, or by passing the pointer back as a result from the function.

    A third alternative is to pass in two arguments, one with the (pointer to the) source structure, another with the pointer to destination structure.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. System call to call another C file from Existing C File
    By simly01 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2002, 01:29 PM
  2. system call
    By stautze in forum C Programming
    Replies: 2
    Last Post: 05-07-2002, 12:48 PM
  3. exec system call
    By weedus in forum Linux Programming
    Replies: 3
    Last Post: 03-07-2002, 09:34 PM
  4. reqd a system call
    By nrohan in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 03:56 AM
  5. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 06:57 AM