9

Where are some lists of system calls on UNIX?

This wasn't my original question, but thanks anyway :)

Ken Bloom
  • 57,498
  • 14
  • 111
  • 168
Oleg Razgulyaev
  • 5,757
  • 4
  • 28
  • 28
  • 2
    Which is the question here -- "Where are some lists of system calls?", or "How can I determine....system call?". In either case, we need to know what your target platform is before we will be able to answer the question. EDIT: I have edited your question to the former, please edit both the question body and title if you meant the latter. – Billy ONeal Apr 20 '10 at 04:07
  • http://www.di.uevora.pt/~lmr/syscalls.html – PersianGulf Feb 27 '17 at 18:43

8 Answers8

9

man 2 syscalls

Aside from that, you can look in /usr/include/sys/syscall.h (which on my system merely #includes /usr/include/bits/syscall.h). That's generated at libc build time from kernel syscall list.

You can also grep the Linux kernel source for SYSCALL_DEFINE. (I'm not a BSD expert, but I think the equivalent in FreeBSD is SYSCALL_MODULE)

Ken Bloom
  • 57,498
  • 14
  • 111
  • 168
  • 2
    `man 2 syscalls` gives me `No entry for syscalls in section 2 of the manual`. –  Apr 20 '10 at 04:29
  • 3
    You may need to install an appropriate package on your system. On Debian and Ubuntu, that package is named `manpages-dev`. – Ken Bloom Apr 20 '10 at 04:36
  • @Kinopiko apparently there isn't one. – Ken Bloom Apr 20 '10 at 13:35
  • @sharth, @Ken Bloom, those are not applicable to all UNIX implementations. It is better to consult the authoritative spec (i.e. the Open Group Base Specifications / IEEE Std. 1003.1) – Michael Aaron Safyan Apr 21 '10 at 05:40
  • @Michael good point. There's UNIX system calls, and then there's your UNIX's system calls, and those are two different things. – Ken Bloom Apr 21 '10 at 13:13
5

Read The Fine Manual. For system calls, start with

man 2 intro

That's how I got started in UNIX. We didn't have no fancy internet back then ...

Duncan
  • 2,056
  • 13
  • 11
  • @Kinopiko: It was good enough back in the days of wood-burning computers. We were given half a page of common UNIX commands and a few hints, then set loose in the lab to figure it out for ourselves. – Duncan Apr 20 '10 at 04:55
  • I should warn that the man pages installed on the local machine may have idiosyncracies specific to that implementation of UNIX. It would be better to consult the man pages from the spec. – Michael Aaron Safyan Apr 21 '10 at 05:38
  • @Michael Aaron Safyan: I would assume that one would in most cases be programming under the implementation of UNIX for which they are consulting the man pages. However, I agree with your point provided the idiosyncracies augment the spec rather than change it. – Duncan Apr 21 '10 at 07:08
4

For the official, authoritative IEEE Std. 1003.1 / Single UNIX Specification (UNIX 2004) manpages, see:

A full list of functions (system interfaces) may be found under "System Interfaces" or at the link. I would also like to use this as an opportunity to plug my Development / Coding Search custom search engine, which includes and is heavily biased towards the Single UNIX Specification / IEEE Std. 1003.1. For example, a standard search for fopen, close, unix, etc. have promotions taken out to ensure that results from the authoritative documentation are at the very top. Adding "man" in front of a query heavily weights the result in favor of the IEEE Std. 1003.1 man page as in man find, man free, man inttypes.h, etc., although most queries should favor IEEE Std. 1003.1 even without adding "man" (if it isn't, type bad query and tell me).

Michael Aaron Safyan
  • 93,612
  • 16
  • 138
  • 200
2

In FreeBSD, the best place to look for what the system calls are is in the file /usr/src/sys/sys/syscall.h. This is on FreeBSD 9.0

Daniel Rudy
  • 1,411
  • 12
  • 23
2

What operating system, exactly? Man section 2 documents the syscalls, however the complete set varies depending upon what flavor of UNIX you are on.

POSIX.1 defines a standard set of operating system interfaces, however no operating system limits itself to just those. In general you have the BSD and SYSV flavors which have slightly different semantics. However, nowdays the supposed syscalls are actually quasi library functions.

The only TRUE answer requires a specific installation and examination of the file

 /usr/include/syscall.h
caskey
  • 12,305
  • 2
  • 26
  • 27
1

What you should really do is pick up a copy of "Advanced Programming in the Unix Environment" by W. Richard Stevens. This is the classic book on how to program Unix-like OS's. The book is old and MacOs/iPhoneOs are a different most traditional flavors of Unix, but the book is a great way to learn the basics and get a feel for how the API's are supposed to be used. Check it out at Amazon

Armentage
  • 12,065
  • 8
  • 33
  • 33
  • @Armentage, why would you do that, if the Single UNIX Specification is available online for free? The book (I have a copy), is just a poor waste of trees and is practically obsolete when printed. – Michael Aaron Safyan Apr 21 '10 at 05:37
  • 2
    I didn't say he should buy a new paper copy. There are probably thousands of copies of this book floating around that can be purchased second hand, borrowed from a library, or from a friend. It's a very well respected book that is NOT just a stupid print out of man pages. It contains simple examples of what you can be doing with a unix-like OS and is a good starting point for someone who is trying to pick it up for the first time. – Armentage Apr 23 '10 at 02:55
0

http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html

http://www.metasploit.com/users/opcode/syscalls.html

sblom
  • 26,911
  • 4
  • 71
  • 95
0

In most environments, ls /usr/man/2/ will do the trick, although it could be /usr/local/man or /usr/share/man or even /usr/local/share/man.

EDIT: There might even be a MANPATH environment variable pointing you to the right place.

Lucas Jones
  • 19,767
  • 8
  • 75
  • 88
Ben Voigt
  • 277,958
  • 43
  • 419
  • 720