sysdeps/linux: add ioctl, access, tcgetattr, tcsetattr sysdeps
#define NR_sigaction 13
#define NR_rt_sigprocmask 14
#define NR_ioctl 16
+#define NR_access 21
#define NR_pipe 22
#define NR_select 23
#define NR_nanosleep 35
@@ -296,6 +297,15 @@ int sys_isatty(int fd) {
return 1;
}
+int sys_ioctl(int fd, unsigned long request, void *arg, int *result) {
+ auto ret = do_syscall(NR_ioctl, fd, request, arg);
+ if (int e = sc_error(ret); e)
+ return e;
+ if (result)
+ *result = sc_int_result<unsigned long>(ret);
+ return 0;
+}
+
int sys_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
auto ret = do_cp_syscall(NR_connect, sockfd, addr, addrlen);
if (int e = sc_error(ret); e)
@@ -398,6 +408,36 @@ int sys_tgkill(int tgid, int tid, int sig) {
return 0;
}
+int sys_tcgetattr(int fd, struct termios *attr) {
+ auto ret = do_syscall(NR_ioctl, fd, TCGETS, attr);
+ if (int e = sc_error(ret); e)
+ return e;
+ return 0;
+}
+
+int sys_tcsetattr(int fd, int optional_action, const struct termios *attr) {
+ int req;
+
+ switch (optional_action) {
+ case TCSANOW: req = TCSETS; break;
+ case TCSADRAIN: req = TCSETSW; break;
+ case TCSAFLUSH: req = TCSETSF; break;
+ default: return EINVAL;
+ }
+
+ auto ret = do_syscall(NR_ioctl, fd, req, attr);
+ if (int e = sc_error(ret); e)
+ return e;
+ return 0;
+}
+
+int sys_access(const char *path, int mode) {
+ auto ret = do_syscall(NR_access, path, mode);
+ if (int e = sc_error(ret); e)
+ return e;
+ return 0;
+}
+
#endif // __MLIBC_POSIX_OPTION
pid_t sys_getpid() {
