Linux-man Archive on lore.kernel.org
 help / color / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Eric Rannaud <eric.rannaud@gmail.com>,
	Linux API <linux-api@vger.kernel.org>,
	linux-man <linux-man@vger.kernel.org>
Cc: Aleksa Sarai <asarai@suse.de>
Subject: Re: clock_settime(2) error for non-settable clocks
Date: Sun, 29 Mar 2020 22:49:00 +0200
Message-ID: <CAKgNAkhzOq2-H8Ka2Dx9ijrVZkaH9cNzKkAENM9hyQx9MBnAKQ@mail.gmail.com> (raw)
In-Reply-To: <a225bae5-e342-fee4-b7fa-c3093ca52fa0@gmail.com>

On Thu, 26 Mar 2020 at 09:37, Michael Kerrisk (man-pages)
<mtk.manpages@gmail.com> wrote:
>
> Eric,
>
> On 3/20/20 7:02 PM, Eric Rannaud wrote:
> > If clock_id is a valid clock on the system (i.e. it can be passed to
> > clock_gettime(2)), clock_settime(clock_id, &ts) sets errno to, either:
> >
> >   - EINVAL if CONFIG_POSIX_TIMERS is not enabled (kernel/posix-stubs.c);
> >   - EINVAL if CONFIG_POSIX_TIMERS is enabled (kernel/posix-timers.c)
> > and the k_clock has no set function (e.g. CLOCK_BOOTTIME);
> >   - EACCES for dynamic posix clock devices that lack F_WRITE
> > (kernel/posix-time.c);
> >   - EOPNOTSUPP for dynamic posix clock devices that have F_WRITE but
> > don't have a clock_settime op.
> >   - EOPNOTSUPP for drivers/ptp/ptp_kvm.c (they provide a clock_settime
> > op that returns -EOPNOTSUPP directly, rather than opt to leave
> > clock_settime NULL which would do the same thing, see previous point).
> >
> > The manpage for clock_settime(2) is not very clear:
> >
> >        EINVAL The clk_id specified is not supported on this system.
> >
> >        EPERM  clock_settime() does not have permission to set the clock  indi‐
> >               cated.
> >
> > To me, the manpage reads like EPERM should be expected when trying to
> > set a clock that is not settable.
> >
> > Should we update the manpage to more fully explain the range of
> > possible errors or instead try to have more consistent errors? For
> > syscalls, what's the backward-compatibility contract for errno values?
>
> A man-pages patch would be most appropriate. Would you be able to put
> something together?

I have in the meantime added this patch:

commit 238442a2de3821921e9b78117bf89519f8093c42 (HEAD -> master)
Author: Michael Kerrisk <mtk.manpages@gmail.com>
Date:   Sun Mar 29 22:36:19 2020 +0200

    clock_getres.2: ERRORS: add EINVAL for attempt to set a nonsettable clock

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

diff --git a/man2/clock_getres.2 b/man2/clock_getres.2
index ed9310208..66ed84c5c 100644
--- a/man2/clock_getres.2
+++ b/man2/clock_getres.2
@@ -237,6 +237,13 @@ is negative or
 .I tp.tv_nsec
 is outside the range [0..999,999,999].
 .TP
+.B EINVAL
+The
+.I clk_id
+specified in a call to
+.BR clock_settime ()
+is not a settable clock.
+.TP
 .BR EINVAL " (since Linux 4.3)"
 .\" commit e1d7ba8735551ed79c7a0463a042353574b96da3
 A call to

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 18:02 Eric Rannaud
2020-03-21  3:56 ` Aleksa Sarai
2020-03-26  8:37 ` Michael Kerrisk (man-pages)
2020-03-29 20:49   ` Michael Kerrisk (man-pages) [this message]
2020-04-02 11:48     ` Michael Kerrisk (man-pages)
2020-04-02 14:23       ` [PATCH 1/1] clock_getres.2: dynamic POSIX clock devices can return other errors Eric Rannaud
2020-04-02 19:55         ` Michael Kerrisk (man-pages)
2020-04-02 20:06         ` Eric Rannaud
2020-04-02 20:19           ` Michael Kerrisk (man-pages)
2020-04-02 20:49             ` Eric Rannaud
2020-04-02 20:50               ` Eric Rannaud
2020-04-03  7:02               ` Michael Kerrisk (man-pages)
2020-04-03 16:42                 ` Eric Rannaud
2020-04-20 11:13               ` Michael Kerrisk (man-pages)
2020-04-02 14:29       ` clock_settime(2) error for non-settable clocks Eric Rannaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKgNAkhzOq2-H8Ka2Dx9ijrVZkaH9cNzKkAENM9hyQx9MBnAKQ@mail.gmail.com \
    --to=mtk.manpages@gmail.com \
    --cc=asarai@suse.de \
    --cc=eric.rannaud@gmail.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-man Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-man/0 linux-man/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-man linux-man/ https://lore.kernel.org/linux-man \
		linux-man@vger.kernel.org
	public-inbox-index linux-man

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-man


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git