diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/vnd.c | 48 | ||||
-rw-r--r-- | sys/dev/vndioctl.h | 20 |
2 files changed, 59 insertions, 9 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 91b0023db0d..8dff98e9e9b 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.47 2004/06/19 14:29:20 pedro Exp $ */ +/* $OpenBSD: vnd.c,v 1.48 2004/06/20 18:03:03 pedro Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -120,13 +120,14 @@ struct vnd_softc { struct device sc_dev; struct disk sc_dk; - int sc_flags; /* flags */ - size_t sc_size; /* size of vnd in blocks */ - struct vnode *sc_vp; /* vnode */ - struct ucred *sc_cred; /* credentials */ - int sc_maxactive; /* max # of active requests */ - struct buf sc_tab; /* transfer queue */ - void *sc_keyctx; /* key context */ + char sc_file[VNDNLEN]; /* file we're covering */ + int sc_flags; /* flags */ + size_t sc_size; /* size of vnd in blocks */ + struct vnode *sc_vp; /* vnode */ + struct ucred *sc_cred; /* credentials */ + int sc_maxactive; /* max # of active requests */ + struct buf sc_tab; /* transfer queue */ + void *sc_keyctx; /* key context */ }; /* sc_flags */ @@ -751,6 +752,7 @@ vndioctl(dev, cmd, addr, flag, p) int unit = vndunit(dev); struct vnd_softc *vnd; struct vnd_ioctl *vio; + struct vnd_user *vnu; struct vattr vattr; struct nameidata nd; int error, part, pmask, s; @@ -838,6 +840,7 @@ vndioctl(dev, cmd, addr, flag, p) vndthrottle(vnd, vnd->sc_vp); vio->vnd_size = dbtob((off_t)vnd->sc_size); vnd->sc_flags |= VNF_INITED; + strlcpy(vnd->sc_file, vio->vnd_file, sizeof(vnd->sc_file)); #ifdef DEBUG if (vnddebug & VDB_INIT) printf("vndioctl: SET vp %p size %llx\n", @@ -896,6 +899,35 @@ vndioctl(dev, cmd, addr, flag, p) splx(s); break; + case VNDIOCGET: + vnu = (struct vnd_user *)addr; + + if (vnu->vnu_unit == -1) + vnu->vnu_unit = unit; + if (vnu->vnu_unit >= numvnd) + return (ENXIO); + if (vnu->vnu_unit < 0) + return (EINVAL); + + vnd = &vnd_softc[vnu->vnu_unit]; + + if (vnd->sc_flags & VNF_INITED) { + error = VOP_GETATTR(vnd->sc_vp, &vattr, p->p_ucred, p); + if (error) + return (error); + + strlcpy(vnu->vnu_file, vnd->sc_file, + sizeof(vnu->vnu_file)); + + vnu->vnu_dev = vattr.va_fsid; + vnu->vnu_ino = vattr.va_fileid; + } else { + vnu->vnu_dev = 0; + vnu->vnu_ino = 0; + } + + break; + case DIOCGDINFO: if ((vnd->sc_flags & VNF_HAVELABEL) == 0) return (ENOTTY); diff --git a/sys/dev/vndioctl.h b/sys/dev/vndioctl.h index 1dffd6900f3..2227952677f 100644 --- a/sys/dev/vndioctl.h +++ b/sys/dev/vndioctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vndioctl.h,v 1.5 2003/06/02 23:28:01 millert Exp $ */ +/* $OpenBSD: vndioctl.h,v 1.6 2004/06/20 18:03:03 pedro Exp $ */ /* $NetBSD: vndioctl.h,v 1.5 1995/01/25 04:46:30 cgd Exp $ */ /* @@ -39,6 +39,11 @@ * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93 */ +#ifndef _SYS_VNDIOCTL_H_ +#define _SYS_VNDIOCTL_H_ + +#define VNDNLEN 90 + /* * Ioctl definitions for file (vnode) disk pseudo-device. */ @@ -50,6 +55,16 @@ struct vnd_ioctl { }; /* + * A simple structure used by userland to query about a specific vnd. + */ +struct vnd_user { + char vnu_file[VNDNLEN]; /* vnd file */ + int vnu_unit; /* vnd unit */ + dev_t vnu_dev; /* vnd device */ + ino_t vnu_ino; /* vnd inode */ +}; + +/* * Before you can use a unit, it must be configured with VNDIOCSET. * The configuration persists across opens and closes of the device; * an VNDIOCCLR must be used to reset a configuration. An attempt to @@ -57,3 +72,6 @@ struct vnd_ioctl { */ #define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */ #define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */ +#define VNDIOCGET _IOWR('F', 2, struct vnd_user) /* get disk info */ + +#endif /* !_SYS_VNDIOCTL_H_ */ |