set_tai_offset#
Sets the kernel TAI offset by parsing /usr/share/zoneinfo/leap-seconds.list.
ST 2110 uses PTP/TAI time. The Linux kernel needs to know the UTC-TAI offset
(currently 37 seconds) for CLOCK_TAI to return the correct value. This tool
automates what adjtimex --tai 37 does, but reads the offset from the system’s
leap-seconds file instead of hardcoding it.
Build#
meson setup build && meson compile -C build
Usage#
sudo ./build/set_tai_offset # set if needed
sudo ./build/set_tai_offset -v # verbose
If the offset is already set (> 0), it does nothing.
What it does#
Reads kernel TAI offset via
adjtimex()If already > 0, exits (already correct)
Parses the last offset from
/usr/share/zoneinfo/leap-seconds.listSets it via
adjtimex(ADJ_TAI)Verifies the write
Permissions#
Requires CAP_SYS_TIME or root:
sudo setcap 'cap_sys_time+ep' ./build/set_tai_offset