* utimensat(2) may/must confusion
@ 2015-01-18 1:54 enh
[not found] ` <CAJgzZooHgi2_kqTDLA42KhHOjH6byPQLap2-11KfpfV3TDb03A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: enh @ 2015-01-18 1:54 UTC (permalink / raw)
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
http://man7.org/linux/man-pages/man2/utimensat.2.html
If both tv_nsec fields are specified as UTIME_OMIT, then no file
ownership or permission checks are performed, and the file timestamps
are not modified, but other error conditions may still be detected.
fs/utimes.c
/* Nothing to do, we must not even check the path. */
if (tstimes[0].tv_nsec == UTIME_OMIT &&
tstimes[1].tv_nsec == UTIME_OMIT)
return 0;
if you're intending to match POSIX, the current text is correct. they
say "If both tv_nsec fields are set to UTIME_OMIT, no ownership or
permissions check shall be performed for the file, but other error
conditions may still be detected (including [EACCES] errors related to
the path prefix)."
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html)
but as the snippet above shows, the kernel doesn't, and so will
silently return success even for a non-existent file if both times are
UTIME_OMIT.
i'm not sure why the kernel says "must", but even if they fix that, it
would be useful for the man page to mention this subtlety. something
like "(Note that at present the kernel performs no checks in this
case, not even that the file exists, and will always return
success.)". (strictly that's not true because the EFAULT check for the
struct timespec* will have happened, but it seems less clear to try to
include that fact.)
--elliott
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread[parent not found: <CAJgzZooHgi2_kqTDLA42KhHOjH6byPQLap2-11KfpfV3TDb03A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: utimensat(2) may/must confusion [not found] ` <CAJgzZooHgi2_kqTDLA42KhHOjH6byPQLap2-11KfpfV3TDb03A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-01-18 10:49 ` Michael Kerrisk (man-pages) [not found] ` <54BB8FD7.1060501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Michael Kerrisk (man-pages) @ 2015-01-18 10:49 UTC (permalink / raw) To: enh; +Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA Hello Elliot, On 01/18/2015 02:54 AM, enh wrote: > http://man7.org/linux/man-pages/man2/utimensat.2.html > > If both tv_nsec fields are specified as UTIME_OMIT, then no file > ownership or permission checks are performed, and the file timestamps > are not modified, but other error conditions may still be detected. > > fs/utimes.c > > /* Nothing to do, we must not even check the path. */ > if (tstimes[0].tv_nsec == UTIME_OMIT && > tstimes[1].tv_nsec == UTIME_OMIT) > return 0; > > if you're intending to match POSIX, the current text is correct. they > say "If both tv_nsec fields are set to UTIME_OMIT, no ownership or > permissions check shall be performed for the file, but other error > conditions may still be detected (including [EACCES] errors related to > the path prefix)." > (http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html) > > but as the snippet above shows, the kernel doesn't, and so will > silently return success even for a non-existent file if both times are > UTIME_OMIT. That's an interesting detail. I'm not sure if it was intended, but I agree with what you seem to be saying: it doesn't violate the standard. > > i'm not sure why the kernel says "must", but even if they fix that, it Here's my hypothesis. The implementer of the system call was a German speaker. The German verb "müssen" can be translated as "must" or "to need to". But, while the verb seems like English "must", it's also a "false friend", as language teachers sometimes say. "Wir müessen nicht" might seem like it it means "We must not" but rather, it means "We need not", which clearly is different. I suspect that the author of the code and comments made an English language misstep in the comment. (It's not every day that I get to apply my mediocre German to man-pages work!) > would be useful for the man page to mention this subtlety. something > like "(Note that at present the kernel performs no checks in this > case, not even that the file exists, and will always return > success.)". (strictly that's not true because the EFAULT check for the > struct timespec* will have happened, but it seems less clear to try to > include that fact.) I'm reluctant to note that point too prominently, since it's obviously not the kind of thing we want to encourage user-space programmers to do, but at the bottom of NOTES, I added: If both tv_nsec fields are specified as UTIME_OMIT, then the Linux implementation of utimensat() succeeds even if the file referred to by dirfd and pathname does not exist. Okay? Cheers, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <54BB8FD7.1060501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: utimensat(2) may/must confusion [not found] ` <54BB8FD7.1060501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-01-18 18:13 ` enh 0 siblings, 0 replies; 3+ messages in thread From: enh @ 2015-01-18 18:13 UTC (permalink / raw) To: Michael Kerrisk (man-pages); +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA On Sun, Jan 18, 2015 at 2:49 AM, Michael Kerrisk (man-pages) <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > I'm reluctant to note that point too prominently, since it's > obviously not the kind of thing we want to encourage user-space > programmers to do, but at the bottom of NOTES, I added: > > If both tv_nsec fields are specified as UTIME_OMIT, then the > Linux implementation of utimensat() succeeds even if the file > referred to by dirfd and pathname does not exist. > > Okay? sgtm. anyone who tries to use that man page without carefully reading the NOTES and BUGS sections is going to have a bad time anyway. (plus i suspect that one day this will migrate to the BUGS section :-) ) thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-18 18:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-18 1:54 utimensat(2) may/must confusion enh
[not found] ` <CAJgzZooHgi2_kqTDLA42KhHOjH6byPQLap2-11KfpfV3TDb03A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-18 10:49 ` Michael Kerrisk (man-pages)
[not found] ` <54BB8FD7.1060501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-01-18 18:13 ` enh
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.