summaryrefslogtreecommitdiffstats
path: root/sys/miscfs/fdesc/fdesc_vnops.c
diff options
context:
space:
mode:
authorchris <chris@FreeBSD.org>2000-05-11 22:10:51 +0000
committerchris <chris@FreeBSD.org>2000-05-11 22:10:51 +0000
commit9af0c6c060032728cc1b2d7d075a64ed940d244f (patch)
tree3611bba3e5dc5363f663fd76ad534aba9118b783 /sys/miscfs/fdesc/fdesc_vnops.c
parent38514c79e1a22f59968d7eaa717adfae49929f84 (diff)
downloadFreeBSD-src-9af0c6c060032728cc1b2d7d075a64ed940d244f.zip
FreeBSD-src-9af0c6c060032728cc1b2d7d075a64ed940d244f.tar.gz
Adapt fdesc to be mounted on /dev/fd and remove fd, stdin, stdout and
stderr nodes. More specific items of this patch: o Removed support for symbolic links, and the need for fdesc_readlink(). o Put all the code from fdesc_attr() into fdesc_getattr() and removed fdesc_attr(). This also made it easier to properly give all nodes unique inode numbers. o The removal of all non-fd nodes allowed the removal of the fdesc_read(), fdesc_write(), and fdesc_ioctl() nodes, since we no longer have nodes that get special handling. o Correct the component name validity-checking in fdesc_lookup(). It previously detected the end of the string by checking for a terminating NUL, now it uses cnp->cn_namelen. o Handle kqueue files as FIFOs. This is probably the closest file type to represent this type of file there is, and it is unfortunately not very representative of a kqueue. Creation time is not supported by kqueue, so ctime, mtime and atime are all set to the current time when getattr() was called. o Also set st_[mca]time to the current time since there's no data in socket structures that can be used to fill this in (FIFOs). o Simplify fdesc_readdir() since it only has to report the numbered fd nodes. Add `.' and `..' directory links as well. o Remove read bits from directories as they tend to confuse programs like tar(1). Reviewed by: phk Discussed with: bde (earlier on, not quite review)
Diffstat (limited to 'sys/miscfs/fdesc/fdesc_vnops.c')
-rw-r--r--sys/miscfs/fdesc/fdesc_vnops.c578
1 files changed, 152 insertions, 426 deletions
diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c
index 3256349..368d844 100644
--- a/sys/miscfs/fdesc/fdesc_vnops.c
+++ b/sys/miscfs/fdesc/fdesc_vnops.c
@@ -55,46 +55,31 @@
#include <sys/namei.h>
#include <sys/dirent.h>
#include <sys/conf.h>
+#include <sys/socketvar.h>
#include <miscfs/fdesc/fdesc.h>
-extern struct cdevsw ctty_cdevsw;
-
-#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
-
#define FDL_WANT 0x01
#define FDL_LOCKED 0x02
static int fdcache_lock;
static vop_t **fdesc_vnodeop_p;
-dev_t devctty;
-
-#if (FD_STDIN != FD_STDOUT-1) || (FD_STDOUT != FD_STDERR-1)
-FD_STDIN, FD_STDOUT, FD_STDERR must be a sequence n, n+1, n+2
-#endif
-
#define NFDCACHE 4
#define FD_NHASH(ix) \
(&fdhashtbl[(ix) & fdhash])
static LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl;
static u_long fdhash;
-static int fdesc_attr __P((int fd, struct vattr *vap, struct ucred *cred,
- struct proc *p));
static int fdesc_badop __P((void));
static int fdesc_getattr __P((struct vop_getattr_args *ap));
static int fdesc_inactive __P((struct vop_inactive_args *ap));
-static int fdesc_ioctl __P((struct vop_ioctl_args *ap));
static int fdesc_lookup __P((struct vop_lookup_args *ap));
static int fdesc_open __P((struct vop_open_args *ap));
static int fdesc_print __P((struct vop_print_args *ap));
-static int fdesc_read __P((struct vop_read_args *ap));
static int fdesc_readdir __P((struct vop_readdir_args *ap));
-static int fdesc_readlink __P((struct vop_readlink_args *ap));
static int fdesc_reclaim __P((struct vop_reclaim_args *ap));
static int fdesc_poll __P((struct vop_poll_args *ap));
static int fdesc_setattr __P((struct vop_setattr_args *ap));
-static int fdesc_write __P((struct vop_write_args *ap));
/*
* Initialise cache headers
@@ -104,7 +89,6 @@ fdesc_init(vfsp)
struct vfsconf *vfsp;
{
- devctty = NODEV;
fdhashtbl = hashinit(NFDCACHE, M_CACHE, &fdhash);
return (0);
}
@@ -163,7 +147,7 @@ loop:
fd->fd_ix = ix;
LIST_INSERT_HEAD(fc, fd, fd_hash);
-out:;
+out:
fdcache_lock &= ~FDL_LOCKED;
if (fdcache_lock & FDL_WANT) {
@@ -191,11 +175,11 @@ fdesc_lookup(ap)
struct componentname *cnp = ap->a_cnp;
char *pname = cnp->cn_nameptr;
struct proc *p = cnp->cn_proc;
+ int nlen = cnp->cn_namelen;
int nfiles = p->p_fd->fd_nfiles;
- unsigned fd = -1;
+ u_int fd;
int error;
struct vnode *fvp;
- char *ln;
if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
error = EROFS;
@@ -210,110 +194,34 @@ fdesc_lookup(ap)
return (0);
}
- switch (VTOFDESC(dvp)->fd_type) {
- default:
- case Flink:
- case Fdesc:
- case Fctty:
+ if (VTOFDESC(dvp)->fd_type != Froot) {
error = ENOTDIR;
goto bad;
+ }
- case Froot:
- if (cnp->cn_namelen == 2 && bcmp(pname, "fd", 2) == 0) {
- error = fdesc_allocvp(Fdevfd, FD_DEVFD, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- *vpp = fvp;
- fvp->v_type = VDIR;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- return (0);
- }
-
- if (cnp->cn_namelen == 3 && bcmp(pname, "tty", 3) == 0) {
- struct vnode *ttyvp = cttyvp(p);
- if (ttyvp == NULL) {
- error = ENXIO;
- goto bad;
- }
- error = fdesc_allocvp(Fctty, FD_CTTY, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- *vpp = fvp;
- fvp->v_type = VFIFO;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- return (0);
- }
-
- ln = 0;
- switch (cnp->cn_namelen) {
- case 5:
- if (bcmp(pname, "stdin", 5) == 0) {
- ln = "fd/0";
- fd = FD_STDIN;
- }
- break;
- case 6:
- if (bcmp(pname, "stdout", 6) == 0) {
- ln = "fd/1";
- fd = FD_STDOUT;
- } else
- if (bcmp(pname, "stderr", 6) == 0) {
- ln = "fd/2";
- fd = FD_STDERR;
- }
- break;
- }
-
- if (ln) {
- error = fdesc_allocvp(Flink, fd, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- VTOFDESC(fvp)->fd_link = ln;
- *vpp = fvp;
- fvp->v_type = VLNK;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- return (0);
- } else {
- error = ENOENT;
- goto bad;
- }
-
- /* FALL THROUGH */
-
- case Fdevfd:
- if (cnp->cn_namelen == 2 && bcmp(pname, "..", 2) == 0) {
- if ((error = fdesc_root(dvp->v_mount, vpp)) != 0)
- goto bad;
- return (0);
- }
-
- fd = 0;
- while (*pname >= '0' && *pname <= '9') {
- fd = 10 * fd + *pname++ - '0';
- if (fd >= nfiles)
- break;
- }
-
- if (*pname != '\0') {
+ fd = 0;
+ while (nlen--) {
+ if (*pname < '0' || *pname > '9') {
error = ENOENT;
goto bad;
}
+ fd = 10 * fd + *pname++ - '0';
+ }
- if (fd >= nfiles || p->p_fd->fd_ofiles[fd] == NULL) {
- error = EBADF;
- goto bad;
- }
-
- error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- VTOFDESC(fvp)->fd_fd = fd;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- *vpp = fvp;
- return (0);
+ if (fd >= nfiles || p->p_fd->fd_ofiles[fd] == NULL) {
+ error = EBADF;
+ goto bad;
}
-bad:;
+ error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
+ if (error)
+ goto bad;
+ VTOFDESC(fvp)->fd_fd = fd;
+ vn_lock(fvp, LK_SHARED | LK_RETRY, p);
+ *vpp = fvp;
+ return (0);
+
+bad:
vn_lock(dvp, LK_SHARED | LK_RETRY, p);
*vpp = NULL;
return (error);
@@ -329,91 +237,20 @@ fdesc_open(ap)
} */ *ap;
{
struct vnode *vp = ap->a_vp;
- int error = 0;
-
- switch (VTOFDESC(vp)->fd_type) {
- case Fdesc:
- /*
- * XXX Kludge: set p->p_dupfd to contain the value of the
- * the file descriptor being sought for duplication. The error
- * return ensures that the vnode for this device will be
- * released by vn_open. Open will detect this special error and
- * take the actions in dupfdopen. Other callers of vn_open or
- * VOP_OPEN will simply report the error.
- */
- ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */
- error = ENODEV;
- break;
- case Fctty:
- error = (*ctty_cdevsw.d_open)(devctty, ap->a_mode, 0, ap->a_p);
- break;
-
- default: /* nothing special */
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_attr(fd, vap, cred, p)
- int fd;
- struct vattr *vap;
- struct ucred *cred;
- struct proc *p;
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct stat stb;
- int error;
-
- if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
- return (EBADF);
-
- switch (fp->f_type) {
- case DTYPE_FIFO:
- case DTYPE_VNODE:
- error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred, p);
- if (error == 0 && vap->va_type == VDIR) {
- /*
- * directories can cause loops in the namespace,
- * so turn off the 'x' bits to avoid trouble.
- */
- vap->va_mode &= ~((VEXEC)|(VEXEC>>3)|(VEXEC>>6));
- }
- break;
-
- case DTYPE_PIPE:
- case DTYPE_SOCKET:
- error = fo_stat(fp, &stb, p);
- if (error == 0) {
- vattr_null(vap);
- vap->va_type = VSOCK; /* XXX pipe? */
- vap->va_mode = stb.st_mode;
- vap->va_nlink = stb.st_nlink;
- vap->va_uid = stb.st_uid;
- vap->va_gid = stb.st_gid;
- vap->va_fsid = stb.st_dev;
- vap->va_fileid = stb.st_ino;
- vap->va_size = stb.st_size;
- vap->va_blocksize = stb.st_blksize;
- vap->va_atime = stb.st_atimespec;
- vap->va_mtime = stb.st_mtimespec;
- vap->va_ctime = stb.st_ctimespec;
- vap->va_gen = stb.st_gen;
- vap->va_flags = stb.st_flags;
- vap->va_rdev = stb.st_rdev;
- vap->va_bytes = stb.st_blocks * stb.st_blksize;
- }
- break;
-
- default:
- panic("fdesc attr");
- break;
- }
+ if (VTOFDESC(vp)->fd_type == Froot)
+ return (0);
- return (error);
+ /*
+ * XXX Kludge: set p->p_dupfd to contain the value of the the file
+ * descriptor being sought for duplication. The error return ensures
+ * that the vnode for this device will be released by vn_open. Open
+ * will detect this special error and take the actions in dupfdopen.
+ * Other callers of vn_open or VOP_OPEN will simply report the
+ * error.
+ */
+ ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */
+ return (ENODEV);
}
static int
@@ -427,40 +264,22 @@ fdesc_getattr(ap)
{
struct vnode *vp = ap->a_vp;
struct vattr *vap = ap->a_vap;
- unsigned fd;
+ struct filedesc *fdp = ap->a_p->p_fd;
+ struct file *fp;
+ struct stat stb;
+ u_int fd;
int error = 0;
switch (VTOFDESC(vp)->fd_type) {
case Froot:
- case Fdevfd:
- case Flink:
- case Fctty:
bzero((caddr_t) vap, sizeof(*vap));
vattr_null(vap);
- vap->va_fileid = VTOFDESC(vp)->fd_ix;
-
- switch (VTOFDESC(vp)->fd_type) {
- case Flink:
- vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- vap->va_type = VLNK;
- vap->va_nlink = 1;
- vap->va_size = strlen(VTOFDESC(vp)->fd_link);
- break;
-
- case Fctty:
- vap->va_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
- vap->va_type = VFIFO;
- vap->va_nlink = 1;
- vap->va_size = 0;
- break;
- default:
- vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- vap->va_type = VDIR;
- vap->va_nlink = 2;
- vap->va_size = DEV_BSIZE;
- break;
- }
+ vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
+ vap->va_type = VDIR;
+ vap->va_nlink = 2;
+ vap->va_size = DEV_BSIZE;
+ vap->va_fileid = VTOFDESC(vp)->fd_ix;
vap->va_uid = 0;
vap->va_gid = 0;
vap->va_blocksize = DEV_BSIZE;
@@ -476,7 +295,75 @@ fdesc_getattr(ap)
case Fdesc:
fd = VTOFDESC(vp)->fd_fd;
- error = fdesc_attr(fd, vap, ap->a_cred, ap->a_p);
+
+ if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
+ return (EBADF);
+
+ switch (fp->f_type) {
+ case DTYPE_FIFO:
+ case DTYPE_VNODE:
+ error = VOP_GETATTR((struct vnode *) fp->f_data, vap,
+ ap->a_cred, ap->a_p);
+ if (error == 0 && vap->va_type == VDIR) {
+ /*
+ * directories can cause loops in the namespace,
+ * so turn off the 'r' and 'x' bits to avoid
+ * trouble.
+ */
+#define VRXEC (VREAD|VEXEC)
+ vap->va_mode &= ~((VRXEC)|(VRXEC>>3)|(VRXEC>>6));
+#undef VRXEC
+ }
+ /*
+ * Make sure these nodes reflect data as it pertains
+ * to fdesc and not the original file system.
+ */
+ vap->va_fileid = VTOFDESC(vp)->fd_ix;
+ vap->va_fsid = VNOVAL;
+ break;
+
+ case DTYPE_PIPE:
+ case DTYPE_SOCKET:
+ case DTYPE_KQUEUE:
+ error = fo_stat(fp, &stb, ap->a_p);
+ if (error == 0) {
+ vattr_null(vap);
+ if (fp->f_type == DTYPE_KQUEUE)
+ vap->va_type = VFIFO;
+ else
+ vap->va_type = IFTOVT(stb.st_mode);
+
+ vap->va_mode = S_IRUSR | S_IWUSR | S_IRGRP |
+ S_IWGRP | S_IROTH | S_IWOTH;
+ vap->va_nlink = 1;
+ vap->va_flags = 0;
+ vap->va_bytes = stb.st_blocks * stb.st_blksize;
+ vap->va_fsid = VNOVAL;
+ vap->va_fileid = VTOFDESC(vp)->fd_ix;
+ vap->va_size = stb.st_size;
+ vap->va_blocksize = stb.st_blksize;
+
+ /*
+ * XXX Sockets and kqueues don't have any
+ * mtime/atime/ctime data.
+ */
+ if (fp->f_type == DTYPE_SOCKET ||
+ fp->f_type == DTYPE_KQUEUE) {
+ nanotime(&stb.st_atimespec);
+ stb.st_mtimespec = stb.st_atimespec;
+ stb.st_ctimespec = stb.st_mtimespec;
+ }
+ vap->va_atime = stb.st_atimespec;
+ vap->va_mtime = stb.st_mtimespec;
+ vap->va_ctime = stb.st_ctimespec;
+ vap->va_uid = stb.st_uid;
+ vap->va_gid = stb.st_gid;
+ }
+ break;
+ default:
+ panic("fdesc_getattr: Unknown fp->f_type encountered");
+ break;
+ }
break;
default:
@@ -486,7 +373,6 @@ fdesc_getattr(ap)
if (error == 0)
vp->v_type = vap->va_type;
-
return (error);
}
@@ -508,23 +394,12 @@ fdesc_setattr(ap)
/*
* Can't mess with the root vnode
*/
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fdesc:
- break;
-
- case Fctty:
- if (vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
- return (0);
-
- default:
+ if (VTOFDESC(ap->a_vp)->fd_type == Froot)
return (EACCES);
- }
fd = VTOFDESC(ap->a_vp)->fd_fd;
- if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) {
+ if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
- }
/*
* Can setattr the underlying vnode, but not sockets!
@@ -533,10 +408,12 @@ fdesc_setattr(ap)
case DTYPE_FIFO:
case DTYPE_PIPE:
case DTYPE_VNODE:
- error = VOP_SETATTR((struct vnode *) fp->f_data, ap->a_vap, ap->a_cred, ap->a_p);
+ error = VOP_SETATTR((struct vnode *) fp->f_data, ap->a_vap,
+ ap->a_cred, ap->a_p);
break;
case DTYPE_SOCKET:
+ case DTYPE_KQUEUE:
if (vap->va_flags != VNOVAL)
error = EOPNOTSUPP;
else
@@ -553,19 +430,6 @@ fdesc_setattr(ap)
#define UIO_MX 16
-static struct dirtmp {
- u_long d_fileno;
- u_short d_reclen;
- u_short d_namlen;
- char d_name[8];
-} rootent[] = {
- { FD_DEVFD, UIO_MX, 2, "fd" },
- { FD_STDIN, UIO_MX, 5, "stdin" },
- { FD_STDOUT, UIO_MX, 6, "stdout" },
- { FD_STDERR, UIO_MX, 6, "stderr" },
- { FD_CTTY, UIO_MX, 3, "tty" },
-};
-
static int
fdesc_readdir(ap)
struct vop_readdir_args /* {
@@ -579,7 +443,9 @@ fdesc_readdir(ap)
{
struct uio *uio = ap->a_uio;
struct filedesc *fdp;
- int error, i, off;
+ struct dirent d;
+ struct dirent *dp = &d;
+ int error, i, off, fcnt;
/*
* We don't allow exporting fdesc mounts, and currently local
@@ -588,8 +454,7 @@ fdesc_readdir(ap)
if (ap->a_ncookies)
panic("fdesc_readdir: not hungry");
- if (VTOFDESC(ap->a_vp)->fd_type != Froot &&
- VTOFDESC(ap->a_vp)->fd_type != Fdevfd)
+ if (VTOFDESC(ap->a_vp)->fd_type != Froot)
panic("fdesc_readdir: not dir");
off = (int)uio->uio_offset;
@@ -598,173 +463,50 @@ fdesc_readdir(ap)
return (EINVAL);
i = (u_int)off / UIO_MX;
fdp = uio->uio_procp->p_fd;
+ error = 0;
- if (VTOFDESC(ap->a_vp)->fd_type == Froot) {
- struct dirent d;
- struct dirent *dp = &d;
- struct dirtmp *dt;
-
- error = 0;
-
- while (i < sizeof(rootent) / sizeof(rootent[0]) &&
- uio->uio_resid >= UIO_MX) {
- dt = &rootent[i];
- switch (dt->d_fileno) {
- case FD_CTTY:
- if (cttyvp(uio->uio_procp) == NULL)
- continue;
- break;
-
- case FD_STDIN:
- case FD_STDOUT:
- case FD_STDERR:
- if ((dt->d_fileno-FD_STDIN) >= fdp->fd_nfiles)
- continue;
- if (fdp->fd_ofiles[dt->d_fileno-FD_STDIN] == NULL)
- continue;
- break;
- }
- bzero((caddr_t) dp, UIO_MX);
- dp->d_fileno = dt->d_fileno;
- dp->d_namlen = dt->d_namlen;
- dp->d_type = DT_UNKNOWN;
- dp->d_reclen = dt->d_reclen;
- bcopy(dt->d_name, dp->d_name, dp->d_namlen+1);
- error = uiomove((caddr_t) dp, UIO_MX, uio);
- if (error)
- break;
- i++;
- }
- uio->uio_offset = i * UIO_MX;
- return (error);
- }
+ fcnt = i - 2; /* The first two nodes are `.' and `..' */
- error = 0;
- while (i < fdp->fd_nfiles && uio->uio_resid >= UIO_MX) {
- if (fdp->fd_ofiles[i] != NULL) {
- struct dirent d;
- struct dirent *dp = &d;
+ while (i < fdp->fd_nfiles + 2 && uio->uio_resid >= UIO_MX) {
+ switch (i) {
+ case 0: /* `.' */
+ case 1: /* `..' */
+ bzero((caddr_t)dp, UIO_MX);
- bzero((caddr_t) dp, UIO_MX);
+ dp->d_fileno = i + FD_ROOT;
+ dp->d_namlen = i + 1;
+ dp->d_reclen = UIO_MX;
+ bcopy("..", dp->d_name, dp->d_namlen);
+ dp->d_name[i + 1] = '\0';
+ dp->d_type = DT_DIR;
+ break;
+ default:
+ if (fdp->fd_ofiles[fcnt] == NULL)
+ goto done;
- dp->d_namlen = sprintf(dp->d_name, "%d", i);
+ bzero((caddr_t) dp, UIO_MX);
+ dp->d_namlen = sprintf(dp->d_name, "%d", fcnt);
dp->d_reclen = UIO_MX;
dp->d_type = DT_UNKNOWN;
- dp->d_fileno = i + FD_STDIN;
- /*
- * And ship to userland
- */
- error = uiomove((caddr_t) dp, UIO_MX, uio);
- if (error)
- break;
+ dp->d_fileno = i + FD_DESC;
+ break;
}
+ /*
+ * And ship to userland
+ */
+ error = uiomove((caddr_t) dp, UIO_MX, uio);
+ if (error)
+ break;
i++;
+ fcnt++;
}
+done:
uio->uio_offset = i * UIO_MX;
return (error);
}
static int
-fdesc_readlink(ap)
- struct vop_readlink_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- int error;
-
- if (vp->v_type != VLNK)
- return (EPERM);
-
- if (VTOFDESC(vp)->fd_type == Flink) {
- char *ln = VTOFDESC(vp)->fd_link;
- error = uiomove(ln, strlen(ln), ap->a_uio);
- } else {
- error = EOPNOTSUPP;
- }
-
- return (error);
-}
-
-static int
-fdesc_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int error = EOPNOTSUPP;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- error = (*ctty_cdevsw.d_read)(devctty, ap->a_uio, ap->a_ioflag);
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int error = EOPNOTSUPP;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- error = (*ctty_cdevsw.d_write)(devctty, ap->a_uio, ap->a_ioflag);
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- int error = EOPNOTSUPP;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- error = (*ctty_cdevsw.d_ioctl)(devctty, ap->a_command,
- ap->a_data, ap->a_fflag, ap->a_p);
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
-
- return (error);
-}
-
-static int
fdesc_poll(ap)
struct vop_poll_args /* {
struct vnode *a_vp;
@@ -773,19 +515,7 @@ fdesc_poll(ap)
struct proc *a_p;
} */ *ap;
{
- int revents;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- revents = (*ctty_cdevsw.d_poll)(devctty, ap->a_events, ap->a_p);
- break;
-
- default:
- revents = seltrue(0, ap->a_events, ap->a_p);
- break;
- }
-
- return (revents);
+ return seltrue(0, ap->a_events, ap->a_p);
}
static int
@@ -854,18 +584,14 @@ static struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = {
{ &vop_bmap_desc, (vop_t *) fdesc_badop },
{ &vop_getattr_desc, (vop_t *) fdesc_getattr },
{ &vop_inactive_desc, (vop_t *) fdesc_inactive },
- { &vop_ioctl_desc, (vop_t *) fdesc_ioctl },
{ &vop_lookup_desc, (vop_t *) fdesc_lookup },
{ &vop_open_desc, (vop_t *) fdesc_open },
{ &vop_pathconf_desc, (vop_t *) vop_stdpathconf },
{ &vop_poll_desc, (vop_t *) fdesc_poll },
{ &vop_print_desc, (vop_t *) fdesc_print },
- { &vop_read_desc, (vop_t *) fdesc_read },
{ &vop_readdir_desc, (vop_t *) fdesc_readdir },
- { &vop_readlink_desc, (vop_t *) fdesc_readlink },
{ &vop_reclaim_desc, (vop_t *) fdesc_reclaim },
{ &vop_setattr_desc, (vop_t *) fdesc_setattr },
- { &vop_write_desc, (vop_t *) fdesc_write },
{ NULL, NULL }
};
static struct vnodeopv_desc fdesc_vnodeop_opv_desc =
OpenPOWER on IntegriCloud