All of lore.kernel.org
 help / color / mirror / Atom feed
* 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

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.