Cloning cleanup:
1. make fileops const 2. add 2 new negative errno's to `officially' support the cloning hack: - EDUPFD (used to overload ENODEV) - EMOVEFD (used to overload ENXIO) 3. Created an fdclone() function to encapsulate the operations needed for EMOVEFD, and made all cloners use it. 4. Centralize the local noop/badop fileops functions to: fnullop_fcntl, fnullop_poll, fnullop_kqfilter, fbadop_stat
This commit is contained in:
parent
2b9d36c223
commit
31c81b28f5
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svr4_net.c,v 1.36 2004/05/22 22:52:13 jonathan Exp $ */
|
||||
/* $NetBSD: svr4_net.c,v 1.37 2004/11/30 04:25:43 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.36 2004/05/22 22:52:13 jonathan Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.37 2004/11/30 04:25:43 christos Exp $");
|
||||
|
||||
#define COMPAT_SVR4 1
|
||||
|
||||
|
@ -109,7 +109,7 @@ int svr4_netattach __P((int));
|
|||
int svr4_soo_close __P((struct file *, struct proc *));
|
||||
int svr4_ptm_alloc __P((struct proc *));
|
||||
|
||||
static struct fileops svr4_netops = {
|
||||
static const struct fileops svr4_netops = {
|
||||
soo_read, soo_write, soo_ioctl, soo_fcntl, soo_poll,
|
||||
soo_stat, svr4_soo_close, soo_kqfilter
|
||||
};
|
||||
|
@ -211,19 +211,12 @@ svr4_netopen(dev, flag, mode, p)
|
|||
return error;
|
||||
}
|
||||
|
||||
fp->f_flag = FREAD|FWRITE;
|
||||
error = fdclone(p, fp, fd, &svr4_netops, so);
|
||||
fp->f_type = DTYPE_SOCKET;
|
||||
fp->f_ops = &svr4_netops;
|
||||
|
||||
fp->f_data = (caddr_t)so;
|
||||
(void) svr4_stream_get(fp);
|
||||
(void)svr4_stream_get(fp);
|
||||
|
||||
DPRINTF(("ok);\n"));
|
||||
|
||||
curlwp->l_dupfd = fd; /* XXX */
|
||||
FILE_SET_MATURE(fp);
|
||||
FILE_UNUSE(fp, p);
|
||||
return ENXIO;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,8 +276,8 @@ svr4_ptm_alloc(p)
|
|||
case ENXIO:
|
||||
return error;
|
||||
case 0:
|
||||
curlwp->l_dupfd = fd; /* XXX */
|
||||
return ENXIO;
|
||||
curlwp->l_dupfd = fd;
|
||||
return EMOVEFD;
|
||||
default:
|
||||
if (ttynumbers[++n] == '\0') {
|
||||
if (ttyletters[++l] == '\0')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svr4_32_net.c,v 1.10 2003/09/13 08:22:51 jdolecek Exp $ */
|
||||
/* $NetBSD: svr4_32_net.c,v 1.11 2004/11/30 04:25:43 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.10 2003/09/13 08:22:51 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.11 2004/11/30 04:25:43 christos Exp $");
|
||||
|
||||
#define COMPAT_SVR4 1
|
||||
|
||||
|
@ -102,7 +102,7 @@ int svr4_32_netattach __P((int));
|
|||
int svr4_soo_close __P((struct file *, struct proc *));
|
||||
int svr4_ptm_alloc __P((struct proc *));
|
||||
|
||||
static struct fileops svr4_32_netops = {
|
||||
static const struct fileops svr4_32_netops = {
|
||||
soo_read, soo_write, soo_ioctl, soo_fcntl, soo_poll,
|
||||
soo_stat, svr4_soo_close
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dmover_io.c,v 1.14 2004/11/28 07:44:05 thorpej Exp $ */
|
||||
/* $NetBSD: dmover_io.c,v 1.15 2004/11/30 04:25:43 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, 2003 Wasabi Systems, Inc.
|
||||
|
@ -55,7 +55,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.14 2004/11/28 07:44:05 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.15 2004/11/30 04:25:43 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
@ -579,21 +579,6 @@ dmio_ioctl(struct file *fp, u_long cmd, void *data, struct proc *p)
|
|||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* dmio_fcntl:
|
||||
*
|
||||
* Fcntl file op.
|
||||
*/
|
||||
static int
|
||||
dmio_fcntl(struct file *fp, u_int cmd, void *data, struct proc *p)
|
||||
{
|
||||
|
||||
if (cmd == F_SETFL)
|
||||
return (0);
|
||||
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/*
|
||||
* dmio_poll:
|
||||
*
|
||||
|
@ -643,18 +628,6 @@ dmio_poll(struct file *fp, int events, struct proc *p)
|
|||
return (revents);
|
||||
}
|
||||
|
||||
/*
|
||||
* dmio_stat:
|
||||
*
|
||||
* Stat file op.
|
||||
*/
|
||||
static int
|
||||
dmio_stat(struct file *fp, struct stat *sb, struct proc *p)
|
||||
{
|
||||
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/*
|
||||
* dmio_close:
|
||||
*
|
||||
|
@ -704,14 +677,15 @@ dmio_close(struct file *fp, struct proc *p)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static struct fileops dmio_fileops = {
|
||||
static const struct fileops dmio_fileops = {
|
||||
dmio_read,
|
||||
dmio_write,
|
||||
dmio_ioctl,
|
||||
dmio_fcntl,
|
||||
fnullop_fcntl,
|
||||
dmio_poll,
|
||||
dmio_stat,
|
||||
fbadop_stat,
|
||||
dmio_close,
|
||||
fnullop_kqueue
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -738,14 +712,5 @@ dmoverioopen(dev_t dev, int flag, int mode, struct proc *p)
|
|||
TAILQ_INIT(&ds->ds_pending);
|
||||
TAILQ_INIT(&ds->ds_complete);
|
||||
|
||||
fp->f_flag = FREAD | FWRITE;
|
||||
fp->f_type = DTYPE_MISC;
|
||||
fp->f_ops = &dmio_fileops;
|
||||
fp->f_data = (caddr_t) ds;
|
||||
|
||||
curlwp->l_dupfd = fd; /* XXX */
|
||||
FILE_SET_MATURE(fp);
|
||||
FILE_UNUSE(fp, p);
|
||||
|
||||
return (ENXIO);
|
||||
return fdclone(p, fp, fd, &dmio_fileops, ds);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_descrip.c,v 1.126 2004/05/31 15:30:55 pk Exp $ */
|
||||
/* $NetBSD: kern_descrip.c,v 1.127 2004/11/30 04:25:43 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.126 2004/05/31 15:30:55 pk Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.127 2004/11/30 04:25:43 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1515,7 +1515,7 @@ filedescopen(dev_t dev, int mode, int type, struct proc *p)
|
|||
* will simply report the error.
|
||||
*/
|
||||
curlwp->l_dupfd = minor(dev); /* XXX */
|
||||
return (ENODEV);
|
||||
return EDUPFD;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1551,17 +1551,17 @@ dupfdopen(struct proc *p, int indx, int dfd, int mode, int error)
|
|||
/*
|
||||
* There are two cases of interest here.
|
||||
*
|
||||
* For ENODEV simply dup (dfd) to file descriptor
|
||||
* For EDUPFD simply dup (dfd) to file descriptor
|
||||
* (indx) and return.
|
||||
*
|
||||
* For ENXIO steal away the file structure from (dfd) and
|
||||
* For EMOVEFD steal away the file structure from (dfd) and
|
||||
* store it in (indx). (dfd) is effectively closed by
|
||||
* this operation.
|
||||
*
|
||||
* Any other error code is just returned.
|
||||
*/
|
||||
switch (error) {
|
||||
case ENODEV:
|
||||
case EDUPFD:
|
||||
/*
|
||||
* Check that the mode the file is being opened for is a
|
||||
* subset of the mode of the existing descriptor.
|
||||
|
@ -1580,7 +1580,7 @@ dupfdopen(struct proc *p, int indx, int dfd, int mode, int error)
|
|||
FILE_UNUSE_HAVELOCK(wfp, p);
|
||||
return (0);
|
||||
|
||||
case ENXIO:
|
||||
case EMOVEFD:
|
||||
/*
|
||||
* Steal away the file pointer from dfd, and stuff it into indx.
|
||||
*/
|
||||
|
@ -1838,3 +1838,52 @@ fownsignal(pid_t pgid, int signo, int code, int band, void *fdescdata)
|
|||
else if (pgid < 0)
|
||||
kgsignal(-pgid, &ksi, fdescdata);
|
||||
}
|
||||
|
||||
int
|
||||
fdclone(struct proc *p, struct file *fp, int fd, const struct fileops *fops,
|
||||
void *data)
|
||||
{
|
||||
fp->f_flag = FREAD | FWRITE;
|
||||
fp->f_type = DTYPE_MISC;
|
||||
fp->f_ops = fops;
|
||||
fp->f_data = data;
|
||||
|
||||
curlwp->l_dupfd = fd;
|
||||
|
||||
FILE_SET_MATURE(fp);
|
||||
FILE_UNUSE(fp, p);
|
||||
return EMOVEFD;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fnullop_fcntl(struct file *fp, u_int cmd, void *data, struct proc *p)
|
||||
{
|
||||
if (cmd == F_SETFL)
|
||||
return 0;
|
||||
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fnullop_poll(struct file *fp, int which, struct proc *p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fnullop_kqfilter(struct file *fp, struct knote *kn)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
fbadop_stat(struct file *fp, struct stat *sb, struct proc *p)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_event.c,v 1.20 2004/04/25 16:42:41 simonb Exp $ */
|
||||
/* $NetBSD: kern_event.c,v 1.21 2004/11/30 04:25:43 christos Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.20 2004/04/25 16:42:41 simonb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.21 2004/11/30 04:25:43 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -72,7 +72,7 @@ static int kqueue_kqfilter(struct file *fp, struct knote *kn);
|
|||
static int kqueue_stat(struct file *fp, struct stat *sp, struct proc *p);
|
||||
static int kqueue_close(struct file *fp, struct proc *p);
|
||||
|
||||
static struct fileops kqueueops = {
|
||||
static const struct fileops kqueueops = {
|
||||
kqueue_read, kqueue_write, kqueue_ioctl, kqueue_fcntl, kqueue_poll,
|
||||
kqueue_stat, kqueue_close, kqueue_kqfilter
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_systrace.c,v 1.41 2004/11/28 07:44:05 thorpej Exp $ */
|
||||
/* $NetBSD: kern_systrace.c,v 1.42 2004/11/30 04:25:43 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2002, 2003 Niels Provos <provos@citi.umich.edu>
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.41 2004/11/28 07:44:05 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.42 2004/11/30 04:25:43 christos Exp $");
|
||||
|
||||
#include "opt_systrace.h"
|
||||
|
||||
|
@ -84,16 +84,13 @@ int systracef_read(struct file *, off_t *, struct uio *, struct ucred *,
|
|||
int);
|
||||
int systracef_write(struct file *, off_t *, struct uio *, struct ucred *,
|
||||
int);
|
||||
int systracef_fcntl(struct file *, u_int, void *, struct proc *);
|
||||
int systracef_poll(struct file *, int, struct proc *);
|
||||
#else
|
||||
int systracef_read(struct file *, off_t *, struct uio *, struct ucred *);
|
||||
int systracef_write(struct file *, off_t *, struct uio *, struct ucred *);
|
||||
int systracef_select(struct file *, int, struct proc *);
|
||||
#endif
|
||||
int systracef_kqfilter(struct file *, struct knote *);
|
||||
int systracef_ioctl(struct file *, u_long, void *, struct proc *);
|
||||
int systracef_stat(struct file *, struct stat *, struct proc *);
|
||||
int systracef_close(struct file *, struct proc *);
|
||||
|
||||
struct str_policy {
|
||||
|
@ -182,22 +179,15 @@ int systrace_msg_emul(struct fsystrace *, struct str_process *);
|
|||
int systrace_msg_ugid(struct fsystrace *, struct str_process *);
|
||||
int systrace_make_msg(struct str_process *, int, struct str_message *);
|
||||
|
||||
static struct fileops systracefops = {
|
||||
static const struct fileops systracefops = {
|
||||
systracef_read,
|
||||
systracef_write,
|
||||
systracef_ioctl,
|
||||
#ifdef __NetBSD__
|
||||
systracef_fcntl,
|
||||
fnullop_fcntl,
|
||||
systracef_poll,
|
||||
#else
|
||||
systracef_select,
|
||||
systracef_kqfilter,
|
||||
#endif
|
||||
systracef_stat,
|
||||
systracef_close
|
||||
#ifdef __NetBSD__
|
||||
, systracef_kqfilter
|
||||
#endif
|
||||
fbadop_stat,
|
||||
systracef_close,
|
||||
fnullop_kqfilter
|
||||
};
|
||||
|
||||
#ifdef __NetBSD__
|
||||
|
@ -432,19 +422,6 @@ systracef_ioctl(struct file *fp, u_long cmd, void *data, struct proc *p)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
#ifdef __NetBSD__
|
||||
/* ARGSUSED */
|
||||
int
|
||||
systracef_fcntl(struct file *fp, u_int cmd, void *data, struct proc *p)
|
||||
{
|
||||
|
||||
if (cmd == F_SETFL)
|
||||
return 0;
|
||||
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NetBSD__
|
||||
int
|
||||
systracef_poll(struct file *fp, int events, struct proc *p)
|
||||
|
@ -488,21 +465,6 @@ systracef_select(struct file *fp, int which, struct proc *p)
|
|||
}
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
systracef_kqfilter(struct file *fp, struct knote *kn)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
systracef_stat(struct file *fp, struct stat *sb, struct proc *p)
|
||||
{
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
systracef_close(struct file *fp, struct proc *p)
|
||||
|
@ -610,16 +572,7 @@ systraceopen(dev_t dev, int flag, int mode, struct proc *p)
|
|||
fst->p_ruid = p->p_cred->p_ruid;
|
||||
fst->p_rgid = p->p_cred->p_rgid;
|
||||
|
||||
fp->f_flag = FREAD | FWRITE;
|
||||
fp->f_type = DTYPE_MISC;
|
||||
fp->f_ops = &systracefops;
|
||||
fp->f_data = (caddr_t) fst;
|
||||
|
||||
curlwp->l_dupfd = fd; /* XXX */
|
||||
FILE_SET_MATURE(fp);
|
||||
FILE_UNUSE(fp, p);
|
||||
|
||||
return (ENXIO);
|
||||
return fdclone(p, fp, fd, &systracefops, fst);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sys_pipe.c,v 1.61 2004/11/21 04:30:33 yamt Exp $ */
|
||||
/* $NetBSD: sys_pipe.c,v 1.62 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -83,7 +83,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.61 2004/11/21 04:30:33 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.62 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -135,15 +135,13 @@ static int pipe_write(struct file *fp, off_t *offset, struct uio *uio,
|
|||
struct ucred *cred, int flags);
|
||||
static int pipe_close(struct file *fp, struct proc *p);
|
||||
static int pipe_poll(struct file *fp, int events, struct proc *p);
|
||||
static int pipe_fcntl(struct file *fp, u_int com, void *data,
|
||||
struct proc *p);
|
||||
static int pipe_kqfilter(struct file *fp, struct knote *kn);
|
||||
static int pipe_stat(struct file *fp, struct stat *sb, struct proc *p);
|
||||
static int pipe_ioctl(struct file *fp, u_long cmd, void *data,
|
||||
struct proc *p);
|
||||
|
||||
static struct fileops pipeops = {
|
||||
pipe_read, pipe_write, pipe_ioctl, pipe_fcntl, pipe_poll,
|
||||
static const struct fileops pipeops = {
|
||||
pipe_read, pipe_write, pipe_ioctl, fnullop_fcntl, pipe_poll,
|
||||
pipe_stat, pipe_close, pipe_kqfilter
|
||||
};
|
||||
|
||||
|
@ -1484,19 +1482,6 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
pipe_fcntl(fp, cmd, data, p)
|
||||
struct file *fp;
|
||||
u_int cmd;
|
||||
void *data;
|
||||
struct proc *p;
|
||||
{
|
||||
if (cmd == F_SETFL)
|
||||
return (0);
|
||||
else
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle pipe sysctls.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty_ptm.c,v 1.3 2004/11/24 22:19:27 christos Exp $ */
|
||||
/* $NetBSD: tty_ptm.c,v 1.4 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.3 2004/11/24 22:19:27 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.4 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include "opt_ptm.h"
|
||||
|
||||
|
@ -340,7 +340,7 @@ ptmopen(dev_t dev, int flag, int mode, struct proc *p)
|
|||
if ((error = pty_alloc_master(p, &fd, &dev)) != 0)
|
||||
return error;
|
||||
curlwp->l_dupfd = fd;
|
||||
return ENXIO;
|
||||
return EMOVEFD;
|
||||
case 1: /* /dev/ptm */
|
||||
return 0;
|
||||
default:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uipc_syscalls.c,v 1.88 2004/05/22 22:52:13 jonathan Exp $ */
|
||||
/* $NetBSD: uipc_syscalls.c,v 1.89 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1990, 1993
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.88 2004/05/22 22:52:13 jonathan Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.89 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
#include "opt_pipe.h"
|
||||
|
@ -64,7 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.88 2004/05/22 22:52:13 jonathan
|
|||
/*
|
||||
* System call interface to the socket abstraction.
|
||||
*/
|
||||
extern struct fileops socketops;
|
||||
extern const struct fileops socketops;
|
||||
|
||||
int
|
||||
sys_socket(struct lwp *l, void *v, register_t *retval)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_syscalls.c,v 1.212 2004/10/01 16:30:56 yamt Exp $ */
|
||||
/* $NetBSD: vfs_syscalls.c,v 1.213 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.212 2004/10/01 16:30:56 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.213 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_compat_43.h"
|
||||
|
@ -1142,7 +1142,7 @@ sys_open(l, v, retval)
|
|||
FILE_UNUSE(fp, p);
|
||||
fdp->fd_ofiles[indx] = NULL;
|
||||
ffree(fp);
|
||||
if ((error == ENODEV || error == ENXIO) &&
|
||||
if ((error == EDUPFD || error == EMOVEFD) &&
|
||||
l->l_dupfd >= 0 && /* XXX from fdopen */
|
||||
(error =
|
||||
dupfdopen(p, indx, l->l_dupfd, flags, error)) == 0) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_vnops.c,v 1.82 2004/11/06 07:34:53 christos Exp $ */
|
||||
/* $NetBSD: vfs_vnops.c,v 1.83 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.82 2004/11/06 07:34:53 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.83 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include "fs_union.h"
|
||||
|
||||
|
@ -85,7 +85,7 @@ static int vn_fcntl(struct file *fp, u_int com, void *data, struct proc *p);
|
|||
static int vn_statfile(struct file *fp, struct stat *sb, struct proc *p);
|
||||
static int vn_ioctl(struct file *fp, u_long com, void *data, struct proc *p);
|
||||
|
||||
struct fileops vnops = {
|
||||
const struct fileops vnops = {
|
||||
vn_read, vn_write, vn_ioctl, vn_fcntl, vn_poll,
|
||||
vn_statfile, vn_closefile, vn_kqfilter
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fdesc_vnops.c,v 1.81 2004/04/27 17:37:31 jrf Exp $ */
|
||||
/* $NetBSD: fdesc_vnops.c,v 1.82 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.81 2004/04/27 17:37:31 jrf Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.82 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -450,7 +450,7 @@ fdesc_open(v)
|
|||
* VOP_OPEN will simply report the error.
|
||||
*/
|
||||
curlwp->l_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */
|
||||
return (ENODEV);
|
||||
return EDUPFD;
|
||||
|
||||
case Fctty:
|
||||
return ((*ctty_cdevsw.d_open)(devctty, ap->a_mode, 0, ap->a_p));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: portal_vnops.c,v 1.57 2004/11/12 04:15:29 atatat Exp $ */
|
||||
/* $NetBSD: portal_vnops.c,v 1.58 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.57 2004/11/12 04:15:29 atatat Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.58 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -337,7 +337,7 @@ portal_open(v)
|
|||
* by testing whether the dupfd has been set.
|
||||
*/
|
||||
if (curlwp->l_dupfd >= 0) /* XXX */
|
||||
return (ENODEV);
|
||||
return EDUPFD;
|
||||
|
||||
pt = VTOPORTAL(vp);
|
||||
fmp = VFSTOPORTAL(vp->v_mount);
|
||||
|
@ -510,11 +510,11 @@ portal_open(v)
|
|||
|
||||
/*
|
||||
* Save the dup fd in the proc structure then return the
|
||||
* special error code (ENXIO) which causes magic things to
|
||||
* special error code (EMOVEFD) which causes magic things to
|
||||
* happen in vn_open. The whole concept is, well, hmmm.
|
||||
*/
|
||||
curlwp->l_dupfd = fd; /* XXX */
|
||||
error = ENXIO;
|
||||
curlwp->l_dupfd = fd;
|
||||
error = EMOVEFD;
|
||||
|
||||
bad:;
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cryptodev.c,v 1.11 2004/09/17 14:11:27 skrll Exp $ */
|
||||
/* $NetBSD: cryptodev.c,v 1.12 2004/11/30 04:25:44 christos Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
|
||||
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.11 2004/09/17 14:11:27 skrll Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.12 2004/11/30 04:25:44 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -97,21 +97,17 @@ static int cryptoselect(dev_t dev, int rw, struct proc *p);
|
|||
static int cryptof_read(struct file *, off_t *, struct uio *, struct ucred *, int);
|
||||
static int cryptof_write(struct file *, off_t *, struct uio *, struct ucred *, int);
|
||||
static int cryptof_ioctl(struct file *, u_long, void*, struct proc *p);
|
||||
static int cryptof_fcntl(struct file *, u_int, void*, struct proc *p);
|
||||
static int cryptof_poll(struct file *, int, struct proc *);
|
||||
static int cryptof_kqfilter(struct file *, struct knote *);
|
||||
static int cryptof_stat(struct file *, struct stat *, struct proc *);
|
||||
static int cryptof_close(struct file *, struct proc *);
|
||||
|
||||
static struct fileops cryptofops = {
|
||||
static const struct fileops cryptofops = {
|
||||
cryptof_read,
|
||||
cryptof_write,
|
||||
cryptof_ioctl,
|
||||
cryptof_fcntl,
|
||||
cryptof_poll,
|
||||
cryptof_stat,
|
||||
fnullop_fcntl,
|
||||
fnullop_poll,
|
||||
fbadop_stat,
|
||||
cryptof_close,
|
||||
cryptof_kqfilter
|
||||
fnullop_kqfilter
|
||||
};
|
||||
|
||||
static struct csession *csefind(struct fcrypt *, u_int);
|
||||
|
@ -327,13 +323,6 @@ bail:
|
|||
return (error);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
cryptof_fcntl(struct file *fp, u_int cmd, void *data, struct proc *p)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cryptodev_op(struct csession *cse, struct crypt_op *cop, struct proc *p)
|
||||
{
|
||||
|
@ -596,29 +585,6 @@ fail:
|
|||
return (error);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
cryptof_poll(struct file *fp, int which, struct proc *p)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
cryptof_kqfilter(struct file *fp, struct knote *kn)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
cryptof_stat(struct file *fp, struct stat *sb, struct proc *p)
|
||||
{
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
cryptof_close(struct file *fp, struct proc *p)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: errno.h,v 1.34 2003/08/07 16:34:03 agc Exp $ */
|
||||
/* $NetBSD: errno.h,v 1.35 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -171,6 +171,8 @@
|
|||
#define EJUSTRETURN -2 /* don't modify regs, just return */
|
||||
#define ERESTART -3 /* restart syscall */
|
||||
#define EPASSTHROUGH -4 /* ioctl not handled by this layer */
|
||||
#define EDUPFD -5 /* Dup given fd */
|
||||
#define EMOVEFD -6 /* Move given fd */
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_ERRNO_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: file.h,v 1.50 2004/05/16 17:48:18 pk Exp $ */
|
||||
/* $NetBSD: file.h,v 1.51 2004/11/30 04:25:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -70,7 +70,7 @@ struct file {
|
|||
u_int f_msgcount; /* references from message queue */
|
||||
int f_usecount; /* number active users */
|
||||
struct ucred *f_cred; /* creds associated with descriptor */
|
||||
struct fileops {
|
||||
const struct fileops {
|
||||
int (*fo_read) (struct file *, off_t *, struct uio *,
|
||||
struct ucred *, int);
|
||||
int (*fo_write) (struct file *, off_t *, struct uio *,
|
||||
|
@ -151,7 +151,7 @@ extern struct filelist filehead; /* head of list of open files */
|
|||
extern int maxfiles; /* kernel limit on # of open files */
|
||||
extern int nfiles; /* actual number of open files */
|
||||
|
||||
extern struct fileops vnops; /* vnode operations for files */
|
||||
extern const struct fileops vnops; /* vnode operations for files */
|
||||
|
||||
int dofileread(struct proc *, int, struct file *, void *, size_t,
|
||||
off_t *, int, register_t *);
|
||||
|
@ -167,6 +167,15 @@ int fsetown(struct proc *, pid_t *, int, const void *);
|
|||
int fgetown(struct proc *, pid_t, int, void *);
|
||||
void fownsignal(pid_t, int, int, int, void *);
|
||||
|
||||
int fdclone(struct proc *, struct file *, int, const struct fileops *,
|
||||
void *);
|
||||
|
||||
/* Commonly used fileops */
|
||||
int fnullop_fcntl(struct file *, u_int, void *, struct proc *);
|
||||
int fnullop_poll(struct file *, int, struct proc *);
|
||||
int fnullop_kqfilter(struct file *, struct knote *);
|
||||
int fbadop_stat(struct file *, struct stat *, struct proc *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_FILE_H_ */
|
||||
|
|
Loading…
Reference in New Issue