Skip to contentSkip to conversation

y2038: cobalt/posix/clock: Adding clock_adjtime64

PATCH In review Song Chen 1 participant 1 message Apr 29, 2021

lore
Share & tools
lore

Song Chen

author
#0 lore raw

PATCH 1/3 y2038: cobalt/posix/clock: Adding clock_adjtime64

Add a syscall specific for clock_adjtime with 64bit time_t.

---
 include/cobalt/uapi/syscall.h   |  1 +
 kernel/cobalt/posix/clock.c     | 22 ++++++++++++++++++++++
 kernel/cobalt/posix/clock.h     |  6 ++++++
 kernel/cobalt/posix/syscall32.c |  7 +++++++
 kernel/cobalt/posix/syscall32.h |  4 ++++
 5 files changed, 40 insertions(+)
include/cobalt/uapi/syscall.h +1 -0
index 0e178cd..a2795a3 100644
@@ -127,6 +127,7 @@
 #define sc_cobalt_clock_settime64		104
 #define sc_cobalt_clock_nanosleep64		105
 #define sc_cobalt_clock_getres64		106
+#define sc_cobalt_clock_adjtime64		107
 
 #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
 
kernel/cobalt/posix/clock.c +22 -0
index 929b097..71d14db 100644
@@ -271,6 +271,28 @@ COBALT_SYSCALL(clock_adjtime, current,
 	return cobalt_copy_to_user(u_tx, &tx, sizeof(tx));
 }
 
+int __cobalt_clock_adjtime64(clockid_t clock_id,
+			struct __kernel_timex __user *u_tx)
+{
+	struct __kernel_timex tx;
+	int ret;
+
+	if (cobalt_copy_from_user(&tx, u_tx, sizeof(tx)))
+		return -EFAULT;
+
+	ret = __cobalt_clock_adjtime(clock_id, &tx);
+	if (ret)
+		return ret;
+
+	return cobalt_copy_to_user(u_tx, &tx, sizeof(tx));
+}
+
+COBALT_SYSCALL(clock_adjtime64, current,
+	       (clockid_t clock_id, struct __kernel_timex __user *u_tx))
+{
+	return __cobalt_clock_adjtime64(clock_id, u_tx);
+}
+
 int __cobalt_clock_nanosleep(clockid_t clock_id, int flags,
 			     const struct timespec64 *rqt,
 			     struct timespec64 *rmt)
kernel/cobalt/posix/clock.h +6 -0
index 473c6aa..e183739 100644
@@ -115,6 +115,9 @@ int __cobalt_clock_settime64(clockid_t clock_id,
 int __cobalt_clock_adjtime(clockid_t clock_id,
 			   struct __kernel_timex *tx);
 
+int __cobalt_clock_adjtime64(clockid_t clock_id,
+			struct __kernel_timex __user *u_tx);
+
 int __cobalt_clock_nanosleep(clockid_t clock_id, int flags,
 			     const struct timespec64 *rqt,
 			     struct timespec64 *rmt);
@@ -145,6 +148,9 @@ COBALT_SYSCALL_DECL(clock_settime64,
 COBALT_SYSCALL_DECL(clock_adjtime,
 		    (clockid_t clock_id, struct __user_old_timex __user *u_tx));
 
+COBALT_SYSCALL_DECL(clock_adjtime64,
+		    (clockid_t clock_id, struct __kernel_timex __user *u_tx));
+
 COBALT_SYSCALL_DECL(clock_nanosleep,
 		    (clockid_t clock_id, int flags,
 		     const struct __user_old_timespec __user *u_rqt,
kernel/cobalt/posix/syscall32.c +7 -0
index 36f2e3c..9089f7d 100644
@@ -223,6 +223,13 @@ COBALT_SYSCALL32emu(clock_adjtime, current,
 	return sys32_put_timex(u_tx, &tx);
 }
 
+COBALT_SYSCALL32emu(clock_adjtime64, current,
+		    (clockid_t clock_id, struct __kernel_timex __user *u_tx))
+{
+	return __cobalt_clock_adjtime64(clock_id, u_tx);
+}
+
+
 COBALT_SYSCALL32emu(clock_nanosleep, nonrestartable,
 		    (clockid_t clock_id, int flags,
 		     const struct old_timespec32 __user *u_rqt,
kernel/cobalt/posix/syscall32.h +4 -0
index d03b640..a4ce675 100644
@@ -79,6 +79,10 @@ COBALT_SYSCALL32emu_DECL(clock_adjtime,
 			 (clockid_t clock_id,
 			  struct old_timex32 __user *u_tx));
 
+COBALT_SYSCALL32emu_DECL(clock_adjtime64,
+			 (clockid_t clock_id,
+			  struct __kernel_timex __user *u_tx));
+
 COBALT_SYSCALL32emu_DECL(clock_nanosleep,
 			 (clockid_t clock_id, int flags,
 			  const struct old_timespec32 __user *u_rqt,
Signature · 1 line
2.7.4