summaryrefslogtreecommitdiff
path: root/sys/dev/vnd.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-12-22 13:12:15 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-12-22 13:12:15 +0000
commitcd53e7a1bb47618082f2265a48bfa5e6b669fd69 (patch)
treee401a8a85759c0a17571a3c34d7b4bfca7a3a1f1 /sys/dev/vnd.c
parentbe96e1ce749f915c80d135b4dcd207bd7b818530 (diff)
When configuring a vnd(4) disk, populate the disk name based on the mode
in which it was configured. If this is a "safe" vnd disk the name should be "svndX" whereas a standard vnd disk should be named "vndX". ok deraadt@ todd@ thib@
Diffstat (limited to 'sys/dev/vnd.c')
-rw-r--r--sys/dev/vnd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 498fa9378c3..a4f5db83ebe 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.103 2010/09/22 01:18:57 matthew Exp $ */
+/* $OpenBSD: vnd.c,v 1.104 2010/12/22 13:12:14 jsing Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -125,6 +125,7 @@ struct pool vndbufpl;
struct vnd_softc {
struct device sc_dev;
struct disk sc_dk;
+ char sc_dk_name[16];
char sc_file[VNDNLEN]; /* file we're covering */
int sc_flags; /* flags */
@@ -780,6 +781,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
return (error);
}
+ /* Set device name. */
bzero(vnd->sc_dev.dv_xname, sizeof(vnd->sc_dev.dv_xname));
if (snprintf(vnd->sc_dev.dv_xname, sizeof(vnd->sc_dev.dv_xname),
"vnd%d", unit) >= sizeof(vnd->sc_dev.dv_xname)) {
@@ -788,6 +790,16 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
return(ENXIO);
}
+ /* Set disk name depending on how we were created. */
+ bzero(vnd->sc_dk_name, sizeof(vnd->sc_dk_name));
+ if (snprintf(vnd->sc_dk_name, sizeof(vnd->sc_dk_name),
+ "%svnd%d", ((vnd->sc_flags & VNF_SIMPLE) ? "s" : ""),
+ unit) >= sizeof(vnd->sc_dk_name)) {
+ printf("VNDIOCSET: disk name too long\n");
+ vndunlock(vnd);
+ return(ENXIO);
+ }
+
/* Set geometry for device. */
vnd->sc_secsize = vio->vnd_secsize;
vnd->sc_ntracks = vio->vnd_ntracks;
@@ -865,7 +877,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
vnd->sc_vp, (unsigned long long)vnd->sc_size);
/* Attach the disk. */
- vnd->sc_dk.dk_name = vnd->sc_dev.dv_xname;
+ vnd->sc_dk.dk_name = vnd->sc_dk_name;
disk_attach(&vnd->sc_dev, &vnd->sc_dk);
vndunlock(vnd);