Skip to content

syscall #

System Calls

The system call is the fundamental interface between an application and the operating system kernel.

syscall module provides wrappers for system calls. Use C.syscall() if you want to invoke system calls that has no wrappers.

Status and Purpose

This project is currently a Work in Progress (WIP). Breaking changes may occur prior to reaching version 1.0.0.

The objective of this module is to provide C wrappers that are currently missing from V's standard os library. However, this does not preclude the inclusion of wrappers for system calls that are already present in the standard library. Consequently, the syscall module does not aim to provide comprehensive coverage of all system calls; rather, the number of wrappers will be expanded on an as-needed basis.

Microsoft Windows support is not planned.

Constants #

const mnt_detach = 2 // MNT_DETACH
const mnt_expire = 4 // MNT_EXPIRE
const mnt_force = 1 // MNT_FORCE
const mnt_id_req_size_ver0 = 24 // MNT_ID_REQ_SIZE_VER0
const mnt_id_req_size_ver1 = 32 // MNT_ID_REQ_SIZE_VER1
const ms_active = 1073741824 // MS_ACTIVE
const ms_bind = 4096 // MS_BIND
const ms_born = 536870912 // MS_BORN
const ms_dirsync = 128 // MS_DIRSYNC
const ms_i_version = 8388608 // MS_I_VERSION
const ms_kernmount = 4194304 // MS_KERNMOUNT
const ms_lazytime = 33554432 // MS_LAZYTIME
const ms_mandlock = 64 // MS_MANDLOCK
const ms_mgc_msk = -65536 // MS_MGC_MSK
const ms_mgc_val = -1058209792 // MS_MGC_VAL
const ms_move = 8192 // MS_MOVE
const ms_noatime = 1024 // MS_NOATIME
const ms_nodev = 4 // MS_NODEV
const ms_nodiratime = 2048 // MS_NODIRATIME
const ms_noexec = 8 // MS_NOEXEC
const ms_noremotelock = 134217728 // MS_NOREMOTELOCK
const ms_nosec = 268435456 // MS_NOSEC
const ms_nosuid = 2 // MS_NOSUID
const ms_nosymfollow = 256 // MS_NOSYMFOLLOW
const ms_nouser = -2147483648 // MS_NOUSER
const ms_posixacl = 65536 // MS_POSIXACL
const ms_private = 262144 // MS_PRIVATE
const ms_rdonly = 1 // MS_RDONLY
const ms_rec = 16384 // MS_REC
const ms_relatime = 2097152 // MS_RELATIME
const ms_remount = 32 // MS_REMOUNT
const ms_rmt_mask = 41943121 // MS_RMT_MASK
const ms_shared = 1048576 // MS_SHARED
const ms_silent = 32768 // MS_SILENT
const ms_slave = 524288 // MS_SLAVE
const ms_strictatime = 16777216 // MS_STRICTATIME
const ms_submount = 67108864 // MS_SUBMOUNT
const ms_synchronous = 16 // MS_SYNCHRONOUS
const ms_unbindable = 131072 // MS_UNBINDABLE
const ms_verbose = 32768 // MS_VERBOSE
const o_accmode = 3 // O_ACCMODE
const o_append = 1024 // O_APPEND
const o_async = 8192 // O_ASYNC
const o_cloexec = 524288 // O_CLOEXEC
const o_creat = 64 // O_CREAT
const o_directory = 65536 // O_DIRECTORY
const o_dsync = 4096 // O_DSYNC
const o_excl = 128 // O_EXCL
const o_fsync = 1052672 // O_FSYNC
const o_ndelay = 2048 // O_NDELAY
const o_noctty = 256 // O_NOCTTY
const o_nofollow = 131072 // O_NOFOLLOW
const o_nonblock = 2048 // O_NONBLOCK
const o_rdonly = 0 // O_RDONLY
const o_rdwr = 2 // O_RDWR
const o_rsync = 1052672 // O_RSYNC
const o_sync = 1052672 // O_SYNC
const o_trunc = 512 // O_TRUNC
const o_wronly = 1 // O_WRONLY
const seek_cur = 1 // SEEK_CUR
const seek_end = 2 // SEEK_END
const seek_set = 0 // SEEK_SET
const sys_accept4 = 288 // SYS_accept4
const sys_accept = 43 // SYS_accept
const sys_access = 21 // SYS_access
const sys_acct = 163 // SYS_acct
const sys_add_key = 248 // SYS_add_key
const sys_adjtimex = 159 // SYS_adjtimex
const sys_afs_syscall = 183 // SYS_afs_syscall
const sys_alarm = 37 // SYS_alarm
const sys_arch_prctl = 158 // SYS_arch_prctl
const sys_bind = 49 // SYS_bind
const sys_bpf = 321 // SYS_bpf
const sys_brk = 12 // SYS_brk
const sys_cachestat = 451 // SYS_cachestat
const sys_capget = 125 // SYS_capget
const sys_capset = 126 // SYS_capset
const sys_chdir = 80 // SYS_chdir
const sys_chmod = 90 // SYS_chmod
const sys_chown = 92 // SYS_chown
const sys_chroot = 161 // SYS_chroot
const sys_clock_adjtime = 305 // SYS_clock_adjtime
const sys_clock_getres = 229 // SYS_clock_getres
const sys_clock_gettime = 228 // SYS_clock_gettime
const sys_clock_nanosleep = 230 // SYS_clock_nanosleep
const sys_clock_settime = 227 // SYS_clock_settime
const sys_clone3 = 435 // SYS_clone3
const sys_clone = 56 // SYS_clone
const sys_close = 3 // SYS_close
const sys_close_range = 436 // SYS_close_range
const sys_connect = 42 // SYS_connect
const sys_copy_file_range = 326 // SYS_copy_file_range
const sys_create_module = 174 // SYS_create_module
const sys_creat = 85 // SYS_creat
const sys_delete_module = 176 // SYS_delete_module
const sys_dup2 = 33 // SYS_dup2
const sys_dup3 = 292 // SYS_dup3
const sys_dup = 32 // SYS_dup
const sys_epoll_create1 = 291 // SYS_epoll_create1
const sys_epoll_create = 213 // SYS_epoll_create
const sys_epoll_ctl = 233 // SYS_epoll_ctl
const sys_epoll_ctl_old = 214 // SYS_epoll_ctl_old
const sys_epoll_pwait2 = 441 // SYS_epoll_pwait2
const sys_epoll_pwait = 281 // SYS_epoll_pwait
const sys_epoll_wait = 232 // SYS_epoll_wait
const sys_epoll_wait_old = 215 // SYS_epoll_wait_old
const sys_eventfd2 = 290 // SYS_eventfd2
const sys_eventfd = 284 // SYS_eventfd
const sys_execveat = 322 // SYS_execveat
const sys_execve = 59 // SYS_execve
const sys_exit = 60 // SYS_exit
const sys_exit_group = 231 // SYS_exit_group
const sys_faccessat2 = 439 // SYS_faccessat2
const sys_faccessat = 269 // SYS_faccessat
const sys_fadvise64 = 221 // SYS_fadvise64
const sys_fallocate = 285 // SYS_fallocate
const sys_fanotify_init = 300 // SYS_fanotify_init
const sys_fanotify_mark = 301 // SYS_fanotify_mark
const sys_fchdir = 81 // SYS_fchdir
const sys_fchmodat2 = 452 // SYS_fchmodat2
const sys_fchmodat = 268 // SYS_fchmodat
const sys_fchmod = 91 // SYS_fchmod
const sys_fchownat = 260 // SYS_fchownat
const sys_fchown = 93 // SYS_fchown
const sys_fcntl = 72 // SYS_fcntl
const sys_fdatasync = 75 // SYS_fdatasync
const sys_fgetxattr = 193 // SYS_fgetxattr
const sys_file_getattr = 468 // SYS_file_getattr
const sys_file_setattr = 469 // SYS_file_setattr
const sys_finit_module = 313 // SYS_finit_module
const sys_flistxattr = 196 // SYS_flistxattr
const sys_flock = 73 // SYS_flock
const sys_fork = 57 // SYS_fork
const sys_fremovexattr = 199 // SYS_fremovexattr
const sys_fsconfig = 431 // SYS_fsconfig
const sys_fsetxattr = 190 // SYS_fsetxattr
const sys_fsmount = 432 // SYS_fsmount
const sys_fsopen = 430 // SYS_fsopen
const sys_fspick = 433 // SYS_fspick
const sys_fstatfs = 138 // SYS_fstatfs
const sys_fstat = 5 // SYS_fstat
const sys_fsync = 74 // SYS_fsync
const sys_ftruncate = 77 // SYS_ftruncate
const sys_futex = 202 // SYS_futex
const sys_futex_requeue = 456 // SYS_futex_requeue
const sys_futex_waitv = 449 // SYS_futex_waitv
const sys_futex_wait = 455 // SYS_futex_wait
const sys_futex_wake = 454 // SYS_futex_wake
const sys_futimesat = 261 // SYS_futimesat
const sys_getcpu = 309 // SYS_getcpu
const sys_getcwd = 79 // SYS_getcwd
const sys_getdents64 = 217 // SYS_getdents64
const sys_getdents = 78 // SYS_getdents
const sys_getegid = 108 // SYS_getegid
const sys_geteuid = 107 // SYS_geteuid
const sys_getgid = 104 // SYS_getgid
const sys_getgroups = 115 // SYS_getgroups
const sys_getitimer = 36 // SYS_getitimer
const sys_getpeername = 52 // SYS_getpeername
const sys_getpgid = 121 // SYS_getpgid
const sys_getpgrp = 111 // SYS_getpgrp
const sys_getpid = 39 // SYS_getpid
const sys_getpmsg = 181 // SYS_getpmsg
const sys_getppid = 110 // SYS_getppid
const sys_getpriority = 140 // SYS_getpriority
const sys_getrandom = 318 // SYS_getrandom
const sys_getresgid = 120 // SYS_getresgid
const sys_getresuid = 118 // SYS_getresuid
const sys_getrlimit = 97 // SYS_getrlimit
const sys_getrusage = 98 // SYS_getrusage
const sys_getsid = 124 // SYS_getsid
const sys_getsockname = 51 // SYS_getsockname
const sys_getsockopt = 55 // SYS_getsockopt
const sys_gettid = 186 // SYS_gettid
const sys_gettimeofday = 96 // SYS_gettimeofday
const sys_getuid = 102 // SYS_getuid
const sys_getxattrat = 464 // SYS_getxattrat
const sys_getxattr = 191 // SYS_getxattr
const sys_get_kernel_syms = 177 // SYS_get_kernel_syms
const sys_get_mempolicy = 239 // SYS_get_mempolicy
const sys_get_robust_list = 274 // SYS_get_robust_list
const sys_get_thread_area = 211 // SYS_get_thread_area
const sys_init_module = 175 // SYS_init_module
const sys_inotify_add_watch = 254 // SYS_inotify_add_watch
const sys_inotify_init1 = 294 // SYS_inotify_init1
const sys_inotify_init = 253 // SYS_inotify_init
const sys_inotify_rm_watch = 255 // SYS_inotify_rm_watch
const sys_ioctl = 16 // SYS_ioctl
const sys_ioperm = 173 // SYS_ioperm
const sys_iopl = 172 // SYS_iopl
const sys_ioprio_get = 252 // SYS_ioprio_get
const sys_ioprio_set = 251 // SYS_ioprio_set
const sys_io_cancel = 210 // SYS_io_cancel
const sys_io_destroy = 207 // SYS_io_destroy
const sys_io_getevents = 208 // SYS_io_getevents
const sys_io_pgetevents = 333 // SYS_io_pgetevents
const sys_io_setup = 206 // SYS_io_setup
const sys_io_submit = 209 // SYS_io_submit
const sys_io_uring_enter = 426 // SYS_io_uring_enter
const sys_io_uring_register = 427 // SYS_io_uring_register
const sys_io_uring_setup = 425 // SYS_io_uring_setup
const sys_kcmp = 312 // SYS_kcmp
const sys_kexec_file_load = 320 // SYS_kexec_file_load
const sys_kexec_load = 246 // SYS_kexec_load
const sys_keyctl = 250 // SYS_keyctl
const sys_kill = 62 // SYS_kill
const sys_landlock_add_rule = 445 // SYS_landlock_add_rule
const sys_landlock_create_ruleset = 444 // SYS_landlock_create_ruleset
const sys_landlock_restrict_self = 446 // SYS_landlock_restrict_self
const sys_lchown = 94 // SYS_lchown
const sys_lgetxattr = 192 // SYS_lgetxattr
const sys_linkat = 265 // SYS_linkat
const sys_link = 86 // SYS_link
const sys_listen = 50 // SYS_listen
const sys_listmount = 458 // SYS_listmount
const sys_listxattrat = 465 // SYS_listxattrat
const sys_listxattr = 194 // SYS_listxattr
const sys_llistxattr = 195 // SYS_llistxattr
const sys_lookup_dcookie = 212 // SYS_lookup_dcookie
const sys_lremovexattr = 198 // SYS_lremovexattr
const sys_lseek = 8 // SYS_lseek
const sys_lsetxattr = 189 // SYS_lsetxattr
const sys_lsm_get_self_attr = 459 // SYS_lsm_get_self_attr
const sys_lsm_list_modules = 461 // SYS_lsm_list_modules
const sys_lsm_set_self_attr = 460 // SYS_lsm_set_self_attr
const sys_lstat = 6 // SYS_lstat
const sys_madvise = 28 // SYS_madvise
const sys_map_shadow_stack = 453 // SYS_map_shadow_stack
const sys_mbind = 237 // SYS_mbind
const sys_membarrier = 324 // SYS_membarrier
const sys_memfd_create = 319 // SYS_memfd_create
const sys_memfd_secret = 447 // SYS_memfd_secret
const sys_migrate_pages = 256 // SYS_migrate_pages
const sys_mincore = 27 // SYS_mincore
const sys_mkdirat = 258 // SYS_mkdirat
const sys_mkdir = 83 // SYS_mkdir
const sys_mknodat = 259 // SYS_mknodat
const sys_mknod = 133 // SYS_mknod
const sys_mlock2 = 325 // SYS_mlock2
const sys_mlockall = 151 // SYS_mlockall
const sys_mlock = 149 // SYS_mlock
const sys_mmap = 9 // SYS_mmap
const sys_modify_ldt = 154 // SYS_modify_ldt
const sys_mount = 165 // SYS_mount
const sys_mount_setattr = 442 // SYS_mount_setattr
const sys_move_mount = 429 // SYS_move_mount
const sys_move_pages = 279 // SYS_move_pages
const sys_mprotect = 10 // SYS_mprotect
const sys_mq_getsetattr = 245 // SYS_mq_getsetattr
const sys_mq_notify = 244 // SYS_mq_notify
const sys_mq_open = 240 // SYS_mq_open
const sys_mq_timedreceive = 243 // SYS_mq_timedreceive
const sys_mq_timedsend = 242 // SYS_mq_timedsend
const sys_mq_unlink = 241 // SYS_mq_unlink
const sys_mremap = 25 // SYS_mremap
const sys_mseal = 462 // SYS_mseal
const sys_msgctl = 71 // SYS_msgctl
const sys_msgget = 68 // SYS_msgget
const sys_msgrcv = 70 // SYS_msgrcv
const sys_msgsnd = 69 // SYS_msgsnd
const sys_msync = 26 // SYS_msync
const sys_munlockall = 152 // SYS_munlockall
const sys_munlock = 150 // SYS_munlock
const sys_munmap = 11 // SYS_munmap
const sys_name_to_handle_at = 303 // SYS_name_to_handle_at
const sys_nanosleep = 35 // SYS_nanosleep
const sys_newfstatat = 262 // SYS_newfstatat
const sys_nfsservctl = 180 // SYS_nfsservctl
const sys_openat2 = 437 // SYS_openat2
const sys_openat = 257 // SYS_openat
const sys_open = 2 // SYS_open
const sys_open_by_handle_at = 304 // SYS_open_by_handle_at
const sys_open_tree = 428 // SYS_open_tree
const sys_open_tree_attr = 467 // SYS_open_tree_attr
const sys_pause = 34 // SYS_pause
const sys_perf_event_open = 298 // SYS_perf_event_open
const sys_personality = 135 // SYS_personality
const sys_pidfd_getfd = 438 // SYS_pidfd_getfd
const sys_pidfd_open = 434 // SYS_pidfd_open
const sys_pidfd_send_signal = 424 // SYS_pidfd_send_signal
const sys_pipe2 = 293 // SYS_pipe2
const sys_pipe = 22 // SYS_pipe
const sys_pivot_root = 155 // SYS_pivot_root
const sys_pkey_alloc = 330 // SYS_pkey_alloc
const sys_pkey_free = 331 // SYS_pkey_free
const sys_pkey_mprotect = 329 // SYS_pkey_mprotect
const sys_poll = 7 // SYS_poll
const sys_ppoll = 271 // SYS_ppoll
const sys_prctl = 157 // SYS_prctl
const sys_pread64 = 17 // SYS_pread64
const sys_preadv2 = 327 // SYS_preadv2
const sys_preadv = 295 // SYS_preadv
const sys_prlimit64 = 302 // SYS_prlimit64
const sys_process_madvise = 440 // SYS_process_madvise
const sys_process_mrelease = 448 // SYS_process_mrelease
const sys_process_vm_readv = 310 // SYS_process_vm_readv
const sys_process_vm_writev = 311 // SYS_process_vm_writev
const sys_pselect6 = 270 // SYS_pselect6
const sys_ptrace = 101 // SYS_ptrace
const sys_putpmsg = 182 // SYS_putpmsg
const sys_pwrite64 = 18 // SYS_pwrite64
const sys_pwritev2 = 328 // SYS_pwritev2
const sys_pwritev = 296 // SYS_pwritev
const sys_query_module = 178 // SYS_query_module
const sys_quotactl = 179 // SYS_quotactl
const sys_quotactl_fd = 443 // SYS_quotactl_fd
const sys_readahead = 187 // SYS_readahead
const sys_readlinkat = 267 // SYS_readlinkat
const sys_readlink = 89 // SYS_readlink
const sys_readv = 19 // SYS_readv
const sys_read = 0 // SYS_read
const sys_reboot = 169 // SYS_reboot
const sys_recvfrom = 45 // SYS_recvfrom
const sys_recvmmsg = 299 // SYS_recvmmsg
const sys_recvmsg = 47 // SYS_recvmsg
const sys_remap_file_pages = 216 // SYS_remap_file_pages
const sys_removexattrat = 466 // SYS_removexattrat
const sys_removexattr = 197 // SYS_removexattr
const sys_renameat2 = 316 // SYS_renameat2
const sys_renameat = 264 // SYS_renameat
const sys_rename = 82 // SYS_rename
const sys_request_key = 249 // SYS_request_key
const sys_restart_syscall = 219 // SYS_restart_syscall
const sys_rmdir = 84 // SYS_rmdir
const sys_rseq = 334 // SYS_rseq
const sys_rt_sigaction = 13 // SYS_rt_sigaction
const sys_rt_sigpending = 127 // SYS_rt_sigpending
const sys_rt_sigprocmask = 14 // SYS_rt_sigprocmask
const sys_rt_sigqueueinfo = 129 // SYS_rt_sigqueueinfo
const sys_rt_sigreturn = 15 // SYS_rt_sigreturn
const sys_rt_sigsuspend = 130 // SYS_rt_sigsuspend
const sys_rt_sigtimedwait = 128 // SYS_rt_sigtimedwait
const sys_rt_tgsigqueueinfo = 297 // SYS_rt_tgsigqueueinfo
const sys_sched_getaffinity = 204 // SYS_sched_getaffinity
const sys_sched_getattr = 315 // SYS_sched_getattr
const sys_sched_getparam = 143 // SYS_sched_getparam
const sys_sched_getscheduler = 145 // SYS_sched_getscheduler
const sys_sched_get_priority_max = 146 // SYS_sched_get_priority_max
const sys_sched_get_priority_min = 147 // SYS_sched_get_priority_min
const sys_sched_rr_get_interval = 148 // SYS_sched_rr_get_interval
const sys_sched_setaffinity = 203 // SYS_sched_setaffinity
const sys_sched_setattr = 314 // SYS_sched_setattr
const sys_sched_setparam = 142 // SYS_sched_setparam
const sys_sched_setscheduler = 144 // SYS_sched_setscheduler
const sys_sched_yield = 24 // SYS_sched_yield
const sys_seccomp = 317 // SYS_seccomp
const sys_security = 185 // SYS_security
const sys_select = 23 // SYS_select
const sys_semctl = 66 // SYS_semctl
const sys_semget = 64 // SYS_semget
const sys_semop = 65 // SYS_semop
const sys_semtimedop = 220 // SYS_semtimedop
const sys_sendfile = 40 // SYS_sendfile
const sys_sendmmsg = 307 // SYS_sendmmsg
const sys_sendmsg = 46 // SYS_sendmsg
const sys_sendto = 44 // SYS_sendto
const sys_setdomainname = 171 // SYS_setdomainname
const sys_setfsgid = 123 // SYS_setfsgid
const sys_setfsuid = 122 // SYS_setfsuid
const sys_setgid = 106 // SYS_setgid
const sys_setgroups = 116 // SYS_setgroups
const sys_sethostname = 170 // SYS_sethostname
const sys_setitimer = 38 // SYS_setitimer
const sys_setns = 308 // SYS_setns
const sys_setpgid = 109 // SYS_setpgid
const sys_setpriority = 141 // SYS_setpriority
const sys_setregid = 114 // SYS_setregid
const sys_setresgid = 119 // SYS_setresgid
const sys_setresuid = 117 // SYS_setresuid
const sys_setreuid = 113 // SYS_setreuid
const sys_setrlimit = 160 // SYS_setrlimit
const sys_setsid = 112 // SYS_setsid
const sys_setsockopt = 54 // SYS_setsockopt
const sys_settimeofday = 164 // SYS_settimeofday
const sys_setuid = 105 // SYS_setuid
const sys_setxattrat = 463 // SYS_setxattrat
const sys_setxattr = 188 // SYS_setxattr
const sys_set_mempolicy = 238 // SYS_set_mempolicy
const sys_set_mempolicy_home_node = 450 // SYS_set_mempolicy_home_node
const sys_set_robust_list = 273 // SYS_set_robust_list
const sys_set_thread_area = 205 // SYS_set_thread_area
const sys_set_tid_address = 218 // SYS_set_tid_address
const sys_shmat = 30 // SYS_shmat
const sys_shmctl = 31 // SYS_shmctl
const sys_shmdt = 67 // SYS_shmdt
const sys_shmget = 29 // SYS_shmget
const sys_shutdown = 48 // SYS_shutdown
const sys_sigaltstack = 131 // SYS_sigaltstack
const sys_signalfd4 = 289 // SYS_signalfd4
const sys_signalfd = 282 // SYS_signalfd
const sys_socketpair = 53 // SYS_socketpair
const sys_socket = 41 // SYS_socket
const sys_splice = 275 // SYS_splice
const sys_statfs = 137 // SYS_statfs
const sys_statmount = 457 // SYS_statmount
const sys_statx = 332 // SYS_statx
const sys_stat = 4 // SYS_stat
const sys_swapoff = 168 // SYS_swapoff
const sys_swapon = 167 // SYS_swapon
const sys_symlinkat = 266 // SYS_symlinkat
const sys_symlink = 88 // SYS_symlink
const sys_syncfs = 306 // SYS_syncfs
const sys_sync = 162 // SYS_sync
const sys_sync_file_range = 277 // SYS_sync_file_range
const sys_sysfs = 139 // SYS_sysfs
const sys_sysinfo = 99 // SYS_sysinfo
const sys_syslog = 103 // SYS_syslog
const sys_tee = 276 // SYS_tee
const sys_tgkill = 234 // SYS_tgkill
const sys_timerfd_create = 283 // SYS_timerfd_create
const sys_timerfd_gettime = 287 // SYS_timerfd_gettime
const sys_timerfd_settime = 286 // SYS_timerfd_settime
const sys_timer_create = 222 // SYS_timer_create
const sys_timer_delete = 226 // SYS_timer_delete
const sys_timer_getoverrun = 225 // SYS_timer_getoverrun
const sys_timer_gettime = 224 // SYS_timer_gettime
const sys_timer_settime = 223 // SYS_timer_settime
const sys_times = 100 // SYS_times
const sys_time = 201 // SYS_time
const sys_tkill = 200 // SYS_tkill
const sys_truncate = 76 // SYS_truncate
const sys_tuxcall = 184 // SYS_tuxcall
const sys_umask = 95 // SYS_umask
const sys_umount2 = 166 // SYS_umount2
const sys_uname = 63 // SYS_uname
const sys_unlinkat = 263 // SYS_unlinkat
const sys_unlink = 87 // SYS_unlink
const sys_unshare = 272 // SYS_unshare
const sys_uretprobe = 335 // SYS_uretprobe
const sys_uselib = 134 // SYS_uselib
const sys_userfaultfd = 323 // SYS_userfaultfd
const sys_ustat = 136 // SYS_ustat
const sys_utimensat = 280 // SYS_utimensat
const sys_utimes = 235 // SYS_utimes
const sys_utime = 132 // SYS_utime
const sys_vfork = 58 // SYS_vfork
const sys_vhangup = 153 // SYS_vhangup
const sys_vmsplice = 278 // SYS_vmsplice
const sys_vserver = 236 // SYS_vserver
const sys_wait4 = 61 // SYS_wait4
const sys_waitid = 247 // SYS_waitid
const sys_writev = 20 // SYS_writev
const sys_write = 1 // SYS_write
const sys__sysctl = 156 // SYS__sysctl
const s_blksize = 512 // S_BLKSIZE
const s_iexec = 64 // S_IEXEC
const s_ifblk = 24576 // S_IFBLK
const s_ifchr = 8192 // S_IFCHR
const s_ifdir = 16384 // S_IFDIR
const s_ififo = 4096 // S_IFIFO
const s_iflnk = 40960 // S_IFLNK
const s_ifmt = 61440 // S_IFMT
const s_ifreg = 32768 // S_IFREG
const s_ifsock = 49152 // S_IFSOCK
const s_iread = 256 // S_IREAD
const s_irgrp = 32 // S_IRGRP
const s_iroth = 4 // S_IROTH
const s_irusr = 256 // S_IRUSR
const s_irwxg = 56 // S_IRWXG
const s_irwxo = 7 // S_IRWXO
const s_irwxu = 448 // S_IRWXU
const s_isgid = 1024 // S_ISGID
const s_isuid = 2048 // S_ISUID
const s_isvtx = 512 // S_ISVTX
const s_iwgrp = 16 // S_IWGRP
const s_iwoth = 2 // S_IWOTH
const s_iwrite = 128 // S_IWRITE
const s_iwusr = 128 // S_IWUSR
const s_ixgrp = 8 // S_IXGRP
const s_ixoth = 1 // S_IXOTH
const s_ixusr = 64 // S_IXUSR
const umount_nofollow = 8 // UMOUNT_NOFOLLOW

fn C.syscall #

unsafe
fn C.syscall(i32, ...voidptr) i32

C.syscall calls syscall indirectly.

Example

import syscall

pid := C.syscall(syscall.sys_getpid)
println(pid)

fn chroot #

fn chroot(path string) !

chroot changes the root directory of the calling process. See chroot(2) for details.

Note: Only privileged process may call chroot(). On Linux CAP_SYS_CHROOT capability is required.

fn close #

fn close(fd int) !

close closes the file descriptor. See also close(2).

fn fork #

fn fork() !int

fork creates a new process and returns it's PID. See also fork(2).

fn kill #

fn kill(pid i32, sig i32) !

kill sends signal sig to process identified by pid. See also kill(2).

fn lseek #

fn lseek(fd int, offset isize, whence i32) !isize

lseek repositions read/write file offset. See also lseek(2).

fn mount #

fn mount(source string, target string, filesystemtype string, mountflags u64, data voidptr) !

mount mounts the filesystem.

Linux: See mount(2).

FreeBSD: The source argument is ignored. See mount(2).

fn open #

fn open(path string, flags i32, mode i32) !int

open opens and possibly creates a file. See open(2) for details.

fn pipe #

fn pipe() !(int, int)

pipe creates pipe. See also pipe(2).

fn pipe2 #

fn pipe2(flags i32) !(int, int)

pipe2 creates pipe. See also pipe(2).

fn pread #

fn pread(fd int, mut buf []u8, count usize, offset isize) !int

pread reads up to count bytes from file descriptor fd at offset offset (from the start of the file) into the buffer buf. The file offset is not changed. See also pread(2).

fn pwrite #

fn pwrite(fd int, buf []u8, count usize, offset isize) !int

pwrite writes up to count bytes from the buffer buf to the file descriptor fd at offset offset. The file offset is not changed. See also pwrite(2).

fn read #

fn read(fd int, mut buf []u8, count ?usize) !int

read reads data from the file descriptor fd into the buf buffer. If count is not set the buf.len bytes will read. See also read(2).

fn unmount #

fn unmount(target string, flags i32) !

unmount unmounts the filesystem mounted to target.

Linux: See umount(2). If flags is non-zero umount2 is called instead of umount.

FreeBSD: See unmount(2).

fn write #

fn write(fd int, buf []u8, count ?usize) !int

write writes data from buf into the file descriptor fd. If count is not set the buf.len bytes will written. See also write(2).