Skip to content

Commit f6547d1

Browse files
committed
kind of poc for the beginning
1 parent 25b0008 commit f6547d1

File tree

11 files changed

+185
-3
lines changed

11 files changed

+185
-3
lines changed

Config.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
// https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project
1010

1111
VERSION = 0.9.0
12-
BUILD_NUMBER = 20260224.99.US.seanistethered
12+
BUILD_NUMBER = 20260224.102.US.seanistethered

Nyxian.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
LindChain/ProcEnvironment/environment.m,
199199
LindChain/ProcEnvironment/fork.m,
200200
LindChain/ProcEnvironment/hostname.m,
201+
LindChain/ProcEnvironment/ioctl.m,
201202
LindChain/ProcEnvironment/kysapple.m,
202203
LindChain/ProcEnvironment/libproc.m,
203204
LindChain/ProcEnvironment/Object/ArchiveObject.m,
@@ -310,6 +311,7 @@
310311
LindChain/ProcEnvironment/environment.m,
311312
LindChain/ProcEnvironment/fork.m,
312313
LindChain/ProcEnvironment/hostname.m,
314+
LindChain/ProcEnvironment/ioctl.m,
313315
LindChain/ProcEnvironment/kysapple.m,
314316
LindChain/ProcEnvironment/libproc.m,
315317
LindChain/ProcEnvironment/Object/ArchiveObject.m,

Nyxian/LindChain/Multitask/WindowServer/Session/LDEWindowSessionTerminal.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#import <LindChain/Multitask/ProcessManager/LDEProcessManager.h>
2121
#import <LindChain/Multitask/WindowServer/Session/LDEWindowSessionTerminal.h>
22+
#import <LindChain/ProcEnvironment/Surface/tty/tty.h>
2223
#import <Nyxian-Swift.h>
2324

2425
@interface LDEWindowSessionTerminal ()
@@ -56,12 +57,21 @@ - (BOOL)openWindow
5657
self.stdoutPipe = [NSPipe pipe];
5758
self.stdinPipe = [NSPipe pipe];
5859

60+
/*
61+
* in theory creating it before the process exists,
62+
* to have pipes to handoff.
63+
*/
64+
ksurface_tty_t *tty = kvo_alloc_fastpath(tty);
65+
5966
FDMapObject *mapObject = [FDMapObject emptyMap];
6067
[mapObject insertOutFD:self.stdoutPipe.fileHandleForWriting.fileDescriptor ErrFD:self.stdoutPipe.fileHandleForWriting.fileDescriptor InPipe:self.stdinPipe.fileHandleForReading.fileDescriptor];
6168
LDEProcess *process = nil;
6269
[[LDEProcessManager shared] spawnProcessWithPath:_utilityPath withArguments:@[self.utilityPath] withEnvironmentVariables:@{} withMapObject:mapObject withKernelSurfaceProcess:kernel_proc_ enableDebugging:YES process:&process withSession:nil];
6370
_process = process;
6471

72+
/* attaching tty to process lifecycle */
73+
tty_attach_proc(_process.proc, tty);
74+
6575
_terminal = [[NyxianTerminal alloc] initWithFrame:self.windowRect title:process.executablePath.lastPathComponent stdoutFD:self.stdoutPipe.fileHandleForReading.fileDescriptor stdinFD:self.stdinPipe.fileHandleForWriting.fileDescriptor];
6676
_terminal.translatesAutoresizingMaskIntoConstraints = NO;
6777

Nyxian/LindChain/ProcEnvironment/Surface/mapping.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define PROCENVIRONMENT_MAPPING_H
2222

2323
#import <LindChain/ProcEnvironment/Surface/proc/def.h>
24+
#import <LindChain/ProcEnvironment/Surface/tty/def.h>
2425
#import <LindChain/ProcEnvironment/Syscall/mach_syscall_server.h>
2526
#import <LindChain/ProcEnvironment/Syscall/mach_syscall_client.h>
2627
#import <LindChain/ProcEnvironment/Surface/radix/radix.h>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright (C) 2025 cr4zyengineer
3+
4+
This file is part of Nyxian.
5+
6+
Nyxian is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
Nyxian is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with Nyxian. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef SURFACE_SYS_IOCTL_H
21+
#define SURFACE_SYS_IOCTL_H
22+
23+
#import <LindChain/ProcEnvironment/Surface/surface.h>
24+
25+
DEFINE_SYSCALL_HANDLER(ioctl);
26+
27+
#endif /* SURFACE_SYS_IOCTL_H */
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright (C) 2025 cr4zyengineer
3+
4+
This file is part of Nyxian.
5+
6+
Nyxian is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
Nyxian is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with Nyxian. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#import <LindChain/ProcEnvironment/Surface/sys/host/ioctl.h>
21+
#import <LindChain/ProcEnvironment/Surface/tty/tty.h>
22+
#include <termios.h>
23+
24+
DEFINE_SYSCALL_HANDLER(ioctl)
25+
{
26+
sys_name("SYS_ioctl");
27+
sys_need_in_ports_with_cnt(1);
28+
29+
/* prepare arguments */
30+
fileport_t port = in_ports[0];
31+
int flag = (int)args[1];
32+
/* userspace_pointer_t termios_ptr = (userspace_pointer_t)args[2]; MARK: coming later */
33+
34+
/* compatibility flag */
35+
if(flag != TIOCGETA)
36+
{
37+
sys_return_failure(ENOSYS);
38+
}
39+
40+
/* looking up tty */
41+
ksurface_tty_t *tty = NULL;
42+
ksurface_return_t ksr = tty_for_port(port, &tty);
43+
44+
/* final check */
45+
if(ksr != SURFACE_SUCCESS)
46+
{
47+
sys_return_failure(ENOTTY);
48+
}
49+
50+
sys_return;
51+
}

Nyxian/LindChain/ProcEnvironment/Surface/sys/syscall.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#import <LindChain/ProcEnvironment/Surface/sys/host/sysctl.h>
3939
#import <LindChain/ProcEnvironment/Surface/sys/proc/wait4.h>
4040
#import <LindChain/ProcEnvironment/Surface/sys/proc/exit.h>
41+
#import <LindChain/ProcEnvironment/Surface/sys/host/ioctl.h>
4142
#include <sys/syscall.h>
4243

4344
/* additional nyxian syscalls for now */
@@ -52,7 +53,7 @@
5253
#define SYS_procbsd 758 /* MARK: deprecated.. use SYS_sysctl instead */
5354
#define SYS_handoffep 759 /* handoff exception port to kvirt */
5455

55-
#define SYS_N 26
56+
#define SYS_N 27
5657

5758
typedef struct {
5859
const char *name;

Nyxian/LindChain/ProcEnvironment/Surface/sys/syscall.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@
4747
{ .name = "SYS_sysctlbyname", .sysnum = SYS_sysctlbyname, .hndl = GET_SYSCALL_HANDLER(sysctlbyname) },
4848
{ .name = "SYS_wait4", .sysnum = SYS_wait4, .hndl = GET_SYSCALL_HANDLER(wait4) },
4949
{ .name = "SYS_exit", .sysnum = SYS_exit, .hndl = GET_SYSCALL_HANDLER(exit) },
50+
{ .name = "SYS_ioctl", .sysnum = SYS_ioctl, .hndl = GET_SYSCALL_HANDLER(ioctl) },
5051
};

Nyxian/LindChain/ProcEnvironment/Surface/tty/tty.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
#ifndef TTY_TTY_H
2121
#define TTY_TTY_H
2222

23-
#import <LindChain/ProcEnvironment/Surface/surface.h>
2423
#import <LindChain/ProcEnvironment/Surface/tty/def.h>
24+
#import <LindChain/ProcEnvironment/Surface/tty/attach.h>
25+
#import <LindChain/ProcEnvironment/Surface/tty/lookup.h>
2526

2627
DEFINE_KVOBJECT_MAIN_EVENT_HANDLER(tty);
2728

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright (C) 2025 cr4zyengineer
3+
4+
This file is part of Nyxian.
5+
6+
Nyxian is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
Nyxian is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with Nyxian. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef PROCENVIRONMENT_IOCTL_H
21+
#define PROCENVIRONMENT_IOCTL_H
22+
23+
#include <sys/sysctl.h>
24+
25+
void environment_ioctl_init(void);
26+
27+
#endif /* PROCENVIRONMENT_IOCTL_H */

0 commit comments

Comments
 (0)