diff options
| author | Roger A. Faulkner <Roger.Faulkner@Sun.COM> | 2009-09-01 15:37:22 -0700 |
|---|---|---|
| committer | Roger A. Faulkner <Roger.Faulkner@Sun.COM> | 2009-09-01 15:37:22 -0700 |
| commit | 3b862e9a9ce59d5dbf0177b9eb293109fde6bf36 (patch) | |
| tree | 4617754c72826e2339efba871c5b849158c3f689 /usr/src/lib | |
| parent | e8c4ecbb29dd0267f81ae8a6169b404fe10a111a (diff) | |
| download | illumos-joyent-3b862e9a9ce59d5dbf0177b9eb293109fde6bf36.tar.gz | |
PSARC 2009/453 futimens, utimensat
6815302 Implement futimens, utimensat(POSIX.1-2008) -set file modification times with nanosecond granularity
6539657 touch(1) does not set the nanosecond timestamp of a file correctly
Diffstat (limited to 'usr/src/lib')
| -rw-r--r-- | usr/src/lib/libc/amd64/Makefile | 3 | ||||
| -rw-r--r-- | usr/src/lib/libc/common/sys/utime.s | 43 | ||||
| -rw-r--r-- | usr/src/lib/libc/common/sys/utimes.s | 39 | ||||
| -rw-r--r-- | usr/src/lib/libc/i386/Makefile.com | 3 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/mapfile-vers | 2 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/sys/fsmisc.c | 8 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/sys/utimesys.c | 117 | ||||
| -rw-r--r-- | usr/src/lib/libc/sparc/Makefile.com | 3 | ||||
| -rw-r--r-- | usr/src/lib/libc/sparcv9/Makefile.com | 3 |
9 files changed, 123 insertions, 98 deletions
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index bcc340381f..e30dbdd760 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -278,8 +278,6 @@ COMSYSOBJS= \ umask.o \ umount2.o \ unlink.o \ - utime.o \ - utimes.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -833,6 +831,7 @@ PORTSYS= \ time_util.o \ ucontext.o \ ustat.o \ + utimesys.o \ zone.o PORTREGEX= \ diff --git a/usr/src/lib/libc/common/sys/utime.s b/usr/src/lib/libc/common/sys/utime.s deleted file mode 100644 index 34d10f97b6..0000000000 --- a/usr/src/lib/libc/common/sys/utime.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "utime.s" - -/* C library -- utime */ -/* int utime (const char *path, const struct utimbuf *times); */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(utime,function) - -#include "SYS.h" - - SYSCALL_RVAL1(utime) - RETC - SET_SIZE(utime) diff --git a/usr/src/lib/libc/common/sys/utimes.s b/usr/src/lib/libc/common/sys/utimes.s deleted file mode 100644 index 95f5e27a12..0000000000 --- a/usr/src/lib/libc/common/sys/utimes.s +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - - .file "utimes.s" - -/* C library -- utimes */ -/* int utimes (const char *path, const struct timeval *times); */ - -#include "SYS.h" - - SYSCALL_RVAL1(utimes) - RETC - SET_SIZE(utimes) diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index 6bc389bc30..772d09b00e 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -304,8 +304,6 @@ COMSYSOBJS= \ umask.o \ umount2.o \ unlink.o \ - utime.o \ - utimes.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -875,6 +873,7 @@ PORTSYS= \ time_util.o \ ucontext.o \ ustat.o \ + utimesys.o \ zone.o PORTREGEX= \ diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index 11b937ee93..92e89d5614 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -107,6 +107,7 @@ SUNW_1.23 { # SunOS 5.11 (Solaris 11) forkallx; forkx; fsetattr; + futimens; getattrat; htonl; htonll; @@ -184,6 +185,7 @@ SUNW_1.23 { # SunOS 5.11 (Solaris 11) uconv_u32tou8; uconv_u8tou16; uconv_u8tou32; + utimensat; vasprintf; verr; verrx; diff --git a/usr/src/lib/libc/port/sys/fsmisc.c b/usr/src/lib/libc/port/sys/fsmisc.c index ac42393071..5ca207adaf 100644 --- a/usr/src/lib/libc/port/sys/fsmisc.c +++ b/usr/src/lib/libc/port/sys/fsmisc.c @@ -25,14 +25,12 @@ */ #pragma weak _fchownat = fchownat -#pragma weak _futimesat = futimesat #pragma weak _unlinkat = unlinkat #include "lint.h" #include <sys/types.h> #include <sys/syscall.h> #include <sys/stat.h> -#include <sys/time.h> int fchownat(int fd, const char *name, uid_t uid, gid_t gid, int flags) @@ -47,12 +45,6 @@ unlinkat(int fd, const char *name, int flags) } int -futimesat(int fd, const char *name, const struct timeval *tv) -{ - return (syscall(SYS_fsat, 6, fd, name, tv)); -} - -int renameat(int fromfd, const char *fromname, int tofd, const char *toname) { return (syscall(SYS_fsat, 7, fromfd, fromname, tofd, toname)); diff --git a/usr/src/lib/libc/port/sys/utimesys.c b/usr/src/lib/libc/port/sys/utimesys.c new file mode 100644 index 0000000000..dc917f27ae --- /dev/null +++ b/usr/src/lib/libc/port/sys/utimesys.c @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include "lint.h" +#include <string.h> +#include <utime.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/syscall.h> + +int +futimens(int fd, const timespec_t times[2]) +{ + return (syscall(SYS_utimesys, 0, fd, times)); +} + +int +utimensat(int fd, const char *path, const timespec_t times[2], int flag) +{ + return (syscall(SYS_utimesys, 1, fd, path, times, flag)); +} + +#pragma weak _utime = utime +int +utime(const char *path, const struct utimbuf *times) +{ + struct utimbuf ltimes; + timespec_t ts[2]; + timespec_t *tsp; + + if (times == NULL) { + tsp = NULL; + } else { + /* use uucopy() to behave like a system call */ + if (uucopy(times, <imes, sizeof (ltimes)) != 0) + return (-1); /* uucopy() set errno to EFAULT */ + ts[0].tv_sec = ltimes.actime; + ts[0].tv_nsec = 0; + ts[1].tv_sec = ltimes.modtime; + ts[1].tv_nsec = 0; + tsp = ts; + } + return (utimensat(AT_FDCWD, path, tsp, 0)); +} + +int +utimes(const char *path, const struct timeval times[2]) +{ + struct timeval ltimes[2]; + timespec_t ts[2]; + timespec_t *tsp; + + if (times == NULL) { + tsp = NULL; + } else { + /* use uucopy() to behave like a system call */ + if (uucopy(times, ltimes, sizeof (ltimes)) != 0) + return (-1); /* uucopy() set errno to EFAULT */ + ts[0].tv_sec = ltimes[0].tv_sec; + ts[0].tv_nsec = ltimes[0].tv_usec * 1000; + ts[1].tv_sec = ltimes[1].tv_sec; + ts[1].tv_nsec = ltimes[1].tv_usec * 1000; + tsp = ts; + } + return (utimensat(AT_FDCWD, path, tsp, 0)); +} + +#pragma weak _futimesat = futimesat +int +futimesat(int fd, const char *path, const struct timeval times[2]) +{ + struct timeval ltimes[2]; + timespec_t ts[2]; + timespec_t *tsp; + + if (times == NULL) { + tsp = NULL; + } else { + /* use uucopy() to behave like a system call */ + if (uucopy(times, ltimes, sizeof (ltimes)) != 0) + return (-1); /* uucopy() set errno to EFAULT */ + ts[0].tv_sec = ltimes[0].tv_sec; + ts[0].tv_nsec = ltimes[0].tv_usec * 1000; + ts[1].tv_sec = ltimes[1].tv_sec; + ts[1].tv_nsec = ltimes[1].tv_usec * 1000; + tsp = ts; + } + + if (path == NULL) + return (futimens(fd, tsp)); + + return (utimensat(fd, path, tsp, 0)); +} diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com index 5fea549d5c..f4e58ca2e9 100644 --- a/usr/src/lib/libc/sparc/Makefile.com +++ b/usr/src/lib/libc/sparc/Makefile.com @@ -314,8 +314,6 @@ COMSYSOBJS= \ umask.o \ umount2.o \ unlink.o \ - utime.o \ - utimes.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -894,6 +892,7 @@ PORTSYS= \ time_util.o \ ucontext.o \ ustat.o \ + utimesys.o \ zone.o PORTREGEX= \ diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com index bf29faa9ed..c2455ed9d8 100644 --- a/usr/src/lib/libc/sparcv9/Makefile.com +++ b/usr/src/lib/libc/sparcv9/Makefile.com @@ -296,8 +296,6 @@ COMSYSOBJS= \ umask.o \ umount2.o \ unlink.o \ - utime.o \ - utimes.o \ utssys.o \ uucopy.o \ vhangup.o \ @@ -838,6 +836,7 @@ PORTSYS= \ time_util.o \ ucontext.o \ ustat.o \ + utimesys.o \ zone.o PORTREGEX= \ |
