From c7ba6f536adf4c67536ab613240ae450eaa2a104 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 15 Oct 2003 20:00:59 +0000 Subject: [PATCH] Introduce a new optional memberfunction for cdevsw, fdopen() which passes the fdidx from VOP_OPEN down. This is for all I know the final API for this functionality, but the locking semantics for messing with the filedescriptor from the device driver are not settled at this time. --- sys/fs/specfs/spec_vnops.c | 9 +++++++-- sys/sys/conf.h | 2 ++ sys/sys/linedisc.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index ff09a7a0d6c6..8b5d2a54d3a0 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -196,9 +196,14 @@ spec_open(ap) VOP_UNLOCK(vp, 0, td); if(dsw->d_flags & D_NOGIANT) { DROP_GIANT(); - error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); + if (dsw->d_fdopen != NULL) + error = dsw->d_fdopen(dev, ap->a_mode, td, ap->a_fdidx); + else + error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); PICKUP_GIANT(); - } else + } else if (dsw->d_fdopen != NULL) + error = dsw->d_fdopen(dev, ap->a_mode, td, ap->a_fdidx); + else error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 683cd1771f9d..e4f0eab8561f 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -145,6 +145,7 @@ struct knote; typedef struct thread d_thread_t; typedef int d_open_t(dev_t dev, int oflags, int devtype, struct thread *td); +typedef int d_fdopen_t(dev_t dev, int oflags, struct thread *td, int fdidx); typedef int d_close_t(dev_t dev, int fflag, int devtype, struct thread *td); typedef void d_strategy_t(struct bio *bp); typedef int d_ioctl_t(dev_t dev, u_long cmd, caddr_t data, @@ -223,6 +224,7 @@ struct cdevsw { u_int d_flags; const char *d_name; d_open_t *d_open; + d_fdopen_t *d_fdopen; d_close_t *d_close; d_read_t *d_read; d_write_t *d_write; diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 683cd1771f9d..e4f0eab8561f 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -145,6 +145,7 @@ struct knote; typedef struct thread d_thread_t; typedef int d_open_t(dev_t dev, int oflags, int devtype, struct thread *td); +typedef int d_fdopen_t(dev_t dev, int oflags, struct thread *td, int fdidx); typedef int d_close_t(dev_t dev, int fflag, int devtype, struct thread *td); typedef void d_strategy_t(struct bio *bp); typedef int d_ioctl_t(dev_t dev, u_long cmd, caddr_t data, @@ -223,6 +224,7 @@ struct cdevsw { u_int d_flags; const char *d_name; d_open_t *d_open; + d_fdopen_t *d_fdopen; d_close_t *d_close; d_read_t *d_read; d_write_t *d_write;