Skip to content

Commit e98c22d

Browse files
syscall::fs: add epoll_pwait stub
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
1 parent 486cb6e commit e98c22d

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

patches/mlibc/mlibc.patch

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
From 5d484b1a17191d7ce795a2d773e4a72d8fc7490e Mon Sep 17 00:00:00 2001
1+
From a649d90c5073ef1f8a9eadb4773fe5f832a3e87c Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
33
Date: Thu, 10 Feb 2022 19:12:25 +1100
44
Subject: [PATCH] yes
55

66
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
77
---
8-
.gitignore | 3 ++
8+
.gitignore | 3 +
99
options/rtdl/generic/linker.cpp | 2 +-
10-
sysdeps/aero/generic/aero.cpp | 12 ++++-
11-
sysdeps/aero/generic/filesystem.cpp | 79 ++++++++++++++++++++++++++---
10+
sysdeps/aero/generic/aero.cpp | 12 +++-
11+
sysdeps/aero/generic/filesystem.cpp | 97 ++++++++++++++++++++++++++---
1212
sysdeps/aero/generic/signals.cpp | 8 ++-
13-
sysdeps/aero/generic/sockets.cpp | 48 ++++++++++++++++++
14-
sysdeps/aero/include/aero/syscall.h | 12 +++++
15-
7 files changed, 151 insertions(+), 13 deletions(-)
13+
sysdeps/aero/generic/sockets.cpp | 48 ++++++++++++++
14+
sysdeps/aero/include/aero/syscall.h | 11 ++++
15+
7 files changed, 168 insertions(+), 13 deletions(-)
1616

1717
diff --git a/.gitignore b/.gitignore
1818
index dbb35e8b..20c8d4c3 100644
@@ -69,7 +69,7 @@ index 7de909f5..4281beb9 100644
6969
#endif
7070
} // namespace mlibc
7171
diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp
72-
index 6a13f19c..d34dfce3 100644
72+
index 6a13f19c..8f700a38 100644
7373
--- a/sysdeps/aero/generic/filesystem.cpp
7474
+++ b/sysdeps/aero/generic/filesystem.cpp
7575
@@ -1,3 +1,4 @@
@@ -151,7 +151,7 @@ index 6a13f19c..d34dfce3 100644
151151
return 0;
152152
}
153153

154-
@@ -267,4 +297,37 @@ int sys_pipe(int *fds, int flags) {
154+
@@ -267,4 +297,55 @@ int sys_pipe(int *fds, int flags) {
155155

156156
return 0;
157157
}
@@ -178,6 +178,24 @@ index 6a13f19c..d34dfce3 100644
178178
+ return 0;
179179
+}
180180
+
181+
+int sys_epoll_pwait(
182+
+ int epfd,
183+
+ struct epoll_event *ev,
184+
+ int n,
185+
+ int timeout,
186+
+ const sigset_t *sigmask,
187+
+ int *raised
188+
+) {
189+
+ auto result = syscall(SYS_EPOLL_PWAIT, epfd, ev, n, timeout, sigmask);
190+
+
191+
+ if (result < 0) {
192+
+ return -result;
193+
+ }
194+
+
195+
+ *raised = result;
196+
+ return 0;
197+
+}
198+
+
181199
+int sys_eventfd_create(unsigned int initval, int flags, int *fd) {
182200
+ auto result = syscall(SYS_EVENT_FD, initval, flags);
183201
+
@@ -263,10 +281,10 @@ index e69de29b..4e6bd608 100644
263281
+}
264282
+} // namespace mlibc
265283
diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
266-
index 07b1b51b..ef797e40 100644
284+
index 07b1b51b..6487cd85 100644
267285
--- a/sysdeps/aero/include/aero/syscall.h
268286
+++ b/sysdeps/aero/include/aero/syscall.h
269-
@@ -49,6 +49,18 @@
287+
@@ -49,6 +49,17 @@
270288
#define SYS_DUP 42
271289
#define SYS_FCNTL 43
272290
#define SYS_DUP2 44
@@ -280,8 +298,7 @@ index 07b1b51b..ef797e40 100644
280298
+#define SYS_EPOLL_CREATE 52
281299
+#define SYS_EPOLL_PWAIT 53
282300
+#define SYS_EPOLL_CTL 54
283-
+#define SYS_EPOLL_WAIT 55
284-
+#define SYS_EVENT_FD 56
301+
+#define SYS_EVENT_FD 55
285302

286303
// Invalid syscall used to trigger a log error in the kernel (as a hint)
287304
// so, that we can implement the syscall in the kernel.

src/aero_kernel/src/syscall/fs.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ pub fn epoll_ctl(
414414
fd: usize,
415415
event: &mut EPollEvent,
416416
) -> Result<usize, AeroSyscallError> {
417-
let current_task = scheduler::get_scheduler().current_task();
418-
let epfd = current_task
417+
let epfd = scheduler::get_scheduler()
418+
.current_task()
419419
.file_table
420420
.get_handle(epfd)
421421
.ok_or(AeroSyscallError::EBADFD)?;
@@ -433,6 +433,23 @@ pub fn epoll_ctl(
433433
}
434434
}
435435

436+
#[syscall]
437+
pub fn epoll_pwait(
438+
epfd: usize,
439+
_event: &mut EPollEvent,
440+
_max_events: usize,
441+
_timeout: usize,
442+
_sigmask: usize,
443+
) -> Result<usize, AeroSyscallError> {
444+
let _epfd = scheduler::get_scheduler()
445+
.current_task()
446+
.file_table
447+
.get_handle(epfd)
448+
.ok_or(AeroSyscallError::EBADFD)?;
449+
450+
Ok(0)
451+
}
452+
436453
#[syscall]
437454
pub fn event_fd(_initval: usize, flags: usize) -> Result<usize, AeroSyscallError> {
438455
let flags = EventFdFlags::from_bits(flags).ok_or(AeroSyscallError::EINVAL)?;

src/aero_kernel/src/syscall/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ pub fn generic_do_syscall(
207207
// epoll calls:
208208
SYS_EPOLL_CREATE => fs::epoll_create(b),
209209
SYS_EPOLL_CTL => fs::epoll_ctl(b, c, d, e),
210+
SYS_EPOLL_PWAIT => fs::epoll_pwait(b, c, d, e, f),
210211

211212
SYS_SOCKET => net::socket(b, c, d),
212213
SYS_BIND => net::bind(b, c, d),

src/aero_syscall/src/consts.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ pub const SYS_READ_LINK: usize = 51;
7575
pub const SYS_EPOLL_CREATE: usize = 52;
7676
pub const SYS_EPOLL_PWAIT: usize = 53;
7777
pub const SYS_EPOLL_CTL: usize = 54;
78-
pub const SYS_EPOLL_WAIT: usize = 55;
79-
pub const SYS_EVENT_FD: usize = 56;
78+
pub const SYS_EVENT_FD: usize = 55;
8079

8180
// constants for fcntl()'s command argument:
8281
pub const F_DUPFD: usize = 1;

src/aero_syscall/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ pub fn syscall_as_str(syscall: usize) -> &'static str {
224224
prelude::SYS_EPOLL_CREATE => "epoll_create",
225225
prelude::SYS_EPOLL_PWAIT => "epoll_pwait",
226226
prelude::SYS_EPOLL_CTL => "epoll_ctl",
227-
prelude::SYS_EPOLL_WAIT => "epoll_wait",
228227
prelude::SYS_EVENT_FD => "event_fd",
229228

230229
_ => unreachable!("unknown syscall {syscall}"),

0 commit comments

Comments
 (0)