- Add support for CLOCK_BOOTTIME (patch by Mario Pareja <pareja.mario@gmail.com>)

This commit is contained in:
Paul Wouters 2016-10-12 13:09:31 -04:00
parent b2a458f3b1
commit b793ec5b79
2 changed files with 71 additions and 2 deletions

View File

@ -0,0 +1,64 @@
From 628c70a67a94b3020cab79171545721dfd295fcd Mon Sep 17 00:00:00 2001
From: Mario Pareja <pareja.mario@gmail.com>
Date: Fri, 9 Jan 2015 18:15:53 +0000
Subject: [PATCH] Begin adding CLOCK_BOOTTIME support.
---
src/faketime_common.h | 2 ++
src/libfaketime.c | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/faketime_common.h b/src/faketime_common.h
index ee0d627..7de6cd8 100644
--- a/src/faketime_common.h
+++ b/src/faketime_common.h
@@ -32,6 +32,8 @@ struct system_time_s
struct timespec mon;
/* System time according to CLOCK_MONOTONIC_RAW */
struct timespec mon_raw;
+ /* System time according to CLOCK_BOOTTIME */
+ struct timespec boot;
};
/* Data shared among faketime-spawned processes */
diff --git a/src/libfaketime.c b/src/libfaketime.c
index f4a26be..121bbf6 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -208,7 +208,7 @@ static int cache_duration = 10; /* cache fake time input for 10 seconds */
* Static timespec to store our startup time, followed by a load-time library
* initialization declaration.
*/
-static struct system_time_s ftpl_starttime = {{0, -1}, {0, -1}, {0, -1}};
+static struct system_time_s ftpl_starttime = {{0, -1}, {0, -1}, {0, -1}, {0, -1}};
static char user_faked_time_fmt[BUFSIZ] = {0};
@@ -319,6 +319,7 @@ static void system_time_from_system (struct system_time_s * systime)
DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_REALTIME, &systime->real));
DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_MONOTONIC, &systime->mon));
DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_MONOTONIC_RAW, &systime->mon_raw));
+ DONT_FAKE_TIME((*real_clock_gettime)(CLOCK_BOOTTIME, &systime->boot));
#endif
}
@@ -1834,6 +1835,9 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
case CLOCK_MONOTONIC_RAW:
timespecsub(tp, &ftpl_starttime.mon_raw, &tmp_ts);
break;
+ case CLOCK_BOOTTIME:
+ timespecsub(tp, &ftpl_starttime.boot, &tmp_ts);
+ break;
default:
printf("Invalid clock_id for clock_gettime: %d", clk_id);
exit(EXIT_FAILURE);
@@ -1973,6 +1977,9 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
case CLOCK_MONOTONIC_RAW:
timespecsub(tp, &ftpl_starttime.mon_raw, &tdiff);
break;
+ case CLOCK_BOOTTIME:
+ timespecsub(tp, &ftpl_starttime.boot, &tdiff);
+ break;
default:
printf("Invalid clock_id for clock_gettime: %d", clk_id);
exit(EXIT_FAILURE);

View File

@ -7,6 +7,7 @@ Url: http://www.code-wizards.com/projects/%{name}/
Source: http://www.code-wizards.com/projects/%{name}/%{name}-%{version}.tar.gz
Group: System Environment/Libraries
Patch1: libfaketime-0.9.5-fix-infinite-recursion-on-real_clock_gettime.patch
Patch2: libfaketime-0.9.6-boottime.patch
%description
libfaketime intercepts various system calls which programs use to
@ -18,6 +19,7 @@ time system- wide.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
# work around from upstream for autodetecting glibc version bug on i686
sed -i -e 's/__asm__(".symver timer_gettime_22/\/\/__asm__(".symver timer_gettime_22/' src/libfaketime.c
sed -i -e 's/__asm__(".symver timer_settime_22/\/\/__asm__(".symver timer_settime_22/' src/libfaketime.c
@ -28,7 +30,7 @@ cd src ; CFLAGS="%{optflags} -Wno-strict-aliasing" make %{?_smp_mflags} \
PREFIX="%{_prefix}" LIBDIRNAME="/%{_lib}/faketime" all
%check
make %{?_smp_mflags} -C test all
make %{?_smp_mflags} -C test all
%install
make PREFIX="%{_prefix}" DESTDIR=%{buildroot} LIBDIRNAME="/%{_lib}/faketime" install
@ -36,7 +38,7 @@ rm -r %{buildroot}/%{_docdir}/faketime
# needed for stripping/debug package
chmod a+rx %{buildroot}/%{_libdir}/faketime/*.so.*
%files
%files
%{_bindir}/faketime
%dir %attr(0755, root, root) %{_libdir}/faketime/
%attr(0755, root, root) %{_libdir}/faketime/libfaketime*so.*
@ -44,6 +46,9 @@ chmod a+rx %{buildroot}/%{_libdir}/faketime/*.so.*
%{_mandir}/man1/*
%changelog
* Wed Oct 12 2016 Paul Wouters <pwouters@redhat.com> - 0.9.6-4
- Add support for CLOCK_BOOTTIME (patch by Mario Pareja <pareja.mario@gmail.com>)
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild