Skip to content

Commit

Permalink
lsclocks: fix dynamic clock ids
Browse files Browse the repository at this point in the history
Without an explicitly specified clock id, lsclocks would always use
clock id 0 (CLOCK_REALTIME) for the dynamic/PTP clocks.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
  • Loading branch information
t-8ch committed Dec 24, 2024
1 parent 25e62e5 commit 63102b8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions misc-utils/lsclocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
#include "all-io.h"
#include "list.h"

#define CLOCKFD 3

static inline clockid_t FD_TO_CLOCKID(int fd)
{
return (~(unsigned int) fd << 3) | CLOCKFD;
}

#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
Expand Down Expand Up @@ -380,6 +387,7 @@ static void add_dynamic_clock_from_path(struct libscols_table *tb,

struct clockinfo clockinfo = {
.type = CT_PTP,
.id = FD_TO_CLOCKID(fd),
.no_id = true,
.id_name = path,
.name = path,
Expand Down

0 comments on commit 63102b8

Please sign in to comment.