Skip to content

Commit

Permalink
Merge pull request #3125 from marcs-feh/master
Browse files Browse the repository at this point in the history
sys/linux: Add binding to ioctl syscall + standard fd constants.
  • Loading branch information
laytan authored Aug 13, 2024
2 parents 6291153 + c7af8af commit 55be3e6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
15 changes: 15 additions & 0 deletions core/sys/linux/constants.odin
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
package linux

/*
Standard input file descriptor
*/
STDIN_FILENO :: Fd(0)

/*
Standard output file descriptor
*/
STDOUT_FILENO :: Fd(1)

/*
Standard error file descriptor
*/
STDERR_FILENO :: Fd(2)

/*
Special file descriptor to pass to `*at` functions to specify
that relative paths are relative to current directory.
Expand Down
13 changes: 12 additions & 1 deletion core/sys/linux/sys.odin
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,18 @@ rt_sigprocmask :: proc "contextless" (mask_kind: Sig_Mask_Kind, new_set: ^Sig_Se
return Errno(-ret)
}

// TODO(flysand): ioctl
/*
Control devices. The ioctl syscall is a bit special because
its argument is usually a pointer to some driver-specific structure.
The request value is device-specific. Consult your LibC implementation's
ioctls.h file to learn more. The returned value of ioctl *may* be an error
code value instead of a memory address depending on the request type.
Available since Linux 1.0.
*/
ioctl :: proc "contextless" (fd: Fd, request: u32, arg: uintptr) -> (uintptr) {
ret := syscall(SYS_ioctl, fd, request, arg)
return uintptr(ret)
}

/*
Read the file at a specified offset.
Expand Down

0 comments on commit 55be3e6

Please sign in to comment.