mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibCore: Add syscall wrappers for tcgetattr() and tcsetattr()
This commit is contained in:
parent
2b0c2360bb
commit
612eafea2c
2 changed files with 19 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
||||||
|
@ -241,4 +242,19 @@ ErrorOr<void> ioctl(int fd, unsigned request, ...)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<struct termios> tcgetattr(int fd)
|
||||||
|
{
|
||||||
|
struct termios ios = {};
|
||||||
|
if (::tcgetattr(fd, &ios) < 0)
|
||||||
|
return Error::from_syscall("tcgetattr"sv, -errno);
|
||||||
|
return ios;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const& ios)
|
||||||
|
{
|
||||||
|
if (::tcsetattr(fd, optional_actions, &ios) < 0)
|
||||||
|
return Error::from_syscall("tcsetattr"sv, -errno);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <AK/Error.h>
|
#include <AK/Error.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
namespace Core::System {
|
namespace Core::System {
|
||||||
|
|
||||||
|
@ -37,5 +38,7 @@ ErrorOr<int> dup2(int source_fd, int destination_fd);
|
||||||
ErrorOr<String> ptsname(int fd);
|
ErrorOr<String> ptsname(int fd);
|
||||||
ErrorOr<String> gethostname();
|
ErrorOr<String> gethostname();
|
||||||
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
||||||
|
ErrorOr<struct termios> tcgetattr(int fd);
|
||||||
|
ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue