Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Return values from system calls

    I've implemented a few custom system calls in my Ubuntu kernel, but I'm having some issues with the return values. Each function returns a variety of non-negative integers depending on which error is encountered. However, when I'm testing the system calls, the only negative value that gets returned to the user program is -1, regardless of what I have in the code.

    Is there some special path I have to take to get the proper return values?


  2. #2
    I'm having the exact same problem. This wouldn't be for a school project would it?

    I have verified that the code returning other negative values is getting executed by placing printk()'s before those return statements.

    Yet the -1 is all I can get.

    EDIT: I may have solved this. I've looked into errno. I may be wrong about this, but I think the calls will only return -1 specifying that an error has occurred, then the caller must check errno to see what error that was.
    Last edited by ragnaroktomorrow; 04-30-2011 at 02:56 AM.

  3. #3
    No, it's not for a school project.

    I thought that it might be an errno issue, but I've only recently started tinkering with linux under the hood. Do I have to explicitly set errno in the system call? Or will a negative value jump into it automatically?

  4. $spacer_open
  5. #4
    Quote Originally Posted by Fewmitz View Post
    Or will a negative value jump into it automatically?
    I believe so yes, but it won't be negative.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts