3.6 System Call Mapping

The Oracle Linux operating system follows the POSIX standard and provides well-defined system call interfaces. Most of the system calls available on Oracle Linux are also available on other POSIX-compliant operating systems, either as system calls or library functions (APIs). There can be some additional minor differences in system call implementation between platforms.

The following sections list potential implementation differences in the number of arguments, argument types, return values, return value types, or differences in the headers files that should be included. In addition, there are likely to be differences in the errno values that can be set if an error occurs, or in the signals and argument flags that are supported.

Some system calls are available on only one platform. For such system calls, more time and effort will have to be spent during the migration.

System Call

Possible Implementation Differences

#include <unistd.h>

int access(const char *pathname, int mode);

Some operating systems require additional header files such as <sys/fcntl.h> to be included.

#include <unistd.h>

int acct(const char *filename);

Some operating systems define a different argument type or do not require the <unistd.h> header file to be included.

#include <unistd.h>

int brk(void *addr);

Some operating systems define a different argument type.

#include <unistd.h>

int chown(const char *path, uid_t owner, gid_t group);

Some operating systems require additional header files such as <sys/types.h> to be included.

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

int creat(const char *pathname, mode_t mode);

Some operating systems might not require <sys/types.h> or <sys/stat.h> to be included.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <unistd.h>

int faccessat(int dirfd, const char *pathname, int mode, int flags);

Some operating systems do not require _ATFILE_SOURCE to be defined and might require <sys/fcntl.h> to be included instead of <fcntl.h>.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <sys/stat.h>

int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);

Some operating systems do not require _ATFILE_SOURCE to be defined and might not require <fcntl.h> to be included.

#include <unistd.h>

int fchown(int fd, uid_t owner, gid_t group);

Some operating systems require additional header files such as <sys/types.h> to be included.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <unistd.h>

int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);

Some operating systems do not require _ATFILE_SOURCE to be defined and might require <sys/types.h> to be included but not <fcntl.h>.

#include <unistd.h>

#include <fcntl.h>

int fcntl(int fd, int cmd, ... /* arg */ );

Some operating systems require additional header files such as <sys/types.h> to be included or do not require <unistd.h>.

#include <unistd.h>

pid_t fork(void);

Some operating systems include additional header files such as <sys/types.h>.

#include <sys/types.h>

#include <sys/stat.h>

#include <unistd.h>

int fstat(int fd, struct stat *buf);

Some operating systems require the <fcntl.h> header file to be included or do not require <sys/types.h> or <unistd.h>. References to dev_t objects might require the use of the major, minor, and makedev macros that are defined in <sys/sysmacros.h>.

#include <sys/vfs.h> /* or <sys/statfs.h> */

int fstatfs(int fd, struct statfs *buf);

Some operating systems might require the <sys/statfs.h> header file to be included. <sys/vfs.h> and <sys/statfs.h> are equivalent on Oracle Linux.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

int futimesat(int dirfd, const chat *pathname, const struct timeval times[2]);

Some operating systems do not require _ATFILE_SOURCE to be defined and might include <sys/time.h> but not <fcntl.h>.

int getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count);

On some operating systems, the argument types to getdents might be different and the <dirent.h> header file might also need to be included.

getdents is not POSIX compliant. For POSIX compatibility when porting, consider using readdir instead.

#include <sys/types.h>

#include <unistd.h>

int getgroups(int size, gid_t list[]);

On some operating systems, the argument types to getdents are different and the <sys/types.h> header file might not be need to be included.

#include <sys/types.h>

#include <unistd.h>

pid_t getpid(void);

On some operating systems, the <sys/types.h> header file might not be need to be included.

#include <sys/types.h>

#include <unistd.h>

pid_t getppid(void);

On some operating systems, the <sys/types.h> header file might not be need to be included.

#include <sys/time.h>

#include <sys/resource.h>

int getrlimit(int resource, struct rlimit *rlim);

On some operating systems, the <sys/time.h> header file might not be need to be included.

#include <sys/ioctl.h>

int ioctl(int d, int request, ...);

Some operating systems require additional header files such as <unistd.h>, <sys/types.h>, or <stropts.h> to be included, and <sys/ioctl.h> might not be required.

ioctl is not compatible between operating systems as command requests are usually specific to device drivers. Time and effort is required to produce equivalent behavior when migrating code that uses ioctl calls.

#include <sys/klog.h>

int klogctl(int type, char *bufp, int len);

klogctl is specific to Oracle Linux and is not POSIX compliant. On some operating systems, klogctl might not be implemented or the arguments and argument types to klogctl might be different.

Time and effort is required to produce equivalent behavior when migrating code that uses klogctl calls.

#include <unistd.h>

int lchown(const char *path, uid_t owner, gid_t group);

Some operating systems require additional header files such as <sys/types.h> to be included.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <unistd.h>

int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags);

Some operating systems do not require _ATFILE_SOURCE to be defined and might not require <fcntl.h> to be included.

#include <sys/types.h>

#include <sys/stat.h>

#include <unistd.h>

int lstat(const char *path, struct stat *buf);

Some operating systems do not implement lstat or do not require the <sys/types.h> or <unistd.h> header files to be included.

#include <unistd.h>

#include <sys/mman.h>

int mincore(void *addr, size_t length, unsigned char *vec);

On some operating systems, the argument types to mincore might be different and the <sys/types.h> header file might also need to be included but not <unistd.h> or <sys/mman.h>.

#include <sys/stat.h>

#include <sys/types.h>

int mkdir(const char *pathname, mode_t mode);

Some operating systems might not require <sys/types.h> to be included.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <sys/stat.h>

int mkdirat(int dirfd, const char *pathname, mode_t mode);

Some operating systems do not require _ATFILE_SOURCE to be defined and might not require <fcntl.h> to be included.

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <unistd.h>

int mknod(const char *pathname, mode_t mode, dev_t dev);

Some operating systems might not require <sys/types.h>, <fcntl.h>, or <unistd.h> to be included.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <sys/stat.h>

int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev);

Some operating systems do not require _ATFILE_SOURCE to be defined and might not require <fcntl.h> to be included.

#include <sys/mount.h>

int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,const void *data);

mount is not POSIX compliant. On some operating systems, the arguments and argument types to mount might be different and the <sys/types.h>, <sys/mntent.h>, or <sys/vmount.h> header files might also need to be included.

Time and effort is required to produce equivalent behavior when migrating code that uses mount calls.

#include <sys/mman.h>

int mprotect(const void *addr, size_t len, int prot);

On some operating systems, the arguments and argument types to mprotect might be different.

#include <sys/types.h>

#include <sys/ipc.h>

#include <sys/msg.h>

int msgctl(int msqid, int cmd, struct msqid_ds *buf);

Some operating systems might not require <sys/types.h> or <sys/ipc.h> to be included.

#include <sys/types.h>

#include <sys/ipc.h>

#include <sys/msg.h>

int msgget(key_t key, int msgflg);

Some operating systems might not require <sys/types.h> or <sys/ipc.h> to be included.

#include <sys/types.h>

#include <sys/ipc.h>

#include <sys/msg.h>

ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,int msgflg);

On some operating systems, the argument types to msgrcv might be different and the <sys/types.h> and <sys/ipc.h> header files might not need to be included.

#include <sys/types.h>

#include <sys/ipc.h>

#include <sys/msg.h>

int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);

Some operating systems might not require <sys/types.h> and <sys/ipc.h> to be included.

#include <poll.h>

int poll(struct pollfd *fds, nfds_t nfds, int timeout);

On some operating systems, the argument types to poll might be different.

#define _GNU_SOURCE

#include <poll.h>

int ppoll(struct pollfd *fds, nfds_t nfds,const struct timespec *timeout, const sigset_t *sigmask);

Some operating systems do not require _GNU_SOURCE to be defined.

#include <unistd.h>

int profil(unsigned short *buf, size_t bufsiz, size_t offset, unsigned int scale);

On some operating systems, the argument types and return value type of profil might be different or might require the <time.h> header file to be included but not <unistd.h>.

#include <unistd.h>

ssize_t readlink(const char *path, char *buf, size_t bufsiz);

On some operating systems, the argument types and return value type of readlink might be different and might require the <symlink.h> header file to be included instead of <unistd.h>.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <unistd.h>

int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);

Some operating systems do not require _ATFILE_SOURCE to be defined and might not require the <fcntl.h> header file to be included.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <stdio.h>

int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);

Some operating systems do not require _ATFILE_SOURCE to be defined, and might require <unistd.h> to be included but not <fcntl.h> or <stdio.h>.

#include <unistd.h>

void *sbrk(intptr_t increment);

Some operating systems define a different argument type.

#include <sys/types.h>

#include <sys/ipc.h>

#include <sys/sem.h>

int semop(int semid, struct sembuf *sops, unsigned nsops);

On some operating systems, the argument types for semop might be different or the <sys/types.h> and <sys/ipc.h> header files might not need to be included.

#include <sys/types.h>

#include <sys/ipc.h>

#include <sys/sem.h>

int semtimedop(int semid, struct sembuf *sops, unsigned nsops, struct timespec *timeout);

On some operating systems, the argument types for semtimedop might be different or the <sys/time.h> header file might need to be included instead of <sys/types.h> and <sys/ipc.h>.

#include <grp.h>

int setgroups(size_t size, const gid_t *list);

On some operating systems, the argument types to setgroups might be different, and the <unistd.h> header file might need to be included instead of <grp.h>.

#include <unistd.h>

int setpgid(pid_t pid, pid_t pgid);

Some operating systems might require the <sys/types.h> header file to be included.

#include <unistd.h>

pid_t setsid(void);

Some operating systems might require the <sys/types.h> header file to be included.

#include <sys/ipc.h>

#include <sys/shm.h>

int shmctl(int shmid, int cmd, struct shmid_ds *buf);

Some operating systems might require the <sys/types.h> header file to be included or not require <sys/ipc.h>.

#include <sys/ipc.h>

#include <sys/shm.h>

int shmget(key_t key, size_t size, int shmflg);

Some operating systems might require the <sys/types.h> header file to be included or not require <sys/ipc.h>.

#include <signal.h>

int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);

On some operating systems, the argument types to sigaction might be different.

#include <signal.h>

int sigaltstack(const stack_t *ss, stack_t *oss);

On some operating systems, the argument types to sigaltstack might be different.

#include <signal.h>

int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);

On some operating systems, the argument types to sigprocmask might be different.

#include <sys/types.h>

#include <sys/stat.h>

#include <unistd.h>

int stat(const char *path, struct stat *buf);

Some operating systems might require the <fcntl.h> header file to be included or not require <unistd.h>.

#include <sys/vfs.h> /* or <sys/statfs.h> */

int statfs(const char *path, struct statfs *buf);

Some operating systems might require the <sys/statfs.h> header file to be included. <sys/vfs.h> and <sys/statfs.h> are equivalent on Oracle Linux.

#include <time.h>

int stime(time_t *t);

On some operating systems, the argument type to stime might be different or the <unistd.h> header file might need to be included instead of <time.h>.

#define _ATFILE_SOURCE

#include <fcntl.h> /* Definition of AT_* constants */

#include <stdio.h>

int symlinkat(const char *oldpath, int newdirfd, const char *newpath);

Some operating systems do not require _ATFILE_SOURCE to be defined and might require <unistd.h> to be included but not <fcntl.h> or <stdio.h>.

int sysfs(int option);

int sysfs(int option, const char *fsname);

int sysfs(int option, unsigned int fs_index, char *buf);

On some operating systems, the supported arguments and argument types to sysfs might be different and the <sys/fstyp.h> or <sys/fsid.h> header files might need to be included.

#include <sys/sysinfo.h>

int sysinfo(struct sysinfo *info);

On some operating systems, the supported arguments and argument types to sysfs might be different and the <sys/systeminfo.h> header file might need to be included instead of <sys/sysinfo.h>.

Time and effort is required to produce equivalent behavior when migrating code that uses sysinfo calls.

int syslog(int type, char *bufp, int len);

syslog is specific to Oracle Linux and is not POSIX compliant. On some operating systems, syslog might not be implemented or the arguments and argument types to syslog might be different.

Time and effort is required to produce equivalent behavior when migrating code that uses syslog calls.

#include <time.h>

time_t time(time_t *t);

Some operating systems might also require the <sys/types.h> header file to be included.

The method used to determine the time might depend on the system architecture.

#include <sys/times.h>

clock_t times(struct tms *buf);

Some operating systems might also require the <limits.h> header file to be included.

#include <sys/utsname.h>

int uname(struct utsname *buf);

Some operating systems might define domainname as part of the utsname structure.

#define _ATFILE_SOURCE

#include <fcntl.h>

int unlinkat(int dirfd, const char *pathname, int flags);

Some operating systems do not require _ATFILE_SOURCE to be defined and might require <unistd.h> to be included but not <fcntl.h>.

#include <sys/types.h>

#include <unistd.h> /* libc[45] */

#include <ustat.h> /* glibc2 */

int ustat(dev_t dev, struct ustat *ubuf);

Some operating systems do not require the <unistd.h> or <sys/types.h> header files to be included.

#include <unistd.h>

int vhangup(void);

On some operating systems, the return value type of vhangup might be different.