Commit Graph

91 Commits

Author SHA1 Message Date
Michael Kerrisk 178635c4e4 adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 17:25:09 +01:00
Michael Kerrisk 1a96e4f2ba adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 17:25:09 +01:00
Michael Kerrisk 2f01620267 adjtimex.2: Various improvements after feedback from John Stultz
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 17:25:09 +01:00
Michael Kerrisk f4d9c97d6a adjtimex.2: Note range constraints and clamping for ADJ_FREQUENCY
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 17:25:04 +01:00
Michael Kerrisk 88ec900f22 adjtimex.2: Note treatment of out-of-range buf.offset
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 14:32:46 +01:00
Michael Kerrisk a2300b58d1 adjtimex.2: Update details of buf.offset EINVAL error
Reported-by: Naresh Kamboju <naresh.kernel@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 14:32:30 +01:00
Michael Kerrisk 77a47e474d adjtimex.2: Split EINVAL error cases
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 14:07:12 +01:00
William Preston f3910b4712 adjtimex.2: Update a detail in adjtimex return value description
Starting with Linux 3.4, the time_state change is now asynchronous
and the call returns the time_state before it has been altered,
rather than after it was altered as the previous code did.

======================================================

Notes from Petr Gajdos

attached program behaves differently on 2.6 and 3.0 kernels:

*******************************************************
2.6.32.59-0.7-default

Insert LS
adjtimex() return code 1: insert leap second (TIME_INS)
Kernel leap second flag: STA_INS

Delete LS
adjtimex() return code 2: delete leap second (TIME_DEL)
Kernel leap second flag: STA_DEL

Insert LS again
adjtimex() return code 1: insert leap second (TIME_INS)
Kernel leap second flag: STA_INS

Delete LS again
adjtimex() return code 2: delete leap second (TIME_DEL)
Kernel leap second flag: STA_DEL

*******************************************************
3.0.101-0.35-default

sbsvt101:~/tmp # ./adjt
Insert LS
adjtimex() return code 0: clock synchronized (TIME_OK)
Kernel leap second flag: STA_INS

Delete LS
adjtimex() return code 1: insert leap second (TIME_INS)
Kernel leap second flag: STA_DEL

Insert LS again
adjtimex() return code 2: delete leap second (TIME_DEL)
Kernel leap second flag: STA_INS

Delete LS again
adjtimex() return code 1: insert leap second (TIME_INS)
Kernel leap second flag: STA_DEL

*******************************************************

The explanation provided by William Preston (in CC):

