aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malone <dwmalone@FreeBSD.org>2004-03-16 10:46:42 +0000
committerDavid Malone <dwmalone@FreeBSD.org>2004-03-16 10:46:42 +0000
commit31c7e8b05b1303ef4a95b38f2da729910eba4d10 (patch)
tree66f96df9e290049d0e96248d21d693edbc3753b8
parent1f325ae35e34c9e8ce698da233f63deac0b41696 (diff)
downloadsrc-31c7e8b05b1303ef4a95b38f2da729910eba4d10.tar.gz
src-31c7e8b05b1303ef4a95b38f2da729910eba4d10.zip
Nudge Giant as far as I can into kern_open(). Mark open() as MPSAFE.
Use kern_open() to implement creat() rather than taking the long route through open(). Mark creat as MPSAFE. While I'm at it, mark nosys() (syscall 0) as MPSAFE, for all the difference it will make.
Notes
Notes: svn path=/head/; revision=127062
-rw-r--r--sys/kern/init_sysent.c8
-rw-r--r--sys/kern/syscalls.c2
-rw-r--r--sys/kern/vfs_extattr.c20
-rw-r--r--sys/kern/vfs_syscalls.c20
-rw-r--r--sys/sys/syscall.h2
-rw-r--r--sys/sys/syscall.mk2
-rw-r--r--sys/sys/sysproto.h2
7 files changed, 30 insertions, 26 deletions
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index e72f77bc7e10..a5728e27ed29 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.168 2004/03/15 18:48:28 jhb Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.169 2004/03/16 10:41:23 dwmalone Exp
*/
#include "opt_compat.h"
@@ -28,15 +28,15 @@
/* The casts are bogus but will do for now. */
struct sysent sysent[] = {
- { 0, (sy_call_t *)nosys }, /* 0 = syscall */
+ { SYF_MPSAFE | 0, (sy_call_t *)nosys }, /* 0 = syscall */
{ SYF_MPSAFE | AS(sys_exit_args), (sy_call_t *)sys_exit }, /* 1 = exit */
{ SYF_MPSAFE | 0, (sy_call_t *)fork }, /* 2 = fork */
{ SYF_MPSAFE | AS(read_args), (sy_call_t *)read }, /* 3 = read */
{ SYF_MPSAFE | AS(write_args), (sy_call_t *)write }, /* 4 = write */
- { AS(open_args), (sy_call_t *)open }, /* 5 = open */
+ { SYF_MPSAFE | AS(open_args), (sy_call_t *)open }, /* 5 = open */
{ SYF_MPSAFE | AS(close_args), (sy_call_t *)close }, /* 6 = close */
{ SYF_MPSAFE | AS(wait_args), (sy_call_t *)wait4 }, /* 7 = wait4 */
- { compat(AS(ocreat_args),creat) }, /* 8 = old creat */
+ { compat(SYF_MPSAFE | AS(ocreat_args),creat) }, /* 8 = old creat */
{ AS(link_args), (sy_call_t *)link }, /* 9 = link */
{ AS(unlink_args), (sy_call_t *)unlink }, /* 10 = unlink */
{ 0, (sy_call_t *)nosys }, /* 11 = obsolete execv */
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index 46a836e7311b..81f7720d1233 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.168 2004/03/15 18:48:28 jhb Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.169 2004/03/16 10:41:23 dwmalone Exp
*/
const char *syscallnames[] = {
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index d06ba27c5596..98e2b695c1d0 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -920,6 +920,8 @@ change_root(vp, td)
/*
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
+ *
+ * MP SAFE
*/
#ifndef _SYS_SYSPROTO_H_
struct open_args {
@@ -968,8 +970,10 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, pathseg, path, td);
td->td_dupfd = -1; /* XXX check for fdopen */
+ mtx_lock(&Giant);
error = vn_open(&nd, &flags, cmode, indx);
if (error) {
+ mtx_unlock(&Giant);
/*
* If the vn_open replaced the method vector, something
@@ -1040,6 +1044,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
FILE_UNLOCK(fp);
VOP_UNLOCK(vp, 0, td);
vn_close(vp, flags & FMASK, fp->f_cred, td);
+ mtx_unlock(&Giant);
fdrop(fp, td);
td->td_retval[0] = indx;
return (0);
@@ -1091,6 +1096,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
if (error)
goto bad;
}
+ mtx_unlock(&Giant);
/*
* Release our private reference, leaving the one associated with
* the descriptor table intact.
@@ -1099,6 +1105,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
td->td_retval[0] = indx;
return (0);
bad:
+ mtx_unlock(&Giant);
FILEDESC_LOCK(fdp);
if (fdp->fd_ofiles[indx] == fp) {
fdp->fd_ofiles[indx] = NULL;
@@ -1115,6 +1122,8 @@ bad:
#ifdef COMPAT_43
/*
* Create a file.
+ *
+ * MP SAFE
*/
#ifndef _SYS_SYSPROTO_H_
struct ocreat_args {
@@ -1130,16 +1139,9 @@ ocreat(td, uap)
int mode;
} */ *uap;
{
- struct open_args /* {
- char *path;
- int flags;
- int mode;
- } */ nuap;
- nuap.path = uap->path;
- nuap.mode = uap->mode;
- nuap.flags = O_WRONLY | O_CREAT | O_TRUNC;
- return (open(td, &nuap));
+ return (kern_open(td, uap->path, UIO_USERSPACE,
+ O_WRONLY | O_CREAT | O_TRUNC, uap->mode));
}
#endif /* COMPAT_43 */
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index d06ba27c5596..98e2b695c1d0 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -920,6 +920,8 @@ change_root(vp, td)
/*
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
+ *
+ * MP SAFE
*/
#ifndef _SYS_SYSPROTO_H_
struct open_args {
@@ -968,8 +970,10 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, pathseg, path, td);
td->td_dupfd = -1; /* XXX check for fdopen */
+ mtx_lock(&Giant);
error = vn_open(&nd, &flags, cmode, indx);
if (error) {
+ mtx_unlock(&Giant);
/*
* If the vn_open replaced the method vector, something
@@ -1040,6 +1044,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
FILE_UNLOCK(fp);
VOP_UNLOCK(vp, 0, td);
vn_close(vp, flags & FMASK, fp->f_cred, td);
+ mtx_unlock(&Giant);
fdrop(fp, td);
td->td_retval[0] = indx;
return (0);
@@ -1091,6 +1096,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
if (error)
goto bad;
}
+ mtx_unlock(&Giant);
/*
* Release our private reference, leaving the one associated with
* the descriptor table intact.
@@ -1099,6 +1105,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
td->td_retval[0] = indx;
return (0);
bad:
+ mtx_unlock(&Giant);
FILEDESC_LOCK(fdp);
if (fdp->fd_ofiles[indx] == fp) {
fdp->fd_ofiles[indx] = NULL;
@@ -1115,6 +1122,8 @@ bad:
#ifdef COMPAT_43
/*
* Create a file.
+ *
+ * MP SAFE
*/
#ifndef _SYS_SYSPROTO_H_
struct ocreat_args {
@@ -1130,16 +1139,9 @@ ocreat(td, uap)
int mode;
} */ *uap;
{
- struct open_args /* {
- char *path;
- int flags;
- int mode;
- } */ nuap;
- nuap.path = uap->path;
- nuap.mode = uap->mode;
- nuap.flags = O_WRONLY | O_CREAT | O_TRUNC;
- return (open(td, &nuap));
+ return (kern_open(td, uap->path, UIO_USERSPACE,
+ O_WRONLY | O_CREAT | O_TRUNC, uap->mode));
}
#endif /* COMPAT_43 */
diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h
index e48431993961..7420b08daf87 100644
--- a/sys/sys/syscall.h
+++ b/sys/sys/syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.168 2004/03/15 18:48:28 jhb Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.169 2004/03/16 10:41:23 dwmalone Exp
*/
#define SYS_syscall 0
diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk
index 10b653bcaa8e..ddb4d4c26489 100644
--- a/sys/sys/syscall.mk
+++ b/sys/sys/syscall.mk
@@ -1,7 +1,7 @@
# FreeBSD system call names.
# DO NOT EDIT-- this file is automatically generated.
# $FreeBSD$
-# created from FreeBSD: src/sys/kern/syscalls.master,v 1.168 2004/03/15 18:48:28 jhb Exp
+# created from FreeBSD: src/sys/kern/syscalls.master,v 1.169 2004/03/16 10:41:23 dwmalone Exp
MIASM = \
syscall.o \
exit.o \
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index 067b787a5c18..775beee42d5a 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.168 2004/03/15 18:48:28 jhb Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.169 2004/03/16 10:41:23 dwmalone Exp
*/
#ifndef _SYS_SYSPROTO_H_