Module Name:    src
Committed By:   njoly
Date:           Tue Sep 24 13:27:50 UTC 2013

Modified Files:
        src/sys/compat/linux/arch/alpha: syscalls.master
        src/sys/compat/linux/arch/amd64: syscalls.master
        src/sys/compat/linux/arch/arm: syscalls.master
        src/sys/compat/linux/arch/i386: syscalls.master
        src/sys/compat/linux/arch/m68k: syscalls.master
        src/sys/compat/linux/arch/mips: syscalls.master
        src/sys/compat/linux/arch/powerpc: syscalls.master
        src/sys/compat/linux/common: linux_fcntl.h linux_file.c linux_misc.c

Log Message:
Add utimensat(2) for compat linux.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/compat/linux/arch/alpha/syscalls.master
cvs rdiff -u -r1.42 -r1.43 src/sys/compat/linux/arch/amd64/syscalls.master
cvs rdiff -u -r1.50 -r1.51 src/sys/compat/linux/arch/arm/syscalls.master
cvs rdiff -u -r1.109 -r1.110 src/sys/compat/linux/arch/i386/syscalls.master
cvs rdiff -u -r1.75 -r1.76 src/sys/compat/linux/arch/m68k/syscalls.master
cvs rdiff -u -r1.45 -r1.46 src/sys/compat/linux/arch/mips/syscalls.master
cvs rdiff -u -r1.54 -r1.55 src/sys/compat/linux/arch/powerpc/syscalls.master
cvs rdiff -u -r1.14 -r1.15 src/sys/compat/linux/common/linux_fcntl.h
cvs rdiff -u -r1.104 -r1.105 src/sys/compat/linux/common/linux_file.c
cvs rdiff -u -r1.225 -r1.226 src/sys/compat/linux/common/linux_misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/arch/alpha/syscalls.master
diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.78 src/sys/compat/linux/arch/alpha/syscalls.master:1.79
--- src/sys/compat/linux/arch/alpha/syscalls.master:1.78	Sun Sep 15 12:58:34 2013
+++ src/sys/compat/linux/arch/alpha/syscalls.master	Tue Sep 24 13:27:49 2013
@@ -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

Index: src/sys/compat/linux/arch/amd64/syscalls.master
diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.42 src/sys/compat/linux/arch/amd64/syscalls.master:1.43
--- src/sys/compat/linux/arch/amd64/syscalls.master:1.42	Mon Apr  8 20:54:47 2013
+++ src/sys/compat/linux/arch/amd64/syscalls.master	Tue Sep 24 13:27:49 2013
@@ -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

Index: src/sys/compat/linux/arch/arm/syscalls.master
diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.50 src/sys/compat/linux/arch/arm/syscalls.master:1.51
--- src/sys/compat/linux/arch/arm/syscalls.master:1.50	Mon Apr  8 20:54:48 2013
+++ src/sys/compat/linux/arch/arm/syscalls.master	Tue Sep 24 13:27:49 2013
@@ -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

Index: src/sys/compat/linux/arch/i386/syscalls.master
diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.109 src/sys/compat/linux/arch/i386/syscalls.master:1.110
--- src/sys/compat/linux/arch/i386/syscalls.master:1.109	Mon Apr  8 20:54:48 2013
+++ src/sys/compat/linux/arch/i386/syscalls.master	Tue Sep 24 13:27:49 2013
@@ -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

Index: src/sys/compat/linux/arch/m68k/syscalls.master
diff -u src/sys/compat/linux/arch/m68k/syscalls.master:1.75 src/sys/compat/linux/arch/m68k/syscalls.master:1.76
--- src/sys/compat/linux/arch/m68k/syscalls.master:1.75	Mon Apr  8 20:54:48 2013
+++ src/sys/compat/linux/arch/m68k/syscalls.master	Tue Sep 24 13:27:49 2013
@@ -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

Index: src/sys/compat/linux/arch/mips/syscalls.master
diff -u src/sys/compat/linux/arch/mips/syscalls.master:1.45 src/sys/compat/linux/arch/mips/syscalls.master:1.46
--- src/sys/compat/linux/arch/mips/syscalls.master:1.45	Mon Apr  8 20:54:48 2013
+++ src/sys/compat/linux/arch/mips/syscalls.master	Tue Sep 24 13:27:50 2013
@@ -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

Index: src/sys/compat/linux/arch/powerpc/syscalls.master
diff -u src/sys/compat/linux/arch/powerpc/syscalls.master:1.54 src/sys/compat/linux/arch/powerpc/syscalls.master:1.55
--- src/sys/compat/linux/arch/powerpc/syscalls.master:1.54	Sun Aug 11 18:34:43 2013
+++ src/sys/compat/linux/arch/powerpc/syscalls.master	Tue Sep 24 13:27:50 2013
@@ -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

Index: src/sys/compat/linux/common/linux_fcntl.h
diff -u src/sys/compat/linux/common/linux_fcntl.h:1.14 src/sys/compat/linux/common/linux_fcntl.h:1.15
--- src/sys/compat/linux/common/linux_fcntl.h:1.14	Mon Apr 28 20:23:43 2008
+++ src/sys/compat/linux/common/linux_fcntl.h	Tue Sep 24 13:27:50 2013
@@ -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;

Index: src/sys/compat/linux/common/linux_file.c
diff -u src/sys/compat/linux/common/linux_file.c:1.104 src/sys/compat/linux/common/linux_file.c:1.105
--- src/sys/compat/linux/common/linux_file.c:1.104	Fri Oct 14 09:23:28 2011
+++ src/sys/compat/linux/common/linux_file.c	Tue Sep 24 13:27:50 2013
@@ -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 stru
 	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) \

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.225 src/sys/compat/linux/common/linux_misc.c:1.226
--- src/sys/compat/linux/common/linux_misc.c:1.225	Sun Sep 15 12:58:34 2013
+++ src/sys/compat/linux/common/linux_misc.c	Tue Sep 24 13:27:50 2013
@@ -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 st
 	    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), &lts, sizeof(lts));
+		if (error != 0)
+			return error;
+		linux_to_native_timespec(&ts[0], &lts[0]);
+		linux_to_native_timespec(&ts[1], &lts[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)

Reply via email to