Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src add utimens and lutimens wrappers using utimensat.
details: https://anonhg.NetBSD.org/src/rev/adceb0e3fa0e
branches: trunk
changeset: 782470:adceb0e3fa0e
user: christos <christos%NetBSD.org@localhost>
date: Sat Nov 03 19:39:21 2012 +0000
description:
add utimens and lutimens wrappers using utimensat.
diffstat:
lib/libc/gen/Makefile.inc | 6 ++--
lib/libc/gen/utimens.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
lib/libc/sys/utimes.2 | 23 +++++++++++++++++--
sys/sys/stat.h | 6 ++++-
4 files changed, 81 insertions(+), 7 deletions(-)
diffs (165 lines):
diff -r b4ab8bb59397 -r adceb0e3fa0e lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc Sat Nov 03 19:26:52 2012 +0000
+++ b/lib/libc/gen/Makefile.inc Sat Nov 03 19:39:21 2012 +0000
@@ -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 @@
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
diff -r b4ab8bb59397 -r adceb0e3fa0e lib/libc/gen/utimens.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/utimens.c Sat Nov 03 19:39:21 2012 +0000
@@ -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);
+}
diff -r b4ab8bb59397 -r adceb0e3fa0e lib/libc/sys/utimes.2
--- a/lib/libc/sys/utimes.2 Sat Nov 03 19:26:52 2012 +0000
+++ b/lib/libc/sys/utimes.2 Sat Nov 03 19:39:21 2012 +0000
@@ -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 @@
.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 @@
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 @@
.Sh ERRORS
.Fn utimes ,
.Fn lutimes ,
+.Fn utimens ,
+.Fn lutimens ,
and
.Fn utimensat
will fail if:
diff -r b4ab8bb59397 -r adceb0e3fa0e sys/sys/stat.h
--- a/sys/sys/stat.h Sat Nov 03 19:26:52 2012 +0000
+++ b/sys/sys/stat.h Sat Nov 03 19:39:21 2012 +0000
@@ -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 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
Home |
Main Index |
Thread Index |
Old Index