Skip to contentSkip to conversation

y2038: cobalt/posix/muqueue: Adding mq_timedreceive64

PATCH New Song Chen 1 participant 1 message Jun 8, 2021

lore
Share & tools
lore

Song Chen

author
#0 lore raw

PATCH 3/5 y2038: cobalt/posix/muqueue: Adding mq_timedreceive64

Add a syscall specific for mq_timedreceive with 64bit time_t.

---
 include/cobalt/uapi/syscall.h   |  1 +
 kernel/cobalt/posix/mqueue.c    | 28 ++++++++++++++++++++++++++++
 kernel/cobalt/posix/mqueue.h    | 11 +++++++++++
 kernel/cobalt/posix/syscall32.c | 10 ++++++++++
 kernel/cobalt/posix/syscall32.h |  6 ++++++
 5 files changed, 56 insertions(+)
include/cobalt/uapi/syscall.h +1 -0
index 464e170..c27d6d0 100644
@@ -130,6 +130,7 @@
 #define sc_cobalt_clock_adjtime64		107
 #define sc_cobalt_mutex_timedlock64		108
 #define sc_cobalt_mq_timedsend64		109
+#define sc_cobalt_mq_timedreceive64		110
 
 #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
 
kernel/cobalt/posix/mqueue.c +28 -0
index 9179427..2bb2fb7 100644
@@ -1031,3 +1031,31 @@ COBALT_SYSCALL(mq_timedreceive, primary,
 
 	return ret ?: cobalt_copy_to_user(u_len, &len, sizeof(*u_len));
 }
+
+int __cobalt_mq_timedreceive64(mqd_t uqd, void __user *u_buf,
+				 ssize_t __user *u_len,
+			     unsigned int __user *u_prio,
+			     const void __user *u_ts)
+{
+	ssize_t len;
+	int ret;
+
+	ret = cobalt_copy_from_user(&len, u_len, sizeof(len));
+	if (ret)
+		return ret;
+
+	ret = __cobalt_mq_timedreceive(uqd, u_buf, &len, u_prio,
+				       u_ts, u_ts ? mq_fetch_timeout64 : NULL);
+
+	return ret ?: cobalt_copy_to_user(u_len, &len, sizeof(*u_len));
+}
+
+COBALT_SYSCALL(mq_timedreceive64, primary,
+	       (mqd_t uqd, void __user *u_buf,
+		ssize_t __user *u_len,
+		unsigned int __user *u_prio,
+		const struct __kernel_timespec __user *u_ts))
+{
+	return __cobalt_mq_timedreceive64(uqd, u_buf, u_len, u_prio,
+				       u_ts);
+}
kernel/cobalt/posix/mqueue.h +11 -0
index f8414f4..6ef986b 100644
@@ -50,6 +50,11 @@ int __cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
 			     int (*fetch_timeout)(struct timespec64 *ts,
 						  const void __user *u_ts));
 
+int __cobalt_mq_timedreceive64(mqd_t uqd, void __user *u_buf,
+				 ssize_t __user *u_len,
+			     unsigned int __user *u_prio,
+			     const void __user *u_ts);
+
 int __cobalt_mq_notify(mqd_t fd, const struct sigevent *evp);
 
 COBALT_SYSCALL_DECL(mq_open,
@@ -76,6 +81,12 @@ COBALT_SYSCALL_DECL(mq_timedreceive,
 		     unsigned int __user *u_prio,
 		     const struct __user_old_timespec __user *u_ts));
 
+COBALT_SYSCALL(mq_timedreceive64, primary,
+	       (mqd_t uqd, void __user *u_buf,
+		ssize_t __user *u_len,
+		unsigned int __user *u_prio,
+		const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL_DECL(mq_notify,
 		    (mqd_t fd, const struct sigevent *__user evp));
 
kernel/cobalt/posix/syscall32.c +10 -0
index 716fc16..e24c96a 100644
@@ -354,6 +354,16 @@ COBALT_SYSCALL32emu(mq_timedreceive, primary,
 	return ret ?: cobalt_copy_to_user(u_len, &clen, sizeof(*u_len));
 }
 
+COBALT_SYSCALL32emu(mq_timedreceive64, primary,
+		    (mqd_t uqd, void __user *u_buf,
+		     ssize_t __user *u_len,
+		     unsigned int __user *u_prio,
+		     const struct __kernel_timespec __user *u_ts))
+{
+	return __cobalt_mq_timedreceive64(uqd, u_buf, u_len, u_prio,
+				       u_ts);
+}
+
 static inline int mq_fetch_timeout(struct timespec64 *ts,
 				   const void __user *u_ts)
 {
kernel/cobalt/posix/syscall32.h +6 -0
index dd0e43d..3a551b9 100644
@@ -132,6 +132,12 @@ COBALT_SYSCALL32emu_DECL(mq_timedreceive,
 			  unsigned int __user *u_prio,
 			  const struct old_timespec32 __user *u_ts));
 
+COBALT_SYSCALL32emu(mq_timedreceive64, primary,
+		    (mqd_t uqd, void __user *u_buf,
+		     ssize_t __user *u_len,
+		     unsigned int __user *u_prio,
+		     const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL32emu_DECL(mq_notify,
 			 (mqd_t fd, const struct compat_sigevent *__user u_cev));
 
Signature · 1 line
2.7.4