Module Name:    src
Committed By:   manu
Date:           Mon Aug  8 12:08:54 UTC 2011

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/include: unistd.h
        src/lib/libc/sys: Makefile.inc link.2
        src/sys/kern: kern_exec.c syscalls.master vfs_syscalls.c
        src/sys/sys: fcntl.h stat.h

Log Message:
First stage of support for Extended API set 2. Most of the think is
unimplemented, except enough of linkat(2) to hardlink to a symlink.

Everything new in headers is guarded #ifdef _INCOMPLETE_XOPEN_C063 since
some software (e.g.: xcvs in our own tree) will assume they can use openat(2)
when AT_FDCWD is defined. _INCOMPLETE_XOPEN_C063 will go away once support
will be completed.


To generate a diff of this commit:
cvs rdiff -u -r1.1658 -r1.1659 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.126 -r1.127 src/include/unistd.h
cvs rdiff -u -r1.207 -r1.208 src/lib/libc/sys/Makefile.inc
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/sys/link.2
cvs rdiff -u -r1.316 -r1.317 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.250 -r1.251 src/sys/kern/syscalls.master
cvs rdiff -u -r1.432 -r1.433 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.39 -r1.40 src/sys/sys/fcntl.h
cvs rdiff -u -r1.60 -r1.61 src/sys/sys/stat.h

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1658 src/distrib/sets/lists/comp/mi:1.1659
--- src/distrib/sets/lists/comp/mi:1.1658	Sun Aug  7 13:33:02 2011
+++ src/distrib/sets/lists/comp/mi	Mon Aug  8 12:08:52 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1658 2011/08/07 13:33:02 rmind Exp $
+#	$NetBSD: mi,v 1.1659 2011/08/08 12:08:52 manu Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4708,6 +4708,7 @@
 ./usr/share/man/cat2/lfs_segclean.0		comp-c-catman		.cat
 ./usr/share/man/cat2/lfs_segwait.0		comp-c-catman		.cat
 ./usr/share/man/cat2/link.0			comp-c-catman		.cat
+./usr/share/man/cat2/linkat.0			comp-c-catman		.cat
 ./usr/share/man/cat2/listen.0			comp-c-catman		.cat
 ./usr/share/man/cat2/lseek.0			comp-c-catman		.cat
 ./usr/share/man/cat2/lstat.0			comp-c-catman		.cat
@@ -10887,6 +10888,7 @@
 ./usr/share/man/html2/lfs_segclean.html		comp-c-htmlman		html
 ./usr/share/man/html2/lfs_segwait.html		comp-c-htmlman		html
 ./usr/share/man/html2/link.html			comp-c-htmlman		html
+./usr/share/man/html2/linkat.html		comp-c-htmlman		html
 ./usr/share/man/html2/listen.html		comp-c-htmlman		html
 ./usr/share/man/html2/lseek.html		comp-c-htmlman		html
 ./usr/share/man/html2/lstat.html		comp-c-htmlman		html
@@ -16846,6 +16848,7 @@
 ./usr/share/man/man2/lfs_segclean.2		comp-c-man		.man
 ./usr/share/man/man2/lfs_segwait.2		comp-c-man		.man
 ./usr/share/man/man2/link.2			comp-c-man		.man
+./usr/share/man/man2/linkat.2			comp-c-man		.man
 ./usr/share/man/man2/listen.2			comp-c-man		.man
 ./usr/share/man/man2/lseek.2			comp-c-man		.man
 ./usr/share/man/man2/lstat.2			comp-c-man		.man

Index: src/include/unistd.h
diff -u src/include/unistd.h:1.126 src/include/unistd.h:1.127
--- src/include/unistd.h:1.126	Sun Jun 26 16:42:40 2011
+++ src/include/unistd.h	Mon Aug  8 12:08:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: unistd.h,v 1.126 2011/06/26 16:42:40 christos Exp $	*/
+/*	$NetBSD: unistd.h,v 1.127 2011/08/08 12:08:53 manu Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -291,6 +291,24 @@
 ssize_t	 pwrite(int, const void *, size_t, off_t);
 #endif
 
+/*
+ * X/Open Extended API set 2 (a.k.a. C063)
+ */
+#if defined(_INCOMPLETE_XOPEN_C063)
+int	linkat(int, const char *, int, const char *, int);
+int	renameat(int, const char *, int, const char *);
+int	mkfifoat(int, const char *, mode_t);
+int	mknodat(int, const char *, mode_t, uint32_t);
+int	mkdirat(int, const char *, mode_t);
+int	faccessat(int, const char *, int, int);
+int	fchmodat(int, const char *, mode_t, int);
+int	fchownat(int, const char *, uid_t, gid_t, int);
+int	fexecve(int, char * const *, char * const *);
+int	readlinkat(int, const char *, char *, size_t);
+int	symlinkat(const char *, int, const char *);
+int	unlinkat(int, const char *, int);
+#endif
+
 
 /*
  * Implementation-defined extensions

Index: src/lib/libc/sys/Makefile.inc
diff -u src/lib/libc/sys/Makefile.inc:1.207 src/lib/libc/sys/Makefile.inc:1.208
--- src/lib/libc/sys/Makefile.inc:1.207	Mon Jun 27 16:39:44 2011
+++ src/lib/libc/sys/Makefile.inc	Mon Aug  8 12:08:53 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.207 2011/06/27 16:39:44 manu Exp $
+#	$NetBSD: Makefile.inc,v 1.208 2011/08/08 12:08:53 manu Exp $
 #	@(#)Makefile.inc	8.3 (Berkeley) 10/24/94
 
 # sys sources
@@ -87,9 +87,10 @@
 	setxattr.S getxattr.S listxattr.S removexattr.S \
 		lsetxattr.S lgetxattr.S llistxattr.S lremovexattr.S \
 		fsetxattr.S fgetxattr.S flistxattr.S fremovexattr.S \
-	fchdir.S fchflags.S fchmod.S fchown.S fchroot.S \
-		__fhopen40.S __fhstat50.S __fhstatvfs140.S fktrace.S \
-		flock.S fpathconf.S __fstat50.S fstatvfs1.S __futimes50.S \
+	faccessat.S fchdir.S fchflags.S fchmod.S fchmodat.S fchown.S \
+		fchownat.S fchroot.S fexecve.S __fhopen40.S __fhstat50.S \
+		__fhstatvfs140.S fktrace.S flock.S fpathconf.S __fstat50.S \
+		fstatvfs1.S fstatat.S  __futimes50.S \
 	__getcwd.S __getdents30.S __getfh30.S getvfsstat.S getgroups.S\
 		__getitimer50.S __getlogin.S getpeername.S getpgid.S getpgrp.S \
 		getpriority.S getrlimit.S __getrusage50.S getsid.S \
@@ -100,22 +101,24 @@
 		_ksem_post.S _ksem_trywait.S _ksem_unlink.S _ksem_wait.S \
 		_ksem_open.S \
 	lchflags.S lchmod.S lchown.S lfs_bmapv.S lfs_markv.S lfs_segclean.S \
-		__lfs_segwait50.S link.S listen.S __lstat50.S __lutimes50.S \
-		_lwp_create.S _lwp_exit.S _lwp_kill.S ___lwp_park50.S \
-		_lwp_self.S _lwp_wait.S _lwp_unpark.S _lwp_unpark_all.S \
-		_lwp_suspend.S _lwp_continue.S _lwp_wakeup.S _lwp_detach.S \
-		_lwp_setprivate.S \
+		__lfs_segwait50.S link.S linkat.S listen.S __lstat50.S \
+		__lutimes50.S _lwp_create.S _lwp_exit.S _lwp_kill.S \
+		___lwp_park50.S _lwp_self.S _lwp_wait.S _lwp_unpark.S \
+		_lwp_unpark_all.S _lwp_suspend.S _lwp_continue.S \
+		_lwp_wakeup.S _lwp_detach.S _lwp_setprivate.S \
 		_lwp_setname.S _lwp_getname.S _lwp_ctl.S \
-	madvise.S mincore.S minherit.S mkdir.S mkfifo.S __mknod50.S \
-		mlock.S mlockall.S modctl.S __mount50.S mprotect.S \
-		__msgctl50.S msgget.S munlock.S munlockall.S munmap.S \
+	madvise.S mincore.S minherit.S mkdir.S mkdirat.S mkfifo.S mkfifoat.S \
+		__mknod50.S mknodat.S mlock.S mlockall.S modctl.S __mount50.S \
+		mprotect.S __msgctl50.S msgget.S munlock.S munlockall.S \
+		munmap.S \
 	nfssvc.S __ntp_gettime50.S \
+	openat.S \
 	paccept.S pathconf.S pipe2.S pmc_get_info.S pmc_control.S \
 		__posix_chown.S __posix_fchown.S __posix_lchown.S \
 		__posix_rename.S profil.S \
 	__quotactl50.S \
-	rasctl.S reboot.S recvfrom.S recvmsg.S rename.S revoke.S \
-		rmdir.S \
+	rasctl.S readlinkat.S reboot.S recvfrom.S recvmsg.S rename.S \
+		renameat.S revoke.S rmdir.S \
 	sa_register.S sa_stacks.S sa_enable.S sa_setconcurrency.S sa_yield.S \
 		sa_preempt.S semconfig.S semget.S semop.S \
 		sendmsg.S sendto.S setegid.S setcontext.S seteuid.S setgid.S \
@@ -126,11 +129,11 @@
 		sigqueueinfo.S \
 		__sigaltstack14.S __sigpending14.S __sigaction_sigtramp.S \
 		____sigtimedwait50.S __socket30.S socketpair.S __stat50.S \
-		statvfs1.S swapctl.S symlink.S __sysctl.S \
+		statvfs1.S swapctl.S symlink.S symlinkat.S __sysctl.S \
 	timer_create.S timer_delete.S __timer_gettime50.S timer_getoverrun.S \
 		____semctl50.S __timer_settime50.S \
-	umask.S undelete.S unlink.S unmount.S __utimes50.S utrace.S uuidgen.S \
-	vadvise.S
+	umask.S undelete.S unlink.S unlinkat.S unmount.S __utimes50.S \
+		utimensat.S utrace.S uuidgen.S vadvise.S
 
 # modules with potentially non default implementations
 ASM_MD=	_lwp_getprivate.S mremap.S 
@@ -283,6 +286,7 @@
 MLINKS+=kqueue.2 kevent.2
 MLINKS+=ktrace.2 fktrace.2
 MLINKS+=lseek.2 seek.2
+MLINKS+=link.2 linkat.2
 MLINKS+=_lwp_suspend.2 _lwp_continue.2
 MLINKS+=_lwp_getprivate.2 _lwp_setprivate.2
 MLINKS+=madvise.2 posix_madvise.2

Index: src/lib/libc/sys/link.2
diff -u src/lib/libc/sys/link.2:1.24 src/lib/libc/sys/link.2:1.25
--- src/lib/libc/sys/link.2:1.24	Mon May 31 12:16:20 2010
+++ src/lib/libc/sys/link.2	Mon Aug  8 12:08:53 2011
@@ -1,6 +1,6 @@
-.\"	$NetBSD: link.2,v 1.24 2010/05/31 12:16:20 njoly Exp $
+.\"	$NetBSD: link.2,v 1.25 2011/08/08 12:08:53 manu Exp $
 .\"
-.\" Copyright (c) 1980, 1991, 1993
+.\" Copyright (c) 1980, 1991, 1993, 2011
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,8 @@
 .In unistd.h
 .Ft int
 .Fn link "const char *name1" "const char *name2"
+.Ft int
+.Fn linkat "int fd1" "const char *name1" "int fd2" "const char *name2" "int flags"
 .Sh DESCRIPTION
 The
 .Fn link
@@ -77,6 +79,26 @@
 .Fa name1
 may not be a directory unless the caller is the super-user
 and the file system containing it supports linking to directories.
+.Pp 
+When operating on a symlink,
+.Fn link
+resolves the symlink and creates a hard link on the target. 
+.Fn linkat
+will do the same if 
+.Dv AT_SYMLINK_FOLLOW
+is set in 
+.Fa flags ,
+but it will link on the symlink itself if the flag is clear.
+.Pp
+At the moment, 
+.Fn linkat
+is partially implemented. It will return
+.Er ENOSYS for 
+.Fa fd1
+and 
+.Fa fd2 
+values different than
+.Dv AT_FDCWD .
 .Sh RETURN VALUES
 Upon successful completion, a value of 0 is returned.
 Otherwise, a value of \-1 is returned and
@@ -155,6 +177,9 @@
 .Sh SEE ALSO
 .Xr symlink 2 ,
 .Xr unlink 2
+.Sh BUGS
+.Fn linkat 
+is partially implemented.
 .Sh STANDARDS
 The
 .Fn link

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.316 src/sys/kern/kern_exec.c:1.317
--- src/sys/kern/kern_exec.c:1.316	Mon Jun  6 22:04:34 2011
+++ src/sys/kern/kern_exec.c	Mon Aug  8 12:08:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.316 2011/06/06 22:04:34 matt Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.317 2011/08/08 12:08:53 manu Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.316 2011/06/06 22:04:34 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.317 2011/08/08 12:08:53 manu Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_modular.h"
@@ -460,6 +460,19 @@
 	    SCARG(uap, envp), execve_fetch_element);
 }
 
+int   
+sys_fexecve(struct lwp *l, const struct sys_fexecve_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int)			fd;
+		syscallarg(char * const *)	argp;
+		syscallarg(char * const *)	envp;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Load modules to try and execute an image that we do not understand.
  * If no execsw entries are present, we load those likely to be needed

Index: src/sys/kern/syscalls.master
diff -u src/sys/kern/syscalls.master:1.250 src/sys/kern/syscalls.master:1.251
--- src/sys/kern/syscalls.master:1.250	Mon Jul 18 11:28:24 2011
+++ src/sys/kern/syscalls.master	Mon Aug  8 12:08:53 2011
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.250 2011/07/18 11:28:24 drochner Exp $
+	$NetBSD: syscalls.master,v 1.251 2011/08/08 12:08:53 manu Exp $
 
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
 
@@ -893,3 +893,33 @@
 456	STD  RUMP	{ int|sys||paccept(int s, struct sockaddr *name, \
 			    socklen_t *anamelen, const sigset_t *mask, \
 			    int flags); }
+457	STD  RUMP	{ int|sys||linkat(int fd1, const char *name1, \
+			    int fd2, const char *name2, int flags); }
+458	STD  RUMP	{ int|sys||renameat(int fromfd, const char *from, \
+			    int tofd, const char *to); }
+459	STD  RUMP	{ int|sys||mkfifoat(int fd, const char *path, \
+			    mode_t mode); }
+460	STD  RUMP	{ int|sys||mknodat(int fd, const char *path, \
+			    mode_t mode, uint32_t dev); }
+461	STD  RUMP	{ int|sys||mkdirat(int fd, const char *path, \
+			    mode_t mode); }
+462	STD  RUMP	{ int|sys||faccessat(int fd, const char *path, \
+			    int amode, int flag); }
+463	STD  RUMP	{ int|sys||fchmodat(int fd, const char *path, \
+			    mode_t mode, int flag); }
+464	STD  RUMP	{ int|sys||fchownat(int fd, const char *path, \
+			    uid_t owner, gid_t group, int flag); }
+465	STD  RUMP	{ int|sys||fexecve(int fd, \
+			    char * const *argp, char * const *envp); }
+466	STD  RUMP	{ int|sys||fstatat(int fd, const char *path, \
+			    struct stat *buf, int flag); }
+467	STD  RUMP	{ int|sys||utimensat(int fd, const char *path, \
+			    const struct timespec *tptr, int flag); }
+468	STD  RUMP	{ int|sys||openat(int fd, const char *path, \
+			    int oflags, ... mode_t mode); }
+469	STD  RUMP	{ int|sys||readlinkat(int fd, const char *path, \
+			    char *buf, size_t bufsize); }
+470	STD  RUMP	{ int|sys||symlinkat(const char *path1, int fd, \
+			    const char *path2); }
+471	STD  RUMP	{ int|sys||unlinkat(int fd, const char *path, \
+			    int flag); }

Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.432 src/sys/kern/vfs_syscalls.c:1.433
--- src/sys/kern/vfs_syscalls.c:1.432	Sun Jul 24 09:40:10 2011
+++ src/sys/kern/vfs_syscalls.c	Mon Aug  8 12:08:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.432 2011/07/24 09:40:10 martin Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.433 2011/08/08 12:08:53 manu Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.432 2011/07/24 09:40:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.433 2011/08/08 12:08:53 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -83,6 +83,7 @@
 #include <sys/filedesc.h>
 #include <sys/kernel.h>
 #include <sys/file.h>
+#include <sys/fcntl.h>
 #include <sys/stat.h>
 #include <sys/vnode.h>
 #include <sys/mount.h>
@@ -1160,6 +1161,19 @@
 	return (0);
 }
 
+int
+sys_openat(struct lwp *l, const struct sys_openat_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(int) flags;
+		syscallarg(int) mode;
+	} */
+
+	return ENOSYS;
+}
+
 static void
 vfs__fhfree(fhandle_t *fhp)
 {
@@ -1616,6 +1630,20 @@
 }
 
 int