"""
in both cases you get the actual value of the global kernel variable
time_state.

The code changed between the two kernels in the way it handled this.

In 2.6.32.59 the adjtimex call starts a timer immediately with the
function ntp_start_leap_timer(), which sets the value of time_state
before returning to the user.

This means you will get the value TIME_INS / TIME_DEL back
immediately.

In 3.0.101, the timer has been removed and the value of time_state is
set when the microsecond field overflows. The function
second_overflow() handles this. This means the value of time_state
will not have been set when the syscall adjtimex returns, and so you
will almost certainly get the old state.

Incidentally if you remove the sleep() calls in the code for 3.0.101
you may instead see the state of TIME_OK when switching between
STA_INS / STA_DEL.

All this is completely normal and expected behaviour, since both
return the current state, however I agree it is not intuitive.

I would recommend calling adjtimex without a mode to get the actual
state of the system after waiting a second.

At the same time, William suggests the patch in the attachement.

Petr

=============== adjt.c ================

void adjtm(int);

int main()
{
    printf("Insert LS\n");
    adjtm(STA_INS);

    sleep(2);
    printf("\nDelete LS\n");
    adjtm(STA_DEL);

    sleep(2);
    printf("\nInsert LS again\n");
    adjtm(STA_INS);

    sleep(2);
    printf("\nDelete LS again\n");
    adjtm(STA_DEL);

    printf("\nRestoring initial state\n");
    adjtm(0);
}

/*************************************/
/*  Modify LS flag and print status  */
/*************************************/
void adjtm(int ls)
{
    struct timex tx;
    int rc;

    tx.modes = ADJ_STATUS;
    tx.status = ls;

    if ((rc = adjtimex(&tx)) == -1) {
	perror("adjtimex()");
	exit(1);
    }

    sleep(2);

    tx.modes = 0;
    rc = adjtimex(&tx);

    printf("adjtimex() return code %d: ", rc);
    switch (rc) {
    case TIME_OK:
	printf("clock synchronized (TIME_OK)\n");
	break;

    case TIME_INS:
	printf("insert leap second (TIME_INS)\n");
	break;

    case TIME_DEL:
	printf("delete leap second (TIME_DEL)\n");
	break;

    case TIME_OOP:
	printf("leap second in progress (TIME_OOP)\n");
	break;

    case TIME_WAIT:
	printf("leap second has occurred (TIME_WAIT)\n");
	break;

    case TIME_BAD:
	printf("clock not synchronized (TIME_BAD)\n");
	break;

    default:
	printf("Unknown return code: %i\n", rc);
	break;

    }

    printf("Kernel leap second flag: ");
    if (tx.status & STA_INS)
	printf("STA_INS\n");
    else if (tx.status & STA_DEL)
	printf("STA_DEL\n");
    else
	printf("not set\n");
}
=======================================

Reported-by: Petr Gajdos <pgajdos@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 12:22:46 +01:00
Michael Kerrisk e3548e1d64 adjtimex.2: Add some FIXMEs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-04 12:22:46 +01:00
Michael Kerrisk 38e3518901 adjtimex.2: Remove FTM requirements
It seems that adjtimex() never needed _BSD_SOURCE (and my
earlier commit 5918743bc8 was simply a blunder.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-03-01 20:01:03 +01:00
Akihiro Motoki 69256b8085 adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-16 07:54:02 +01:00
Michael Kerrisk e0ea18e3fc adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 21:58:46 +01:00
Michael Kerrisk bd59305f77 adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 21:31:23 +01:00
Michael Kerrisk 9b8c7b2b16 adjtimex.2: srcfix: Add FIXME
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:48:00 +01:00
Michael Kerrisk d58d906ecd adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:37:22 +01:00
Michael Kerrisk 4dfc98f29a adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:36:23 +01:00
Michael Kerrisk f93daa5105 adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:35:00 +01:00
Michael Kerrisk ff4bd2e179 adjtimex.2: srcfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:26:19 +01:00
Laurent Georget b19c356f5b adjtimex.2: Change 'PPM' (parts per million) to 'ppm'
Hi again,

this is the second patch of the new series of patchs for adjtimex.2.

This is a trivia patch correcting "PPM" (parts per million) to the more usual "ppm".
Credits to Jeff Epler <jepler@unpythonic.net>.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:19:07 +01:00
Laurent Georget 277be06802 adjtimex.2: Clarify the 'ppm scaling' used in struct timex
This patch makes explicit and clarifies the unit used for
the fields "freq", "ppsfreq" and "stabil" in struct timex.

Reviewed-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-06 16:16:35 +01:00
Michael Kerrisk 4ce77a32fd adjtimex.2: Note that TIME_ERROR is the modern synonym for TIME_BAD
Reported-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2015-01-04 07:28:16 +01:00
Michael Kerrisk 0649afd45a localedef.1, adjtimex.2, clock_nanosleep.2, epoll_ctl.2, ioctl.2, madvise.2, open.2, posix_fadvise.2, prctl.2, restart_syscall.2, sched_setaffinity.2, select.2, semop.2, setsid.2, sgetmask.2, sigaction.2, sigreturn.2, splice.2, syscall.2, syscalls.2, tee.2, tkill.2, abort.3, cmsg.3, exp10.3, ftw.3, getopt.3, ilogb.3, memcmp.3, mq_open.3, pow.3, pthread_setschedparam.3, sigvec.3, sysconf.3, termios.3, tgamma.3, wordexp.3, locale.5, proc.5, resolv.conf.5, cp1251.7, credentials.7, fanotify.7, inotify.7, locale.7, man-pages.7, signal.7, unix.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-31 07:01:38 +01:00
Michael Kerrisk 86e1503ee9 adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 17:43:18 +01:00
Michael Kerrisk 872feab512 adjtimex.2: Rework ADJ_TAI text
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 93b445d553 adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 9155a2763e adjtimex.2: Add more details to description of 'tai' field
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 5de5062ad1 adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk d94ed228c3 adjtimex.2: Update RFC number: RFC 5905 obsoletes RFC 1305
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 6848ba030b adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 373bd09840 adjtimex.2: Add nanosecond details
Fixes ttps://bugzilla.kernel.org/show_bug.cgi?id=61171.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>

Conflicts:
	man2/adjtimex.2
2014-12-30 16:02:41 +01:00
Michael Kerrisk b84ba68687 adjtimex.2: Document timex 'status' bits
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk c35d69e238 adjtimex.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk fe31458ffa adjtimex.2: Note PPS (pulse per second) fields in timex structure
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 7b69c78cc5 adjtimex.2: Add comment noting that timex structure contains padding bytes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 012ed58da5 adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 95547282a2 adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk f4f2c9a18b adjtimex.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 22b278129c adjtimex.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 9d75cc4c8b adjtimex.2: Note kernel version for 'timex.tai' field
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 784f598504 adjtimex.2: Note effect of ADJ_NANO for ADJ_SETOFFSET
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk cef8628bf4 adjtimex.2: Clarify treatment of other 'modes' bits for ADJ_OFFSET_*
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 005239ca35 adjtimex.2: Note that ADJ_OFFSET_SINGLESHOT takes a time in microseconds
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 31d07b1e9a adjtimex.2: Other 'modes' bits are ignored on ADJ_OFFSET_*
Other bits in 'modes' are ignored if modes contains
ADJ_OFFSET_SINGLESHOT or ADJ_OFFSET_SS_READ.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:41 +01:00
Michael Kerrisk 6eaec6b167 adjtimex.2: Document ADJ_OFFSET_SS_READ
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00
Michael Kerrisk 002d27fb8d adjtimex.2: Improve description of ADJ_OFFSET_SINGLESHOT
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00
Michael Kerrisk abe87b0c34 adjtimex.2: Clarify which 'timex' field is used by each 'modes' bit
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00
Michael Kerrisk 4f77394811 adjtimex.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00
Michael Kerrisk f7a78a2de6 adjtimex.2: Briefly document ADJ_SETOFFSET
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00
Michael Kerrisk a87ba63b02 adjtimex.2: Note meaning of "PLL" abbreviation
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00
Michael Kerrisk 078f99d7bb adjtimex.2: Add brief documentation of ADJ_MICRO and ADJ_NANO
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-12-30 16:02:40 +01:00