Index: lib/libc/gen/Makefile.inc =================================================================== RCS file: /cvsroot/src/lib/libc/gen/Makefile.inc,v retrieving revision 1.184 diff -u -p -u -r1.184 Makefile.inc --- lib/libc/gen/Makefile.inc 12 Apr 2012 22:08:32 -0000 1.184 +++ lib/libc/gen/Makefile.inc 3 Nov 2012 17:43:19 -0000 @@ -29,8 +29,8 @@ SRCS+= _errno.c alarm.c alphasort.c arc sigset.c sigsetops.c sleep.c \ stringlist.c sysconf.c sysctl.c sysctlbyname.c sysctlgetmibinfo.c \ sysctlnametomib.c syslog.c telldir.c time.c \ - times.c toascii.c tolower_.c ttyname.c ttyslot.c \ - toupper_.c ualarm.c ulimit.c uname.c unvis.c usleep.c utime.c utmp.c \ + times.c toascii.c tolower_.c ttyname.c ttyslot.c toupper_.c ualarm.c \ + ulimit.c uname.c unvis.c usleep.c utime.c utimens.c utmp.c \ utmpx.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c \ vwarn.c vwarnx.c verr.c verrx.c wordexp.c Index: lib/libc/sys/utimes.2 =================================================================== RCS file: /cvsroot/src/lib/libc/sys/utimes.2,v retrieving revision 1.30 diff -u -p -u -r1.30 utimes.2 --- lib/libc/sys/utimes.2 25 Oct 2011 09:26:53 -0000 1.30 +++ lib/libc/sys/utimes.2 3 Nov 2012 17:43:20 -0000 @@ -36,6 +36,8 @@ .Nm utimes , .Nm lutimes , .Nm futimes , +.Nm utimens , +.Nm lutimens , .Nm futimens , .Nm utimensat .Nd set file access and modification times @@ -48,6 +50,10 @@ .Ft int .Fn lutimes "const char *path" "const struct timeval times[2]" .Ft int +.Fn utimens "const char *path" "const struct timeval times[2]" +.Ft int +.Fn lutimens "const char *path" "const struct timeval times[2]" +.Ft int .Fn futimes "int fd" "const struct timeval times[2]" .Ft int .Fn futimens "int fd" "const struct timespec times[2]" @@ -100,10 +106,17 @@ while .Fn utimes changes the times of the file the link references. .Pp +.Fn utimens , +.Fn lutimens , +and .Fn futimens is like +.Fn utimes , +.Fn lutimes , +and .Fn futimes -except that time is specified with nanosecond instead of microseconds. +respectively except that time is specified with nanosecond instead of +microsecond precision. .Pp .Fn utimensat also allows time to be specifed with nanoseconds. @@ -117,7 +130,9 @@ is set to the symbolic link's dates are changed. .Pp The nanosecond fields for -.Fn futimens +.Fn utimens , +.Fn lutimens , +.Fn futimens , and .Fn utimensat can be set to the special value @@ -143,6 +158,8 @@ is set to indicate the error. .Sh ERRORS .Fn utimes , .Fn lutimes , +.Fn utimens , +.Fn lutimens , and .Fn utimensat will fail if: --- /dev/null 2012-11-03 13:43:14.000000000 -0400 +++ lib/libc/gen/utimens.c 2012-11-03 11:32:46.000000000 -0400 @@ -0,0 +1,59 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $"); +#endif /* LIBC_SCCS and not lint */ + +#include "namespace.h" + +#define _INCOMPLETE_XOPEN_C063 +#include <sys/stat.h> + +int +utimens(const char *path, const struct utimbuf *times) +{ + return utimensat(AT_FDCWD, path, times, 0); +} + +int +lutimens(const char *path, const struct utimbuf *times) +{ + return utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); +} Index: sys/sys/stat.h =================================================================== RCS file: /cvsroot/src/sys/sys/stat.h,v retrieving revision 1.63 diff -u -p -u -r1.63 stat.h --- sys/sys/stat.h 4 Sep 2011 10:02:33 -0000 1.63 +++ sys/sys/stat.h 3 Nov 2012 17:45:14 -0000 @@ -249,6 +249,10 @@ int fstatat(int, const char *, struc int utimensat(int, const char *, const struct timespec *, int); #endif +#ifdef _NETBSD_SOURCE +int utimens(const char *, struct timespec *); +int lutimens(const char *, struct timespec *); +#endif int futimens(int, const struct timespec *); #endif