+sys_mknodat(struct lwp *l, const struct sys_mknodat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(mode_t) mode;
+		syscallarg(uint32_t) dev;
+	} */
+
+	return ENOSYS;
+}
+
+int
 do_sys_mknod(struct lwp *l, const char *pathname, mode_t mode, dev_t dev,
     register_t *retval, enum uio_seg seg)
 {
@@ -1771,27 +1799,41 @@
 	return (error);
 }
 
-/*
- * Make a hard file link.
- */
-/* ARGSUSED */
 int
-sys_link(struct lwp *l, const struct sys_link_args *uap, register_t *retval)
+sys_mkfifoat(struct lwp *l, const struct sys_mkfifoat_args *uap, 
+    register_t *retval)
 {
 	/* {
+		syscallarg(int) fd;
 		syscallarg(const char *) path;
-		syscallarg(const char *) link;
+		syscallarg(int) mode;
 	} */
+
+	return ENOSYS;
+}
+/*
+ * Make a hard file link.
+ */
+/* ARGSUSED */
+static int
+do_sys_link(struct lwp *l, const char *path, const char *link, 
+	    int follow, register_t *retval) 
+{
 	struct vnode *vp;
 	struct pathbuf *linkpb;
 	struct nameidata nd;
+	namei_simple_flags_t namei_simple_flags;
 	int error;
 
-	error = namei_simple_user(SCARG(uap, path),
-				NSM_FOLLOW_TRYEMULROOT, &vp);
+	if (follow)
+		namei_simple_flags = NSM_FOLLOW_TRYEMULROOT;
+	else
+		namei_simple_flags =  NSM_NOFOLLOW_TRYEMULROOT;
+
+	error = namei_simple_user(path, namei_simple_flags, &vp);
 	if (error != 0)
 		return (error);
-	error = pathbuf_copyin(SCARG(uap, link), &linkpb);
+	error = pathbuf_copyin(link, &linkpb);
 	if (error) {
 		goto out1;
 	}
@@ -1830,6 +1872,46 @@
 }
 
 int
