Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src First stage of support for Extended API set 2. Most of the t...
details: https://anonhg.NetBSD.org/src/rev/dab203d60bcc
branches: trunk
changeset: 768090:dab203d60bcc
user: manu <manu%NetBSD.org@localhost>
date: Mon Aug 08 12:08:52 2011 +0000
description:
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.
diffstat:
distrib/sets/lists/comp/mi | 5 +-
include/unistd.h | 20 +++-
lib/libc/sys/Makefile.inc | 38 +++---
lib/libc/sys/link.2 | 29 +++++-
sys/kern/kern_exec.c | 17 ++-
sys/kern/syscalls.master | 32 +++++-
sys/kern/vfs_syscalls.c | 243 ++++++++++++++++++++++++++++++++++++++++++--
sys/sys/fcntl.h | 24 ++++-
sys/sys/stat.h | 11 +-
9 files changed, 382 insertions(+), 37 deletions(-)
diffs (truncated from 745 to 300 lines):
diff -r 763b740d4183 -r dab203d60bcc distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Mon Aug 08 11:42:30 2011 +0000
+++ b/distrib/sets/lists/comp/mi Mon Aug 08 12:08:52 2011 +0000
@@ -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
diff -r 763b740d4183 -r dab203d60bcc include/unistd.h
--- a/include/unistd.h Mon Aug 08 11:42:30 2011 +0000
+++ b/include/unistd.h Mon Aug 08 12:08:52 2011 +0000
@@ -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
diff -r 763b740d4183 -r dab203d60bcc lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc Mon Aug 08 11:42:30 2011 +0000
+++ b/lib/libc/sys/Makefile.inc Mon Aug 08 12:08:52 2011 +0000
@@ -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
diff -r 763b740d4183 -r dab203d60bcc lib/libc/sys/link.2
--- a/lib/libc/sys/link.2 Mon Aug 08 11:42:30 2011 +0000
+++ b/lib/libc/sys/link.2 Mon Aug 08 12:08:52 2011 +0000
@@ -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
diff -r 763b740d4183 -r dab203d60bcc sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c Mon Aug 08 11:42:30 2011 +0000
+++ b/sys/kern/kern_exec.c Mon Aug 08 12:08:52 2011 +0000
@@ -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
diff -r 763b740d4183 -r dab203d60bcc sys/kern/syscalls.master
--- a/sys/kern/syscalls.master Mon Aug 08 11:42:30 2011 +0000
+++ b/sys/kern/syscalls.master Mon Aug 08 12:08:52 2011 +0000
@@ -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); }
diff -r 763b740d4183 -r dab203d60bcc sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Mon Aug 08 11:42:30 2011 +0000
+++ b/sys/kern/vfs_syscalls.c Mon Aug 08 12:08:52 2011 +0000
@@ -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>
Home |
Main Index |
Thread Index |
Old Index