* [musl] Bug: adjtime is not returning remaining offset
@ 2025-07-04 14:37 Jan Kardell
2025-07-08 9:23 ` [musl] [PATCH] adjtime: Get the remaining diff when no new diff is set Jan Kardell
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kardell @ 2025-07-04 14:37 UTC (permalink / raw)
To: musl
Hi,
An adjtime(NULL, &olddelta) call do not return anything in olddelta. The
cause is that timex.modes is not set to ADJ_OFFSET_SS_READ in the
resulting call to adjtimex().
I straced on glibc, and there ADJ_OFFSET_SS_READ is set.
Currently I'm using musl-1.2.5, but musl-1.1.24 misbehaves in the same way.
//Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
* [musl] [PATCH] adjtime: Get the remaining diff when no new diff is set
2025-07-04 14:37 [musl] Bug: adjtime is not returning remaining offset Jan Kardell
@ 2025-07-08 9:23 ` Jan Kardell
2025-07-08 16:06 ` Rich Felker
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kardell @ 2025-07-08 9:23 UTC (permalink / raw)
To: musl; +Cc: Rich Felker
The linux clock_adjtime64 syscall do not return a time offset when
called with modes=0. To get the offset, modes must be set to
ADJ_OFFSET_SS_READ.
Signed-off-by: Jan Kardell <jan.kardell@telliq.com>
---
src/linux/adjtime.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/linux/adjtime.c b/src/linux/adjtime.c
index 5a707f2f..65d5fe87 100644
--- a/src/linux/adjtime.c
+++ b/src/linux/adjtime.c
@@ -14,7 +14,8 @@ int adjtime(const struct timeval *in, struct timeval *out)
}
tx.offset = in->tv_sec*1000000 + in->tv_usec;
tx.modes = ADJ_OFFSET_SINGLESHOT;
- }
+ } else
+ tx.modes = ADJ_OFFSET_SS_READ;
if (adjtimex(&tx) < 0) return -1;
if (out) {
out->tv_sec = tx.offset / 1000000;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] [PATCH] adjtime: Get the remaining diff when no new diff is set
2025-07-08 9:23 ` [musl] [PATCH] adjtime: Get the remaining diff when no new diff is set Jan Kardell
@ 2025-07-08 16:06 ` Rich Felker
0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2025-07-08 16:06 UTC (permalink / raw)
To: Jan Kardell; +Cc: musl
On Tue, Jul 08, 2025 at 11:23:49AM +0200, Jan Kardell wrote:
> The linux clock_adjtime64 syscall do not return a time offset when
> called with modes=0. To get the offset, modes must be set to
> ADJ_OFFSET_SS_READ.
>
> Signed-off-by: Jan Kardell <jan.kardell@telliq.com>
> ---
> src/linux/adjtime.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/linux/adjtime.c b/src/linux/adjtime.c
> index 5a707f2f..65d5fe87 100644
> --- a/src/linux/adjtime.c
> +++ b/src/linux/adjtime.c
> @@ -14,7 +14,8 @@ int adjtime(const struct timeval *in, struct timeval *out)
> }
> tx.offset = in->tv_sec*1000000 + in->tv_usec;
> tx.modes = ADJ_OFFSET_SINGLESHOT;
> - }
> + } else
> + tx.modes = ADJ_OFFSET_SS_READ;
> if (adjtimex(&tx) < 0) return -1;
> if (out) {
> out->tv_sec = tx.offset / 1000000;
> --
> 2.43.0
It's not clear to me that the logic here is correct. Isn't adjtime
supposed to produde a readback result even when setting the
adjustment?
Commit message explanation of the change should also be in terms of
contracts of adjtime and adjtimex, not any syscalls which the
implementation of adjtime is not using (it's only using the public
contract of adjtimex), and should identify what adjtime was doing
wrong before (failure to return a meaningful value in *out, I think)
and how the change fixes that.
Rich
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-08 16:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-04 14:37 [musl] Bug: adjtime is not returning remaining offset Jan Kardell
2025-07-08 9:23 ` [musl] [PATCH] adjtime: Get the remaining diff when no new diff is set Jan Kardell
2025-07-08 16:06 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).