+sys_link(struct lwp *l, const struct sys_link_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(const char *) path;
+		syscallarg(const char *) link;
+	} */
+	const char *path = SCARG(uap, path);
+	const char *link = SCARG(uap, link);
+
+	return do_sys_link(l, path, link, 1, retval);
+}
+
+int
+sys_linkat(struct lwp *l, const struct sys_linkat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd1;
+		syscallarg(const char *) name1;
+		syscallarg(int) fd2;
+		syscallarg(const char *) name2;
+		syscallarg(int) flags;
+	} */
+	const char *name1 = SCARG(uap, name1);
+	const char *name2 = SCARG(uap, name2);
+	int follow;
+
+	/*
+	 * Specified fd1 and fd2 are not yet implemented
+	 */ 
+	if ((SCARG(uap, fd1) != AT_FDCWD) || (SCARG(uap, fd2) != AT_FDCWD))
+		return ENOSYS;
+
+	follow = SCARG(uap, flags) & AT_SYMLINK_FOLLOW;
+
+	return do_sys_link(l, name1, name2, follow, retval);
+}
+
+
+int
 do_sys_symlink(const char *patharg, const char *link, enum uio_seg seg)
 {
 	struct proc *p = curproc;
@@ -1854,6 +1936,8 @@
 			goto out1;
 		}
 	}
