diff options
| author | njoly <njoly@NetBSD.org> | 2013-09-24 13:27:49 +0000 |
|---|---|---|
| committer | njoly <njoly@NetBSD.org> | 2013-09-24 13:27:49 +0000 |
| commit | 997b933989dabbe2bb662ce827dbcb01ac7f4b20 (patch) | |
| tree | b0038432feb83c111dce3833e0a7a8f1c61d16a7 /sys/compat | |
| parent | f75de0f992dc52dabae449b1faddb77c19038002 (diff) | |
Add utimensat(2) for compat linux.
Diffstat (limited to 'sys/compat')
| -rw-r--r-- | sys/compat/linux/arch/alpha/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/arch/amd64/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/arch/arm/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/arch/i386/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/arch/m68k/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/arch/mips/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/arch/powerpc/syscalls.master | 5 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_fcntl.h | 11 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_file.c | 21 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_misc.c | 47 |
10 files changed, 95 insertions, 19 deletions
diff --git a/sys/compat/linux/arch/alpha/syscalls.master b/sys/compat/linux/arch/alpha/syscalls.master index 097899dfbe7..dddbe94d430 100644 --- a/sys/compat/linux/arch/alpha/syscalls.master +++ b/sys/compat/linux/arch/alpha/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.78 2013/09/15 12:58:34 njoly Exp $ + $NetBSD: syscalls.master,v 1.79 2013/09/24 13:27:49 njoly Exp $ ; ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -728,7 +728,8 @@ 472 UNIMPL move_pages 473 UNIMPL getcpu 474 UNIMPL epoll_wait -475 UNIMPL utimensat +475 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 476 UNIMPL signalfd 477 UNIMPL timerfd 478 UNIMPL eventfd diff --git a/sys/compat/linux/arch/amd64/syscalls.master b/sys/compat/linux/arch/amd64/syscalls.master index 37ba3e48c44..3cdf850c864 100644 --- a/sys/compat/linux/arch/amd64/syscalls.master +++ b/sys/compat/linux/arch/amd64/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.42 2013/04/08 20:54:47 pooka Exp $ + $NetBSD: syscalls.master,v 1.43 2013/09/24 13:27:49 njoly Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -490,7 +490,8 @@ 277 UNIMPL sync_file_range 278 UNIMPL vmsplice 279 UNIMPL move_pages -280 UNIMPL utimensat +280 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 281 UNIMPL epoll_pwait 282 UNIMPL signalfd 283 UNIMPL timerfd_create diff --git a/sys/compat/linux/arch/arm/syscalls.master b/sys/compat/linux/arch/arm/syscalls.master index 61b5d46e287..7deb88064be 100644 --- a/sys/compat/linux/arch/arm/syscalls.master +++ b/sys/compat/linux/arch/arm/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.50 2013/04/08 20:54:48 pooka Exp $ + $NetBSD: syscalls.master,v 1.51 2013/09/24 13:27:49 njoly Exp $ ; Derived from sys/compat/linux/arch/*/syscalls.master ; and from Linux 2.4.12 arch/arm/kernel/calls.S @@ -534,7 +534,8 @@ 345 UNIMPL getcpu 346 UNIMPL epoll_wait 347 UNIMPL kexec_load -348 UNIMPL utimensat +348 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 349 UNIMPL signalfd 350 UNIMPL timerfd_create 351 UNIMPL eventfd diff --git a/sys/compat/linux/arch/i386/syscalls.master b/sys/compat/linux/arch/i386/syscalls.master index 9bbd0b99840..cc4b2425aea 100644 --- a/sys/compat/linux/arch/i386/syscalls.master +++ b/sys/compat/linux/arch/i386/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.109 2013/04/08 20:54:48 pooka Exp $ + $NetBSD: syscalls.master,v 1.110 2013/09/24 13:27:49 njoly Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -506,7 +506,8 @@ 317 UNIMPL move_pages 318 UNIMPL getcpu 319 UNIMPL epoll_wait -320 UNIMPL utimensat +320 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 321 UNIMPL signalfd 322 UNIMPL timerfd_create 323 UNIMPL eventfd diff --git a/sys/compat/linux/arch/m68k/syscalls.master b/sys/compat/linux/arch/m68k/syscalls.master index 8047d7c1031..a8d99d74808 100644 --- a/sys/compat/linux/arch/m68k/syscalls.master +++ b/sys/compat/linux/arch/m68k/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.75 2013/04/08 20:54:48 pooka Exp $ + $NetBSD: syscalls.master,v 1.76 2013/09/24 13:27:49 njoly Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -519,7 +519,8 @@ 313 UNIMPL kexec_load 314 UNIMPL getcpu 315 UNIMPL epoll_wait -316 UNIMPL utimensat +316 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 317 UNIMPL signalfd 318 UNIMPL timerfd_create 319 UNIMPL eventfd diff --git a/sys/compat/linux/arch/mips/syscalls.master b/sys/compat/linux/arch/mips/syscalls.master index 45db688be3b..ad7b755a15e 100644 --- a/sys/compat/linux/arch/mips/syscalls.master +++ b/sys/compat/linux/arch/mips/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.45 2013/04/08 20:54:48 pooka Exp $ + $NetBSD: syscalls.master,v 1.46 2013/09/24 13:27:50 njoly Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -506,7 +506,8 @@ 313 UNIMPL epoll_pwait 314 UNIMPL ioprio_set 315 UNIMPL ioprio_get -316 UNIMPL utimensat +316 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 317 UNIMPL signalfd 318 UNIMPL timerfd 319 UNIMPL eventfd diff --git a/sys/compat/linux/arch/powerpc/syscalls.master b/sys/compat/linux/arch/powerpc/syscalls.master index 98848238944..a7a85173e20 100644 --- a/sys/compat/linux/arch/powerpc/syscalls.master +++ b/sys/compat/linux/arch/powerpc/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.54 2013/08/11 18:34:43 pooka Exp $ + $NetBSD: syscalls.master,v 1.55 2013/09/24 13:27:50 njoly Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -504,7 +504,8 @@ 301 UNIMPL move_pages 302 UNIMPL getcpu 303 UNIMPL epoll_wait -304 UNIMPL utimensat +304 STD { int|linux_sys||utimensat(int fd, const char *path, \ + struct linux_timespec *times, int flag); } 305 UNIMPL signalfd 306 UNIMPL timerfd_create 307 UNIMPL eventfd diff --git a/sys/compat/linux/common/linux_fcntl.h b/sys/compat/linux/common/linux_fcntl.h index cfaa3add61d..ada0720e330 100644 --- a/sys/compat/linux/common/linux_fcntl.h +++ b/sys/compat/linux/common/linux_fcntl.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_fcntl.h,v 1.14 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_fcntl.h,v 1.15 2013/09/24 13:27:50 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -43,6 +43,15 @@ #define LINUX_O_RDWR 0x0002 #define LINUX_O_ACCMODE 0x0003 +#define LINUX_AT_FDCWD -100 +#define LINUX_AT_SYMLINK_NOFOLLOW 0x0100 +#define LINUX_AT_REMOVEDIR 0x0200 +#define LINUX_AT_SYMLINK_FOLLOW 0x0400 +#define LINUX_AT_NO_AUTOMOUNT 0x0800 +#define LINUX_AT_EMPTY_PATH 0x1000 + +int linux_to_bsd_atflags(int); + struct linux_flock { short l_type; short l_whence; diff --git a/sys/compat/linux/common/linux_file.c b/sys/compat/linux/common/linux_file.c index fd5d8aacc57..8e7a653dfcd 100644 --- a/sys/compat/linux/common/linux_file.c +++ b/sys/compat/linux/common/linux_file.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.104 2011/10/14 09:23:28 hannken Exp $ */ +/* $NetBSD: linux_file.c,v 1.105 2013/09/24 13:27:50 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.104 2011/10/14 09:23:28 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.105 2013/09/24 13:27:50 njoly Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -643,6 +643,23 @@ linux_sys_dup3(struct lwp *l, const struct linux_sys_dup3_args *uap, return 0; } + +int +linux_to_bsd_atflags(int lflags) +{ + int bflags = 0; + + if (lflags & LINUX_AT_SYMLINK_NOFOLLOW) + bflags |= AT_SYMLINK_NOFOLLOW; + if (lflags & LINUX_AT_REMOVEDIR) + bflags |= AT_REMOVEDIR; + if (lflags & LINUX_AT_SYMLINK_FOLLOW) + bflags |= AT_SYMLINK_FOLLOW; + + return bflags; +} + + #define LINUX_NOT_SUPPORTED(fun) \ int \ fun(struct lwp *l, const struct fun##_args *uap, register_t *retval) \ diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c index 83f79c02575..d0344d54520 100644 --- a/sys/compat/linux/common/linux_misc.c +++ b/sys/compat/linux/common/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.225 2013/09/15 12:58:34 njoly Exp $ */ +/* $NetBSD: linux_misc.c,v 1.226 2013/09/24 13:27:50 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.225 2013/09/15 12:58:34 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.226 2013/09/24 13:27:50 njoly Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1409,6 +1409,49 @@ linux_sys_utimes(struct lwp *l, const struct linux_sys_utimes_args *uap, registe tptr, UIO_SYSSPACE); } +int +linux_sys_utimensat(struct lwp *l, const struct linux_sys_utimensat_args *uap, + register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(const char *) path; + syscallarg(const struct linux_timespec *) times; + syscallarg(int) flag; + } */ + int follow, error; + struct linux_timespec lts[2]; + struct timespec *tsp = NULL, ts[2]; + + follow = (SCARG(uap, flag) & LINUX_AT_SYMLINK_NOFOLLOW) ? + NOFOLLOW : FOLLOW; + + if (SCARG(uap, times)) { + error = copyin(SCARG(uap, times), <s, sizeof(lts)); + if (error != 0) + return error; + linux_to_native_timespec(&ts[0], <s[0]); + linux_to_native_timespec(&ts[1], <s[1]); + tsp = ts; + } + + if (SCARG(uap, path) == NULL && SCARG(uap, fd) != AT_FDCWD) { + file_t *fp; + + /* fd_getvnode() will use the descriptor for us */ + if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0) + return error; + error = do_sys_utimensat(l, AT_FDCWD, fp->f_data, NULL, 0, + tsp, UIO_SYSSPACE); + fd_putfile(SCARG(uap, fd)); + return error; + } + + return do_sys_utimensat(l, SCARG(uap, fd), NULL, + SCARG(uap, path), follow, tsp, UIO_SYSSPACE); + +} + int linux_sys_lutimes(struct lwp *, const struct linux_sys_utimes_args *, register_t *); int linux_sys_lutimes(struct lwp *l, const struct linux_sys_utimes_args *uap, register_t *retval) |
