From 40b1cec31e33b477e4fc73532a760073f923cc65 Mon Sep 17 00:00:00 2001 From: David Carlier <devnexen@gmail.com> Date: Tue, 18 Apr 2023 21:24:53 +0100 Subject: [PATCH] stdlib: unlockpt implementation proposal --- src/header/stdlib/mod.rs | 6 ++++-- src/header/sys_ioctl/redox.rs | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index a4037c700..e16b03b41 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -18,6 +18,7 @@ use crate::{ limits, stdio::flush_io_streams, string::*, + sys_ioctl::*, time::constants::CLOCK_MONOTONIC, unistd::{self, sysconf, _SC_PAGESIZE}, wchar::*, @@ -1213,8 +1214,9 @@ pub extern "C" fn ttyslot() -> c_int { } // #[no_mangle] -pub extern "C" fn unlockpt(fildes: c_int) -> c_int { - unimplemented!(); +pub unsafe extern "C" fn unlockpt(fildes: c_int) -> c_int { + let mut u: c_int = 0; + ioctl(fildes, TIOCSPTLCK, &mut u as *mut i32 as *mut c_void) } #[no_mangle] diff --git a/src/header/sys_ioctl/redox.rs b/src/header/sys_ioctl/redox.rs index 3661fed41..8c0a2ea48 100644 --- a/src/header/sys_ioctl/redox.rs +++ b/src/header/sys_ioctl/redox.rs @@ -26,6 +26,8 @@ pub const TIOCSPGRP: c_ulong = 0x5410; pub const TIOCGWINSZ: c_ulong = 0x5413; pub const TIOCSWINSZ: c_ulong = 0x5414; +pub const TIOCSPTLCK: c_ulong = 0x4004_5431; +pub const TIOCGPTLCK: c_ulong = 0x8004_5439; // TODO: some of the structs passed as T have padding bytes, so casting to a byte slice is UB @@ -133,6 +135,12 @@ pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> 0 } } + TIOCGPTLCK => { + 0 + }, + TIOCSPTLCK => { + 0 + }, TCSBRK => { // TODO 0 -- GitLab