+	ktrkuser("symlink-target", path, strlen(path));
+
 	NDINIT(&nd, CREATE, LOCKPARENT | TRYEMULROOT, linkpb);
 	if ((error = namei(&nd)) != 0)
 		goto out2;
@@ -1897,6 +1981,19 @@
 	    UIO_USERSPACE);
 }
 
+int
+sys_symlinkat(struct lwp *l, const struct sys_symlinkat_args *uap, 
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(const char *) link;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Delete a whiteout from the filesystem.
  */
@@ -1956,6 +2053,18 @@
 }
 
 int
+sys_unlinkat(struct lwp *l, const struct sys_unlinkat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+	} */
+
+	return ENOSYS;
+}
+
+int
 do_sys_unlink(const char *arg, enum uio_seg seg)
 {
 	struct vnode *vp;
@@ -2267,6 +2376,20 @@
 	return (error);
 }
 
+int
+sys_faccessat(struct lwp *l, const struct sys_faccessat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(int) amode;
+		syscallarg(int) flag;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Common code for all sys_stat functions, including compat versions.
  */
@@ -2333,6 +2456,19 @@
 	return copyout(&sb, SCARG(uap, ub), sizeof(sb));
 }
 
+int
+sys_fstatat(struct lwp *l, const struct sys_fstatat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(struct stat *) ub;
+		syscallarg(int) flag;
+	} */
+
+	return ENOSYS;
+}
 /*
  * Get configurable pathname variables.
  */
@@ -2413,6 +2549,20 @@
 	return (error);
 }
 
+int
+sys_readlinkat(struct lwp *l, const struct sys_readlinkat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(char *) buf;
+		syscallarg(size_t) count;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Change flags of a file given a path name.
  */
@@ -2560,6 +2710,20 @@
 	return (error);
 }
 
+int
+sys_fchmodat(struct lwp *l, const struct sys_fchmodat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(int) mode;
+		syscallarg(int) flag;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Change mode of a file given path name; this version does not follow links.
  */
@@ -2679,6 +2843,21 @@
 	return (error);
 }
 
+int
+sys_fchownat(struct lwp *l, const struct sys_fchownat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(uid_t) uid;
+		syscallarg(gid_t) gid;
+		syscallarg(int) flag;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Set ownership given a file descriptor, providing POSIX/XPG semantics.
  */
@@ -2869,6 +3048,20 @@
 	    SCARG(uap, tptr), UIO_USERSPACE);
 }
 
+int
+sys_utimensat(struct lwp *l, const struct sys_utimensat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(const struct timespec *) tptr;
+		syscallarg(int) flag;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Common routine to set access and modification times given a vnode.
  */
@@ -3149,6 +3342,20 @@
 	return (do_sys_rename(SCARG(uap, from), SCARG(uap, to), UIO_USERSPACE, 0));
 }
 
+int
+sys_renameat(struct lwp *l, const struct sys_renameat_args *uap, 
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fromfd;
+		syscallarg(const char *) from;
+		syscallarg(int) tofd;
+		syscallarg(const char *) to;
+	} */
+
+	return ENOSYS;
+}
+
 /*
  * Rename files, POSIX semantics frontend.
  */
