Create a per-device state for iscsi(4), effectively making it a cloning
device.
This commit is contained in:
parent
adac2d746a
commit
e754774175
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iscsi_globals.h,v 1.12 2015/05/30 18:12:09 joerg Exp $ */
|
||||
/* $NetBSD: iscsi_globals.h,v 1.13 2015/05/30 20:09:47 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
|
||||
|
@ -500,6 +500,10 @@ typedef struct event_handler_s {
|
|||
TAILQ_HEAD(event_handler_list_s, event_handler_s);
|
||||
typedef struct event_handler_list_s event_handler_list_t;
|
||||
|
||||
/* /dev/iscsi0 state */
|
||||
struct iscsifd {
|
||||
char dummy;
|
||||
};
|
||||
|
||||
/* ------------------------- Global Variables ----------------------------- */
|
||||
|
||||
|
@ -648,7 +652,7 @@ void iscsi_cleanup_thread(void *);
|
|||
uint32_t map_databuf(struct proc *, void **, uint32_t);
|
||||
void unmap_databuf(struct proc *, void *, uint32_t);
|
||||
#endif
|
||||
int iscsiioctl(dev_t, u_long, void *, int, struct lwp *);
|
||||
int iscsiioctl(struct file *, u_long, void *);
|
||||
|
||||
session_t *find_session(uint32_t);
|
||||
connection_t *find_connection(session_t *, uint32_t);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iscsi_ioctl.c,v 1.11 2015/05/30 18:09:31 joerg Exp $ */
|
||||
/* $NetBSD: iscsi_ioctl.c,v 1.12 2015/05/30 20:09:47 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
|
||||
|
@ -1593,8 +1593,9 @@ iscsi_cleanup_thread(void *par)
|
|||
*/
|
||||
|
||||
int
|
||||
iscsiioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
|
||||
iscsiioctl(struct file *fp, u_long cmd, void *addr)
|
||||
{
|
||||
struct lwp *l = curlwp;
|
||||
|
||||
DEB(1, ("ISCSI Ioctl cmd = %x\n", (int) cmd));
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/socketvar.h>
|
||||
|
||||
|
@ -83,14 +85,19 @@ CFATTACH_DECL_NEW(iscsi, sizeof(struct iscsi_softc), iscsi_match, iscsi_attach,
|
|||
|
||||
|
||||
static dev_type_open(iscsiopen);
|
||||
static dev_type_close(iscsiclose);
|
||||
static int iscsiclose(struct file *);
|
||||
|
||||
static const struct fileops iscsi_fileops = {
|
||||
.fo_ioctl = iscsiioctl,
|
||||
.fo_close = iscsiclose,
|
||||
};
|
||||
|
||||
struct cdevsw iscsi_cdevsw = {
|
||||
.d_open = iscsiopen,
|
||||
.d_close = iscsiclose,
|
||||
.d_close = noclose,
|
||||
.d_read = noread,
|
||||
.d_write = nowrite,
|
||||
.d_ioctl = iscsiioctl,
|
||||
.d_ioctl = noioctl,
|
||||
.d_stop = nostop,
|
||||
.d_tty = notty,
|
||||
.d_poll = nopoll,
|
||||
|
@ -119,14 +126,27 @@ STATIC void iscsi_minphys(struct buf *);
|
|||
int
|
||||
iscsiopen(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
{
|
||||
struct iscsifd *d;
|
||||
struct file *fp;
|
||||
int error, fd;
|
||||
|
||||
DEB(99, ("ISCSI Open\n"));
|
||||
return 0;
|
||||
|
||||
if ((error = fd_allocfile(&fp, &fd)) != 0)
|
||||
return error;
|
||||
|
||||
d = kmem_alloc(sizeof(*d), KM_SLEEP);
|
||||
|
||||
return fd_clone(fp, fd, flag, &iscsi_fileops, d);
|
||||
}
|
||||
|
||||
int
|
||||
iscsiclose(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
static int
|
||||
iscsiclose(struct file *fp)
|
||||
{
|
||||
struct iscsifd *d = fp->f_iscsi;
|
||||
|
||||
kmem_free(d, sizeof(*d));
|
||||
fp->f_iscsi = NULL;
|
||||
|
||||
DEB(99, ("ISCSI Close\n"));
|
||||
return 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: file.h,v 1.78 2014/12/14 23:48:58 chs Exp $ */
|
||||
/* $NetBSD: file.h,v 1.79 2015/05/30 20:09:47 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
|
@ -108,6 +108,7 @@ union file_data {
|
|||
struct fcrypt *fd_fcrypt; // DTYPE_CRYPTO is not used
|
||||
struct mqueue *fd_mq; // DTYPE_MQUEUE
|
||||
struct ksem *fd_ks; // DTYPE_SEM
|
||||
struct iscsifd *fd_iscsi; // DTYPE_MISC (iscsi)
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -146,6 +147,7 @@ struct file {
|
|||
#define f_devunit f_undata.fd_devunit
|
||||
#define f_bpf f_undata.fd_bpf
|
||||
#define f_fcrypt f_undata.fd_fcrypt
|
||||
#define f_iscsi f_undata.fd_iscsi
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue