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.
This commit is contained in:
parent
1f325ae35e
commit
31c7e8b05b
@ -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 */
|
||||
|
@ -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[] = {
|
||||
|
@ -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 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
|
||||
#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 */
|
||||
|
||||
|
@ -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 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
|
||||
#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 */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -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_
|
||||
|
Loading…
Reference in New Issue
Block a user