Module Name: src
Committed By: christos
Date: Sat Nov 3 19:39:21 UTC 2012
Modified Files:
src/lib/libc/gen: Makefile.inc
src/lib/libc/sys: utimes.2
src/sys/sys: stat.h
Added Files:
src/lib/libc/gen: utimens.c
Log Message:
add utimens and lutimens wrappers using utimensat.
To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/lib/libc/gen/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/gen/utimens.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/sys/utimes.2
cvs rdiff -u -r1.63 -r1.64 src/sys/sys/stat.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/gen/Makefile.inc
diff -u src/lib/libc/gen/Makefile.inc:1.184 src/lib/libc/gen/Makefile.inc:1.185
--- src/lib/libc/gen/Makefile.inc:1.184 Thu Apr 12 18:08:32 2012
+++ src/lib/libc/gen/Makefile.inc Sat Nov 3 15:39:21 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.184 2012/04/12 22:08:32 christos Exp $
+# $NetBSD: Makefile.inc,v 1.185 2012/11/03 19:39:21 christos Exp $
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources
@@ -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: src/lib/libc/sys/utimes.2
diff -u src/lib/libc/sys/utimes.2:1.30 src/lib/libc/sys/utimes.2:1.31
--- src/lib/libc/sys/utimes.2:1.30 Tue Oct 25 05:26:53 2011
+++ src/lib/libc/sys/utimes.2 Sat Nov 3 15:39:21 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: utimes.2,v 1.30 2011/10/25 09:26:53 wiz Exp $
+.\" $NetBSD: utimes.2,v 1.31 2012/11/03 19:39:21 christos Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -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:
Index: src/sys/sys/stat.h
diff -u src/sys/sys/stat.h:1.63 src/sys/sys/stat.h:1.64
--- src/sys/sys/stat.h:1.63 Sun Sep 4 06:02:33 2011
+++ src/sys/sys/stat.h Sat Nov 3 15:39:21 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: stat.h,v 1.63 2011/09/04 10:02:33 christos Exp $ */
+/* $NetBSD: stat.h,v 1.64 2012/11/03 19:39:21 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -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 *, const struct timespec *);
+int lutimens(const char *, const struct timespec *);
+#endif
int futimens(int, const struct timespec *);
#endif
Added files:
Index: src/lib/libc/gen/utimens.c
diff -u /dev/null src/lib/libc/gen/utimens.c:1.1
--- /dev/null Sat Nov 3 15:39:22 2012
+++ src/lib/libc/gen/utimens.c Sat Nov 3 15:39:21 2012
@@ -0,0 +1,53 @@
+/* $NetBSD: utimens.c,v 1.1 2012/11/03 19:39:21 christos Exp $ */
+
+/*-
+ * 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.
+ *
+ * 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: utimens.c,v 1.1 2012/11/03 19:39:21 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#define _INCOMPLETE_XOPEN_C063
+#include <fcntl.h>
+#include <sys/stat.h>
+
+int
+utimens(const char *path, const struct timespec *times)
+{
+ return utimensat(AT_FDCWD, path, times, 0);
+}
+
+int
+lutimens(const char *path, const struct timespec *times)
+{
+ return utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW);
+}