@@ -3362,6 +3569,20 @@
 }
 
 int
+sys_mkdirat(struct lwp *l, const struct sys_mkdirat_args *uap,
+    register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(const char *) path;
+		syscallarg(int) mode;
+	} */
+
+	return ENOSYS;
+}
+
+
+int
 do_sys_mkdir(const char *path, mode_t mode, enum uio_seg seg)
 {
 	struct proc *p = curlwp->l_proc;

Index: src/sys/sys/fcntl.h
diff -u src/sys/sys/fcntl.h:1.39 src/sys/sys/fcntl.h:1.40
--- src/sys/sys/fcntl.h:1.39	Sat Jul 30 12:08:36 2011
+++ src/sys/sys/fcntl.h	Mon Aug  8 12:08:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fcntl.h,v 1.39 2011/07/30 12:08:36 jmcneill Exp $	*/
+/*	$NetBSD: fcntl.h,v 1.40 2011/08/08 12:08:54 manu Exp $	*/
 
 /*-
  * Copyright (c) 1983, 1990, 1993
@@ -114,6 +114,9 @@
 
 #define	O_DIRECTORY	0x00200000	/* fail if not a directory */
 #define	O_CLOEXEC	0x00400000	/* set close on exec */
+#if defined(_INCOMPLETE_XOPEN_C063) || defined(_KERNEL)
+#define	O_SEARCH	0x00800000	/* skip search permission checks */
+#endif
 
 #ifdef _KERNEL
 /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
@@ -277,6 +280,18 @@
 #define	POSIX_FADV_DONTNEED	4	/* not be needed in near future */
 #define	POSIX_FADV_NOREUSE	5	/* be accessed once */
 
+/*
+ * Constants for linkat(2)
+ */
+#if defined(_INCOMPLETE_XOPEN_C063) || defined(_KERNEL)
+#define	AT_FDCWD		-100	/* Use cwd for relative link target */
+#define	AT_EACCESS		0x100	/* Use euig/egid for access checks */
+#define	AT_SYMLINK_NOFOLLOW	0x200	/* Do not follow symlinks */
+#define	AT_SYMLINK_FOLLOW	0x400	/* Follow symlinks */
+#define	AT_REMOVEDIR		0x800	/* Remove directory only */
+#endif
+
+
 #ifndef _KERNEL
 #include <sys/cdefs.h>
 
@@ -288,6 +303,13 @@
 int	flock(int, int);
 #endif /* _NETBSD_SOURCE */
 int	posix_fadvise(int, off_t, off_t, int);
+
+/*
+ * X/Open Extended API set 2 (a.k.a. C063)
+ */
+#if defined(_INCOMPLETE_XOPEN_C063)
+int	openat(int, const char *, int oflags, ...);
+#endif
 __END_DECLS
 #endif /* !_KERNEL */
 

Index: src/sys/sys/stat.h
diff -u src/sys/sys/stat.h:1.60 src/sys/sys/stat.h:1.61
--- src/sys/sys/stat.h:1.60	Sun Mar  6 17:08:38 2011
+++ src/sys/sys/stat.h	Mon Aug  8 12:08:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: stat.h,v 1.60 2011/03/06 17:08:38 bouyer Exp $	*/
+/*	$NetBSD: stat.h,v 1.61 2011/08/08 12:08:54 manu Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -233,6 +233,15 @@
 int	lchflags(const char *, unsigned long);
 int	lchmod(const char *, mode_t);
 #endif /* defined(_NETBSD_SOURCE) */
+
+/*
+ * X/Open Extended API set 2 (a.k.a. C063)
+ */
+#if defined(_INCOMPLETE_XOPEN_C063) 
+int     fstatat(int, const char *, struct stat *, int);
+int     utimensat(int, const char *, const struct timespec *, int);
+#endif
+
 __END_DECLS
 
 #endif /* !_KERNEL && !_STANDALONE */

Reply via email to