Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2022 19:39:48 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d32db5360bee - stable/13 - linux(4): Implement timerfd_gettime64 syscall.
Message-ID:  <202206171939.25HJdmLv016490@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=d32db5360bee9de70603db121f8ca05d2eb21a63

commit d32db5360bee9de70603db121f8ca05d2eb21a63
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-05-04 10:06:52 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:34:37 +0000

    linux(4): Implement timerfd_gettime64 syscall.
    
    MFC after:              2 weeks
    
    (cherry picked from commit ce9f8d6ab00c491f84a021b23a28a1484ef817d8)
---
 sys/amd64/linux32/linux32_dummy_machdep.c |  1 -
 sys/compat/linux/linux_event.c            | 44 +++++++++++++++++++++++++------
 sys/i386/linux/linux_dummy_machdep.c      |  1 -
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c
index 6b264e2891f1..0cc1cd581c32 100644
--- a/sys/amd64/linux32/linux32_dummy_machdep.c
+++ b/sys/amd64/linux32/linux32_dummy_machdep.c
@@ -68,7 +68,6 @@ DUMMY(mq_getsetattr);
 DUMMY(arch_prctl);
 /* Linux 5.0: */
 DUMMY(clock_adjtime64);
-DUMMY(timerfd_gettime64);
 DUMMY(io_pgetevents_time64);
 DUMMY(recvmmsg_time64);
 DUMMY(mq_timedsend_time64);
diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c
index f3191c910013..1ac1052def7b 100644
--- a/sys/compat/linux/linux_event.c
+++ b/sys/compat/linux/linux_event.c
@@ -902,16 +902,14 @@ linux_timerfd_curval(struct timerfd *tfd, struct itimerspec *ots)
 	}
 }
 
-int
-linux_timerfd_gettime(struct thread *td, struct linux_timerfd_gettime_args *args)
+static int
+linux_timerfd_gettime_common(struct thread *td, int fd, struct itimerspec *ots)
 {
-	struct l_itimerspec lots;
-	struct itimerspec ots;
 	struct timerfd *tfd;
 	struct file *fp;
 	int error;
 
-	error = fget(td, args->fd, &cap_read_rights, &fp);
+	error = fget(td, fd, &cap_read_rights, &fp);
 	if (error != 0)
 		return (error);
 	tfd = fp->f_data;
@@ -921,17 +919,47 @@ linux_timerfd_gettime(struct thread *td, struct linux_timerfd_gettime_args *args
 	}
 
 	mtx_lock(&tfd->tfd_lock);
-	linux_timerfd_curval(tfd, &ots);
+	linux_timerfd_curval(tfd, ots);
 	mtx_unlock(&tfd->tfd_lock);
 
+out:
+	fdrop(fp, td);
+	return (error);
+}
+
+int
+linux_timerfd_gettime(struct thread *td, struct linux_timerfd_gettime_args *args)
+{
+	struct l_itimerspec lots;
+	struct itimerspec ots;
+	int error;
+
+	error = linux_timerfd_gettime_common(td, args->fd, &ots);
+	if (error != 0)
+		return (error);
 	error = native_to_linux_itimerspec(&lots, &ots);
 	if (error == 0)
 		error = copyout(&lots, args->old_value, sizeof(lots));
+	return (error);
+}
 
-out:
-	fdrop(fp, td);
+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
+int
+linux_timerfd_gettime64(struct thread *td, struct linux_timerfd_gettime64_args *args)
+{
+	struct l_itimerspec64 lots;
+	struct itimerspec ots;
+	int error;
+
+	error = linux_timerfd_gettime_common(td, args->fd, &ots);
+	if (error != 0)
+		return (error);
+	error = native_to_linux_itimerspec64(&lots, &ots);
+	if (error == 0)
+		error = copyout(&lots, args->old_value, sizeof(lots));
 	return (error);
 }
+#endif
 
 static int
 linux_timerfd_settime_common(struct thread *td, int fd, int flags,
diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c
index f5852e97ddae..4619fa226a72 100644
--- a/sys/i386/linux/linux_dummy_machdep.c
+++ b/sys/i386/linux/linux_dummy_machdep.c
@@ -70,7 +70,6 @@ DUMMY(vm86old);
 DUMMY(arch_prctl);
 /* Linux 5.0: */
 DUMMY(clock_adjtime64);
-DUMMY(timerfd_gettime64);
 DUMMY(io_pgetevents_time64);
 DUMMY(recvmmsg_time64);
 DUMMY(mq_timedsend_time64);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206171939.25HJdmLv016490>