add utimens and lutimens wrappers using utimensat.
This commit is contained in:
parent
9211d76436
commit
ff84366ca6
@ -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 arc4random.c assert.c basename.c clock.c \
|
||||
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
|
||||
|
||||
|
53
lib/libc/gen/utimens.c
Normal file
53
lib/libc/gen/utimens.c
Normal file
@ -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);
|
||||
}
|
@ -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:
|
||||
|
@ -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 *, struct stat *, int);
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user