4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
33 #include <sys/syscall.h>
36 futimens(int fd
, const timespec_t times
[2])
38 return (syscall(SYS_utimesys
, 0, fd
, times
));
42 utimensat(int fd
, const char *path
, const timespec_t times
[2], int flag
)
44 return (syscall(SYS_utimesys
, 1, fd
, path
, times
, flag
));
47 #pragma weak _utime = utime
49 utime(const char *path
, const struct utimbuf
*times
)
51 struct utimbuf ltimes
;
58 /* use uucopy() to behave like a system call */
59 if (uucopy(times
, <imes
, sizeof (ltimes
)) != 0)
60 return (-1); /* uucopy() set errno to EFAULT */
61 ts
[0].tv_sec
= ltimes
.actime
;
63 ts
[1].tv_sec
= ltimes
.modtime
;
67 return (utimensat(AT_FDCWD
, path
, tsp
, 0));
71 utimes(const char *path
, const struct timeval times
[2])
73 struct timeval ltimes
[2];
80 /* use uucopy() to behave like a system call */
81 if (uucopy(times
, ltimes
, sizeof (ltimes
)) != 0)
82 return (-1); /* uucopy() set errno to EFAULT */
83 ts
[0].tv_sec
= ltimes
[0].tv_sec
;
84 ts
[0].tv_nsec
= ltimes
[0].tv_usec
* 1000;
85 ts
[1].tv_sec
= ltimes
[1].tv_sec
;
86 ts
[1].tv_nsec
= ltimes
[1].tv_usec
* 1000;
89 return (utimensat(AT_FDCWD
, path
, tsp
, 0));
92 #pragma weak _futimesat = futimesat
94 futimesat(int fd
, const char *path
, const struct timeval times
[2])
96 struct timeval ltimes
[2];
103 /* use uucopy() to behave like a system call */
104 if (uucopy(times
, ltimes
, sizeof (ltimes
)) != 0)
105 return (-1); /* uucopy() set errno to EFAULT */
106 ts
[0].tv_sec
= ltimes
[0].tv_sec
;
107 ts
[0].tv_nsec
= ltimes
[0].tv_usec
* 1000;
108 ts
[1].tv_sec
= ltimes
[1].tv_sec
;
109 ts
[1].tv_nsec
= ltimes
[1].tv_usec
* 1000;
114 return (futimens(fd
, tsp
));
116 return (utimensat(fd
, path
, tsp
, 0));