Tue Mar 3 00:19:07 2015 UTC ()
Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call.  Linux also has this system call, but
not tested this on linux.


(enami)
diff -r1.111 -r1.112 src/lib/librumphijack/hijack.c

cvs diff -r1.111 -r1.112 src/lib/librumphijack/hijack.c (expand / switch to unified diff)

--- src/lib/librumphijack/hijack.c 2014/11/04 19:05:17 1.111
+++ src/lib/librumphijack/hijack.c 2015/03/03 00:19:07 1.112
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hijack.c,v 1.111 2014/11/04 19:05:17 pooka Exp $ */ 1/* $NetBSD: hijack.c,v 1.112 2015/03/03 00:19:07 enami Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2011 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28/* 28/*
29 * XXX: rumphijack sort of works on glibc Linux. But it's not 29 * XXX: rumphijack sort of works on glibc Linux. But it's not
30 * the same quality working as on NetBSD. 30 * the same quality working as on NetBSD.
31 * autoconf HAVE_FOO vs. __NetBSD__ / __linux__ could be further 31 * autoconf HAVE_FOO vs. __NetBSD__ / __linux__ could be further
32 * improved. 32 * improved.
33 */ 33 */
34#include <rump/rumpuser_port.h> 34#include <rump/rumpuser_port.h>
35 35
36#if !defined(lint) 36#if !defined(lint)
37__RCSID("$NetBSD: hijack.c,v 1.111 2014/11/04 19:05:17 pooka Exp $"); 37__RCSID("$NetBSD: hijack.c,v 1.112 2015/03/03 00:19:07 enami Exp $");
38#endif 38#endif
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/types.h> 41#include <sys/types.h>
42#include <sys/ioctl.h> 42#include <sys/ioctl.h>
43#include <sys/mman.h> 43#include <sys/mman.h>
44#include <sys/mount.h> 44#include <sys/mount.h>
45#include <sys/socket.h> 45#include <sys/socket.h>
46#include <sys/stat.h> 46#include <sys/stat.h>
47#include <sys/time.h> 47#include <sys/time.h>
48#include <sys/uio.h> 48#include <sys/uio.h>
49 49
50#ifdef __NetBSD__ 50#ifdef __NetBSD__
@@ -103,26 +103,27 @@ enum dualcall { @@ -103,26 +103,27 @@ enum dualcall {
103#ifndef __linux__ 103#ifndef __linux__
104 DUALCALL_STAT, DUALCALL_LSTAT, DUALCALL_FSTAT, 104 DUALCALL_STAT, DUALCALL_LSTAT, DUALCALL_FSTAT,
105#endif 105#endif
106 106
107 DUALCALL_CHMOD, DUALCALL_LCHMOD, DUALCALL_FCHMOD, 107 DUALCALL_CHMOD, DUALCALL_LCHMOD, DUALCALL_FCHMOD,
108 DUALCALL_CHOWN, DUALCALL_LCHOWN, DUALCALL_FCHOWN, 108 DUALCALL_CHOWN, DUALCALL_LCHOWN, DUALCALL_FCHOWN,
109 DUALCALL_OPEN, 109 DUALCALL_OPEN,
110 DUALCALL_CHDIR, DUALCALL_FCHDIR, 110 DUALCALL_CHDIR, DUALCALL_FCHDIR,
111 DUALCALL_LSEEK, 111 DUALCALL_LSEEK,
112 DUALCALL_UNLINK, DUALCALL_SYMLINK, DUALCALL_READLINK, 112 DUALCALL_UNLINK, DUALCALL_SYMLINK, DUALCALL_READLINK,
113 DUALCALL_LINK, DUALCALL_RENAME, 113 DUALCALL_LINK, DUALCALL_RENAME,
114 DUALCALL_MKDIR, DUALCALL_RMDIR, 114 DUALCALL_MKDIR, DUALCALL_RMDIR,
115 DUALCALL_UTIMES, DUALCALL_LUTIMES, DUALCALL_FUTIMES, 115 DUALCALL_UTIMES, DUALCALL_LUTIMES, DUALCALL_FUTIMES,
 116 DUALCALL_UTIMENSAT,
116 DUALCALL_TRUNCATE, DUALCALL_FTRUNCATE, 117 DUALCALL_TRUNCATE, DUALCALL_FTRUNCATE,
117 DUALCALL_FSYNC, 118 DUALCALL_FSYNC,
118 DUALCALL_ACCESS, 119 DUALCALL_ACCESS,
119 120
120#ifndef __linux__ 121#ifndef __linux__
121 DUALCALL___GETCWD, 122 DUALCALL___GETCWD,
122 DUALCALL_GETDENTS, 123 DUALCALL_GETDENTS,
123#endif 124#endif
124 125
125#ifndef __linux__ 126#ifndef __linux__
126 DUALCALL_MKNOD, 127 DUALCALL_MKNOD,
127#endif 128#endif
128 129
@@ -295,26 +296,27 @@ struct sysnames { @@ -295,26 +296,27 @@ struct sysnames {
295 { DUALCALL_STAT, S(REALSTAT), RSYS_NAME(STAT) }, 296 { DUALCALL_STAT, S(REALSTAT), RSYS_NAME(STAT) },
296 { DUALCALL_LSTAT, S(REALLSTAT), RSYS_NAME(LSTAT) }, 297 { DUALCALL_LSTAT, S(REALLSTAT), RSYS_NAME(LSTAT) },
297 { DUALCALL_FSTAT, S(REALFSTAT), RSYS_NAME(FSTAT) }, 298 { DUALCALL_FSTAT, S(REALFSTAT), RSYS_NAME(FSTAT) },
298#endif 299#endif
299 { DUALCALL_CHOWN, "chown", RSYS_NAME(CHOWN) }, 300 { DUALCALL_CHOWN, "chown", RSYS_NAME(CHOWN) },
300 { DUALCALL_LCHOWN, "lchown", RSYS_NAME(LCHOWN) }, 301 { DUALCALL_LCHOWN, "lchown", RSYS_NAME(LCHOWN) },
301 { DUALCALL_FCHOWN, "fchown", RSYS_NAME(FCHOWN) }, 302 { DUALCALL_FCHOWN, "fchown", RSYS_NAME(FCHOWN) },
302 { DUALCALL_CHMOD, "chmod", RSYS_NAME(CHMOD) }, 303 { DUALCALL_CHMOD, "chmod", RSYS_NAME(CHMOD) },
303 { DUALCALL_LCHMOD, "lchmod", RSYS_NAME(LCHMOD) }, 304 { DUALCALL_LCHMOD, "lchmod", RSYS_NAME(LCHMOD) },
304 { DUALCALL_FCHMOD, "fchmod", RSYS_NAME(FCHMOD) }, 305 { DUALCALL_FCHMOD, "fchmod", RSYS_NAME(FCHMOD) },
305 { DUALCALL_UTIMES, S(REALUTIMES), RSYS_NAME(UTIMES) }, 306 { DUALCALL_UTIMES, S(REALUTIMES), RSYS_NAME(UTIMES) },
306 { DUALCALL_LUTIMES, S(REALLUTIMES), RSYS_NAME(LUTIMES) }, 307 { DUALCALL_LUTIMES, S(REALLUTIMES), RSYS_NAME(LUTIMES) },
307 { DUALCALL_FUTIMES, S(REALFUTIMES), RSYS_NAME(FUTIMES) }, 308 { DUALCALL_FUTIMES, S(REALFUTIMES), RSYS_NAME(FUTIMES) },
 309 { DUALCALL_UTIMENSAT, "utimensat", RSYS_NAME(UTIMENSAT) },
308 { DUALCALL_OPEN, "open", RSYS_NAME(OPEN) }, 310 { DUALCALL_OPEN, "open", RSYS_NAME(OPEN) },
309 { DUALCALL_CHDIR, "chdir", RSYS_NAME(CHDIR) }, 311 { DUALCALL_CHDIR, "chdir", RSYS_NAME(CHDIR) },
310 { DUALCALL_FCHDIR, "fchdir", RSYS_NAME(FCHDIR) }, 312 { DUALCALL_FCHDIR, "fchdir", RSYS_NAME(FCHDIR) },
311 { DUALCALL_LSEEK, "lseek", RSYS_NAME(LSEEK) }, 313 { DUALCALL_LSEEK, "lseek", RSYS_NAME(LSEEK) },
312 { DUALCALL_UNLINK, "unlink", RSYS_NAME(UNLINK) }, 314 { DUALCALL_UNLINK, "unlink", RSYS_NAME(UNLINK) },
313 { DUALCALL_SYMLINK, "symlink", RSYS_NAME(SYMLINK) }, 315 { DUALCALL_SYMLINK, "symlink", RSYS_NAME(SYMLINK) },
314 { DUALCALL_READLINK, "readlink", RSYS_NAME(READLINK) }, 316 { DUALCALL_READLINK, "readlink", RSYS_NAME(READLINK) },
315 { DUALCALL_LINK, "link", RSYS_NAME(LINK) }, 317 { DUALCALL_LINK, "link", RSYS_NAME(LINK) },
316 { DUALCALL_RENAME, "rename", RSYS_NAME(RENAME) }, 318 { DUALCALL_RENAME, "rename", RSYS_NAME(RENAME) },
317 { DUALCALL_MKDIR, "mkdir", RSYS_NAME(MKDIR) }, 319 { DUALCALL_MKDIR, "mkdir", RSYS_NAME(MKDIR) },
318 { DUALCALL_RMDIR, "rmdir", RSYS_NAME(RMDIR) }, 320 { DUALCALL_RMDIR, "rmdir", RSYS_NAME(RMDIR) },
319 { DUALCALL_TRUNCATE, "truncate", RSYS_NAME(TRUNCATE) }, 321 { DUALCALL_TRUNCATE, "truncate", RSYS_NAME(TRUNCATE) },
320 { DUALCALL_FTRUNCATE, "ftruncate", RSYS_NAME(FTRUNCATE) }, 322 { DUALCALL_FTRUNCATE, "ftruncate", RSYS_NAME(FTRUNCATE) },
@@ -2486,26 +2488,31 @@ PATHCALL(int, rmdir, DUALCALL_RMDIR,  @@ -2486,26 +2488,31 @@ PATHCALL(int, rmdir, DUALCALL_RMDIR,
2486 (const char *), \ 2488 (const char *), \
2487 (path)) 2489 (path))
2488 2490
2489PATHCALL(int, utimes, DUALCALL_UTIMES, \ 2491PATHCALL(int, utimes, DUALCALL_UTIMES, \
2490 (const char *path, const struct timeval *tv), \ 2492 (const char *path, const struct timeval *tv), \
2491 (const char *, const struct timeval *), \ 2493 (const char *, const struct timeval *), \
2492 (path, tv)) 2494 (path, tv))
2493 2495
2494PATHCALL(int, lutimes, DUALCALL_LUTIMES, \ 2496PATHCALL(int, lutimes, DUALCALL_LUTIMES, \
2495 (const char *path, const struct timeval *tv), \ 2497 (const char *path, const struct timeval *tv), \
2496 (const char *, const struct timeval *), \ 2498 (const char *, const struct timeval *), \
2497 (path, tv)) 2499 (path, tv))
2498 2500
 2501PATHCALL(int, utimensat, DUALCALL_UTIMENSAT, \
 2502 (int fd, const char *path, const struct timespec *ts, int flags), \
 2503 (int, const char *, const struct timespec *, int), \
 2504 (fd, path, ts, flags))
 2505
2499#ifdef HAVE_CHFLAGS 2506#ifdef HAVE_CHFLAGS
2500PATHCALL(int, chflags, DUALCALL_CHFLAGS, \ 2507PATHCALL(int, chflags, DUALCALL_CHFLAGS, \
2501 (const char *path, u_long flags), \ 2508 (const char *path, u_long flags), \
2502 (const char *, u_long), \ 2509 (const char *, u_long), \
2503 (path, flags)) 2510 (path, flags))
2504 2511
2505PATHCALL(int, lchflags, DUALCALL_LCHFLAGS, \ 2512PATHCALL(int, lchflags, DUALCALL_LCHFLAGS, \
2506 (const char *path, u_long flags), \ 2513 (const char *path, u_long flags), \
2507 (const char *, u_long), \ 2514 (const char *, u_long), \
2508 (path, flags)) 2515 (path, flags))
2509#endif /* HAVE_CHFLAGS */ 2516#endif /* HAVE_CHFLAGS */
2510 2517
2511PATHCALL(int, truncate, DUALCALL_TRUNCATE, \ 2518PATHCALL(int, truncate, DUALCALL_TRUNCATE, \