Skip to content

Commit c8b2f17

Browse files
bootstrap::mlibc: add sys_ptsname sysdep
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent e29d5f8 commit c8b2f17

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

patches/mlibc/mlibc.patch

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From 9591f4a8fe0242eafb16c5816455f1d763b19b77 Mon Sep 17 00:00:00 2001
1+
From adcc64e89eb5e570e6ad2bc578fd8b891ee6bd9a Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <[email protected]>
3-
Date: Wed, 1 Feb 2023 16:53:35 +1100
3+
Date: Fri, 17 Feb 2023 19:21:05 +1100
44
Subject: [PATCH] <xxx>
55

66
---
@@ -10,12 +10,12 @@ Subject: [PATCH] <xxx>
1010
options/posix/generic/dlfcn-stubs.cpp | 1 +
1111
options/rtdl/generic/linker.cpp | 2 +-
1212
sysdeps/aero/generic/aero.cpp | 69 ++++++----
13-
sysdeps/aero/generic/filesystem.cpp | 35 ++++-
13+
sysdeps/aero/generic/filesystem.cpp | 51 ++++++-
1414
sysdeps/aero/generic/sockets.cpp | 87 +++++++++++-
1515
sysdeps/aero/generic/time.cpp | 24 ++++
1616
sysdeps/aero/include/aero/syscall.h | 9 ++
1717
sysdeps/aero/meson.build | 1 +
18-
11 files changed, 374 insertions(+), 46 deletions(-)
18+
11 files changed, 389 insertions(+), 47 deletions(-)
1919
create mode 100644 sysdeps/aero/generic/time.cpp
2020

2121
diff --git a/.gitignore b/.gitignore
@@ -269,7 +269,7 @@ index fc9fd84..ab57631 100644
269269
return __dlapi_open(file, flags, ra);
270270
}
271271
diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp
272-
index 2e2d3f1..3ff5fef 100644
272+
index 6eb9d09..2ab5bc9 100644
273273
--- a/options/rtdl/generic/linker.cpp
274274
+++ b/options/rtdl/generic/linker.cpp
275275
@@ -18,7 +18,7 @@ uintptr_t libraryBase = 0x41000000;
@@ -412,10 +412,20 @@ index 29fb961..b5945a8 100644
412412
}
413413

414414
diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp
415-
index a3e2aca..a4edac3 100644
415+
index a3e2aca..8a1e086 100644
416416
--- a/sysdeps/aero/generic/filesystem.cpp
417417
+++ b/sysdeps/aero/generic/filesystem.cpp
418-
@@ -158,11 +158,6 @@ int sys_tcsetattr(int fd, int optional_action, const struct termios *attr) {
418+
@@ -118,7 +118,8 @@ int sys_ioctl(int fd, unsigned long request, void *arg, int *result) {
419+
return -sys_res;
420+
}
421+
422+
- *result = sys_res;
423+
+ if (result)
424+
+ *result = sys_res;
425+
return 0;
426+
}
427+
428+
@@ -158,11 +159,6 @@ int sys_tcsetattr(int fd, int optional_action, const struct termios *attr) {
419429
return 0;
420430
}
421431

@@ -427,7 +437,7 @@ index a3e2aca..a4edac3 100644
427437
int sys_mkdir(const char *path, mode_t) {
428438
auto result = syscall(SYS_MKDIR, path, strlen(path));
429439

430-
@@ -243,7 +238,15 @@ int sys_open_dir(const char *path, int *handle) {
440+
@@ -243,7 +239,15 @@ int sys_open_dir(const char *path, int *handle) {
431441
return sys_open(path, O_DIRECTORY, 0, handle);
432442
}
433443

@@ -444,7 +454,7 @@ index a3e2aca..a4edac3 100644
444454

445455
int sys_readlink(const char *path, void *buffer, size_t max_size, ssize_t *length) {
446456
auto result = syscall(SYS_READ_LINK, path, strlen(path), buffer, max_size);
447-
@@ -357,4 +360,24 @@ int sys_eventfd_create(unsigned int initval, int flags, int *fd) {
457+
@@ -357,4 +361,37 @@ int sys_eventfd_create(unsigned int initval, int flags, int *fd) {
448458
*fd = result;
449459
return 0;
450460
}
@@ -468,6 +478,19 @@ index a3e2aca..a4edac3 100644
468478
+
469479
+ return sys_ppoll(fds, count, &ts, NULL, num_events);
470480
+}
481+
+
482+
+#ifndef MLIBC_BUILDING_RTDL
483+
+#include <stdio.h>
484+
+int sys_ptsname(int fd, char *buffer, size_t length) {
485+
+ int index;
486+
+ if(int e = sys_ioctl(fd, TIOCGPTN, &index, NULL); e)
487+
+ return e;
488+
+ if((size_t)snprintf(buffer, length, "/dev/pts/%d", index) >= length) {
489+
+ return ERANGE;
490+
+ }
491+
+ return 0;
492+
+}
493+
+#endif
471494
} // namespace mlibc
472495
diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp
473496
index b6b18fe..b4635df 100644

0 commit comments

Comments
 (0)