summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2004-03-16 10:46:42 +0000
committerdwmalone <dwmalone@FreeBSD.org>2004-03-16 10:46:42 +0000
commit116755fef7f80b55f78e78d202d7f958e0f205e0 (patch)
tree66f96df9e290049d0e96248d21d693edbc3753b8 /sys/kern
parentbfd66a78ad56e89c04f9ebd3bbf25dafb92ca51b (diff)
downloadFreeBSD-src-116755fef7f80b55f78e78d202d7f958e0f205e0.zip
FreeBSD-src-116755fef7f80b55f78e78d202d7f958e0f205e0.tar.gz
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.
Diffstat (limited to 'sys/kern')
-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
4 files changed, 27 insertions, 23 deletions
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index e72f77b..a5728e2 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 46a836e..81f7720 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 d06ba27..98e2b69 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 d06ba27..98e2b69 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 */
OpenPOWER on IntegriCloud