From a72d8a9fc942adb9fcd8a253b05cebb83ee4bda1 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 25 May 2007 02:21:19 +0000 Subject: [PATCH] Add a -c file option to the vkernel to specify CD images. The first -c or -r option will be the boot device. Add a new virtual CDRom device, vcd. Basically its works the same as VKD but we open the device in read-only mode and use a block size of 2048 instead of 512. Install the console as a real device and change the console major to be the same as the syscons major so a default init is able to start up a getty. --- etc/MAKEDEV | 149 +++++++----------- share/man/man7/vkernel.7 | 26 ++- sys/config/VKERNEL | 3 +- sys/dev/virtual/Makefile | 4 +- sys/dev/virtual/cdrom/Makefile | 8 + sys/dev/virtual/{disk/vdisk.c => cdrom/vcd.c} | 52 +++--- sys/dev/virtual/disk/vdisk.c | 7 +- sys/platform/vkernel/conf/files | 3 +- sys/platform/vkernel/include/md_var.h | 3 +- sys/platform/vkernel/platform/console.c | 49 +++--- sys/platform/vkernel/platform/init.c | 33 ++-- 11 files changed, 174 insertions(+), 163 deletions(-) create mode 100644 sys/dev/virtual/cdrom/Makefile copy sys/dev/virtual/{disk/vdisk.c => cdrom/vcd.c} (81%) diff --git a/etc/MAKEDEV b/etc/MAKEDEV index 37d778c2be..3412273130 100644 --- a/etc/MAKEDEV +++ b/etc/MAKEDEV @@ -21,7 +21,7 @@ # # @(#)MAKEDEV 5.2 (Berkeley) 6/22/90 # $FreeBSD: src/etc/MAKEDEV,v 1.243.2.57 2003/02/10 11:35:53 simokawa Exp $ -# $DragonFly: src/etc/MAKEDEV,v 1.31 2007/05/19 21:37:01 dillon Exp $ +# $DragonFly: src/etc/MAKEDEV,v 1.32 2007/05/25 02:21:09 dillon Exp $ # # Device "make" file. Valid arguments: # all makes all known devices, standard number of units (or close) @@ -657,7 +657,7 @@ wt*) #----------------------------------------------------------------------------- -aacd*s*|acd*s*|ad*s*|ar*s*|afd*s*|amrd*s*|ccd*s*|da*s*|fla*s*|idad*s*|ipsd*s*|md*s*|mlxd*s*|pst*s*|twed*s*|vn*s*|vkd*s*) +aacd*s*|acd*s*|ad*s*|ar*s*|afd*s*|amrd*s*|ccd*s*|da*s*|fd*s*|fla*s*|idad*s*|ipsd*s*|md*s*|mlxd*s*|pst*s*|twed*s*|vn*s*|vkd*s*) case $i in aacd*s*) name=aacd; chr=151;; acd*s*) name=acd; chr=117;; @@ -667,6 +667,7 @@ aacd*s*|acd*s*|ad*s*|ar*s*|afd*s*|amrd*s*|ccd*s*|da*s*|fla*s*|idad*s*|ipsd*s*|md amrd*s*) name=amrd; chr=133;; ccd*s*) name=ccd; chr=74;; da*s*) name=da; chr=13;; + fd*s*) name=fd; chr=9;; fla*s*) name=fla; chr=102;; idad*s*) name=idad; chr=109;; ipsd*s*) name=ipsd; chr=176;; @@ -759,103 +760,51 @@ aacd*s*|acd*s*|ad*s*|ar*s*|afd*s*|amrd*s*|ccd*s*|da*s*|fla*s*|idad*s*|ipsd*s*|md #----------------------------------------------------------------------------- -fd*) - unit=`expr $i : '..\(.*\)'` +control-fd*) + unit=`expr $i : '..........\(.*\)'` name=fd; chr=9 case $unit in 0|1|2|3) - mknod $name $unit c $chr $(($unit * 64)) root:operator 640 - rm -f r$name$unit - # Fake BSD partitions - for i in a b c d e f g h - do - ln -f $name$unit $name$unit$i - rm -f r$name$unit r$name$unit$i - done - # User-readable and programmer-readable name sets - - mknod $name ${unit}.1720 c $chr $(($unit * 64 + 1)) \ - root:operator 640 + minor=`ndkminor $unit 1 129` + mknod $name ${unit}.1720 c $chr $minor rm -f r${name}${unit}.1720 - # ln -f $name${unit}.1720 ${name}${unit}135hs21 - # rm -f r$name${unit}135hs21 - - mknod $name ${unit}.1480 c $chr $(($unit * 64 + 2)) \ - root:operator 640 - rm -f r$name${unit}.1480 - # ln -f $name${unit}.1480 ${name}${unit}135hs18 - # rm -f r$name${unit}135hs18 - # ln -f $name${unit}.1480 ${name}${unit}96hs18 - # rm -f r$name${unit}96hs18 - - mknod $name ${unit}.1440 c $chr $(($unit * 64 + 3)) \ - root:operator 640 - rm -f r$name${unit}.1440 - # ln -f $name${unit}.1440 $name${unit}135 - # rm -f r$name${unit}135 - # ln -f $name${unit}.1440 $name${unit}135ds18 - # rm -f r$name${unit}135ds18 - # ln -f $name${unit}.1440 $name${unit}96ds18 - # rm -f r$name${unit}96ds18 - - mknod $name ${unit}.1200 c $chr $(($unit * 64 + 4)) \ - root:operator 640 - rm -f r$name${unit}.1200 - # ln -f $name${unit}.1200 $name${unit}96 - # rm -f r$name${unit}96 - # ln -f $name${unit}.1200 $name${unit}96ds15 - # rm -f r$name${unit}96ds15 - # ln -f $name${unit}.1200 $name${unit}135ds15 - # rm -f r$name${unit}135ds15 - - mknod $name ${unit}.820 c $chr $(($unit * 64 + 5)) \ - root:operator 640 - rm -f r$name${unit}.820 - # ln -f $name${unit}.820 $name${unit}96hs10 - # rm -f r$name${unit}96hs10 - # ln -f $name${unit}.820 $name${unit}135hs10 - # rm -f r$name${unit}135hs10 - - mknod $name ${unit}.800 c $chr $(($unit * 64 + 6)) \ - root:operator 640 - rm -f r$name${unit}.800 - # ln -f $name${unit}.800 $name${unit}96ds10 - # rm -f r$name${unit}96ds10 - # ln -f $name${unit}.800 $name${unit}135ds10 - # rm -f r$name${unit}135ds10 - - mknod $name ${unit}.720 c $chr $(($unit * 64 + 7)) \ - root:operator 640 - rm -f r$name${unit}.720 - # ln -f $name${unit}.720 $name${unit}96ds9 - # rm -f r$name${unit}96ds9 - # ln -f $name${unit}.720 $name${unit}135ds9 - # rm -f r$name${unit}135ds9 - - mknod $name ${unit}.360 c $chr $(($unit * 64 + 8)) \ - root:operator 640 - rm -f r$name${unit}.360 - # ln -f $name${unit}.360 $name${unit}48 - # rm -f r$name${unit}48 - # ln -f $name${unit}.360 $name${unit}48ds9 - # rm -f r$name${unit}48ds9 - - mknod $name ${unit}.640 c $chr $(($unit * 64 + 9)) \ - root:operator 640 - rm -f r$name${unit}.640 - # ln -f $name${unit}.640 $name${unit}96ds8 - # rm -f r$name${unit}96ds8 - # ln -f $name${unit}.640 $name${unit}135ds8 - # rm -f r$name${unit}135ds8 - - mknod $name ${unit}.1232 c $chr $(($unit * 64 + 10)) \ - root:operator 640 - rm -f r$name${unit}.1232 - # ln -f $name${unit}.1232 $name${unit}96ds8 - # rm -f r$name${unit}96ds8 - # ln -f $name${unit}.1232 $name${unit}135ds8 - # rm -f r$name${unit}135ds8 + + minor=`ndkminor $unit 1 130` + mknod $name ${unit}.1480 c $chr $minor + rm -f r${name}${unit}.1480 + + minor=`ndkminor $unit 1 131` + mknod $name ${unit}.1440 c $chr $minor + rm -f r${name}${unit}.1440 + + minor=`ndkminor $unit 1 132` + mknod $name ${unit}.1200 c $chr $minor + rm -f r${name}${unit}.1200 + + minor=`ndkminor $unit 1 133` + mknod $name ${unit}.820 c $chr $minor + rm -f r${name}${unit}.820 + + minor=`ndkminor $unit 1 134` + mknod $name ${unit}.800 c $chr $minor + rm -f r${name}${unit}.800 + + minor=`ndkminor $unit 1 135` + mknod $name ${unit}.720 c $chr $minor + rm -f r${name}${unit}.720 + + minor=`ndkminor $unit 1 136` + mknod $name ${unit}.360 c $chr $minor + rm -f r${name}${unit}.360 + + minor=`ndkminor $unit 1 137` + mknod $name ${unit}.640 c $chr $minor + rm -f r${name}${unit}.640 + + minor=`ndkminor $unit 1 138` + mknod $name ${unit}.1232 c $chr $minor + rm -f r${name}${unit}.1232 ;; *) echo bad unit for disk in: $i @@ -903,7 +852,7 @@ acd*t*) #----------------------------------------------------------------------------- -aacd*|acd*|ad*|ar*|afd*|amrd*|ccd*|da*|fla*|idad*|ipsd*|md*|mlxd*|pst*|twed*|vn*|vkd*) +aacd*|acd*|ad*|ar*|afd*|amrd*|ccd*|da*|fd*|fla*|idad*|ipsd*|md*|mlxd*|pst*|twed*|vn*|vkd*) doslices=1 case $i in aacd*) name=aacd; chr=151;; @@ -913,6 +862,7 @@ aacd*|acd*|ad*|ar*|afd*|amrd*|ccd*|da*|fla*|idad*|ipsd*|md*|mlxd*|pst*|twed*|vn* afd*) name=afd; chr=118;; amrd*) name=amrd; chr=133;; da*) name=da; chr=13;; + fd*) name=fd; chr=9;; ccd*) name=ccd; chr=74;; fla*) name=fla; chr=102;; idad*) name=idad; chr=109;; @@ -937,6 +887,12 @@ aacd*|acd*|ad*|ar*|afd*|amrd*|ccd*|da*|fla*|idad*|ipsd*|md*|mlxd*|pst*|twed*|vn* ;; esac + case $i in + fd*) + sh MAKEDEV control-$name$unit + ;; + esac + case $unit in [0-9]|[0-9][0-9]|[0-4][0-9][0-9]|50[0-9]|51[0-1]) if [ "$doslices" -gt 0 ]; then @@ -1169,9 +1125,10 @@ ast*) #----------------------------------------------------------------------------- -cd*) +cd*|vcd*) case $i in cd*) units=`expr $i : '..\(.*\)'` ; name=cd; chr=15;; + vcd*) units=`expr $i : '...\(.*\)'` ; name=vcd; chr=98;; esac [ "$units" ] || units=0 diff --git a/share/man/man7/vkernel.7 b/share/man/man7/vkernel.7 index 109a5314b5..4c5dc5a94a 100644 --- a/share/man/man7/vkernel.7 +++ b/share/man/man7/vkernel.7 @@ -29,7 +29,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/share/man/man7/vkernel.7,v 1.15 2007/04/20 07:04:09 swildner Exp $ +.\" $DragonFly: src/share/man/man7/vkernel.7,v 1.16 2007/05/25 02:21:10 dillon Exp $ .\" .Dd April 19, 2007 .Dt VKERNEL 7 @@ -46,6 +46,7 @@ .Pp .Pa /usr/obj/usr/src/sys/VKERNEL/kernel.debug .Op Fl sUv +.Op Fl c Ar file .Op Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ... .Op Fl i Ar file .Op Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc @@ -60,6 +61,21 @@ kernels in userland. .Pp The following options are available: .Bl -tag -width ".Fl m Ar size" +.It Fl c Ar file +Specify a readonly CDRom image +.Ar file +to be used by the kernel, with the first +.Fl c +option defining +.Li vcd0 , +the second one +.Li vcd1 , +and so on. The first +.Fl r +or +.Fl c +option specified on the command line will be the boot disk. +the CD9660 filesystem is assumed when booting from this media. .It Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ... Specify an environment to be used by the kernel. .It Fl i Ar file @@ -134,7 +150,7 @@ and .Cm G are allowed. .It Fl r Ar file -Specify a disk image +Specify a R/W disk image .Ar file to be used by the kernel, with the first .Fl r @@ -142,7 +158,11 @@ option defining .Li vkd0 , the second one .Li vkd1 , -and so on. +and so on. The first +.Fl r +or +.Fl c +option specified on the command line will be the boot disk. .It Fl s Boot into single-user mode. .It Fl U diff --git a/sys/config/VKERNEL b/sys/config/VKERNEL index 6f2cfb6195..e90c030b3a 100644 --- a/sys/config/VKERNEL +++ b/sys/config/VKERNEL @@ -1,6 +1,6 @@ # VKERNEL - test rid for virtual kernel # -# $DragonFly: src/sys/config/VKERNEL,v 1.10 2007/01/30 15:53:30 swildner Exp $ +# $DragonFly: src/sys/config/VKERNEL,v 1.11 2007/05/25 02:21:11 dillon Exp $ platform vkernel # platform architecture (i386, vkernel, etc) machine i386 @@ -96,3 +96,4 @@ pseudo-device bpf #Berkeley packet filter device vn device vkd device vke +device vcd diff --git a/sys/dev/virtual/Makefile b/sys/dev/virtual/Makefile index 081cd1d5dd..69682726d3 100644 --- a/sys/dev/virtual/Makefile +++ b/sys/dev/virtual/Makefile @@ -1,6 +1,6 @@ -# $DragonFly: src/sys/dev/virtual/Makefile,v 1.2 2007/01/10 13:33:22 swildner Exp $ +# $DragonFly: src/sys/dev/virtual/Makefile,v 1.3 2007/05/25 02:21:12 dillon Exp $ # -SUBDIR= disk net +SUBDIR= disk net cdrom .include diff --git a/sys/dev/virtual/cdrom/Makefile b/sys/dev/virtual/cdrom/Makefile new file mode 100644 index 0000000000..016649a76a --- /dev/null +++ b/sys/dev/virtual/cdrom/Makefile @@ -0,0 +1,8 @@ +# $DragonFly: src/sys/dev/virtual/cdrom/Makefile,v 1.1 2007/05/25 02:21:13 dillon Exp $ + +.PATH: ${.CURDIR}/../../dev/vcd +KMOD= vcd +SRCS= vcd.c +NOMAN= + +.include diff --git a/sys/dev/virtual/disk/vdisk.c b/sys/dev/virtual/cdrom/vcd.c similarity index 81% copy from sys/dev/virtual/disk/vdisk.c copy to sys/dev/virtual/cdrom/vcd.c index 7ff6d747fe..3ca23436a4 100644 --- a/sys/dev/virtual/disk/vdisk.c +++ b/sys/dev/virtual/cdrom/vcd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006 The DragonFly Project. All rights reserved. + * Copyright (c) 2007 The DragonFly Project. All rights reserved. * * This code is derived from software contributed to The DragonFly Project * by Matthew Dillon @@ -31,11 +31,11 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/dev/virtual/disk/vdisk.c,v 1.5 2007/05/17 21:08:49 dillon Exp $ + * $DragonFly: src/sys/dev/virtual/cdrom/vcd.c,v 1.1 2007/05/25 02:21:13 dillon Exp $ */ /* - * Virtual disk driver + * Virtual CDROM driver */ #include #include @@ -53,7 +53,7 @@ #include #include -struct vkd_softc { +struct vcd_softc { struct bio_queue_head bio_queue; struct devstat stats; struct disk disk; @@ -62,35 +62,32 @@ struct vkd_softc { int fd; }; -#define CDEV_MAJOR 97 +#define CDEV_MAJOR 98 -static d_strategy_t vkdstrategy; -static d_open_t vkdopen; +static d_strategy_t vcdstrategy; +static d_open_t vcdopen; -static struct dev_ops vkd_ops = { - { "vkd", CDEV_MAJOR, D_DISK }, - .d_open = vkdopen, +static struct dev_ops vcd_ops = { + { "vcd", CDEV_MAJOR, D_DISK }, + .d_open = vcdopen, .d_close = nullclose, .d_read = physread, .d_write = physwrite, - .d_strategy = vkdstrategy, + .d_strategy = vcdstrategy, }; static void -vkdinit(void *dummy __unused) +vcdinit(void *dummy __unused) { struct vkdisk_info *dsk; - struct vkd_softc *sc; + struct vcd_softc *sc; struct stat st; int i; - KASSERT(DiskNum <= VKDISK_MAX, ("too many disks: %d\n", DiskNum)); - for (i = 0; i < DiskNum; i++) { - /* check that the 'bus device' has been initialized */ dsk = &DiskInfo[i]; - if (dsk == NULL) + if (dsk == NULL || dsk->type != VKD_CD) continue; if (dsk->fd < 0 || fstat(dsk->fd, &st) < 0) continue; @@ -100,22 +97,22 @@ vkdinit(void *dummy __unused) sc->unit = dsk->unit; sc->fd = dsk->fd; bioq_init(&sc->bio_queue); - devstat_add_entry(&sc->stats, "vkd", sc->unit, DEV_BSIZE, + devstat_add_entry(&sc->stats, "vcd", sc->unit, 2048, DEVSTAT_NO_ORDERED_TAGS, DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER, DEVSTAT_PRIORITY_DISK); - sc->dev = disk_create(sc->unit, &sc->disk, &vkd_ops); + sc->dev = disk_create(sc->unit, &sc->disk, &vcd_ops); sc->dev->si_drv1 = sc; sc->dev->si_iosize_max = 256 * 1024; } } -SYSINIT(vkdisk, SI_SUB_DRIVERS, SI_ORDER_FIRST, vkdinit, NULL); +SYSINIT(vcdisk, SI_SUB_DRIVERS, SI_ORDER_FIRST, vcdinit, NULL); static int -vkdopen(struct dev_open_args *ap) +vcdopen(struct dev_open_args *ap) { - struct vkd_softc *sc; + struct vcd_softc *sc; struct disk_info info; struct stat st; cdev_t dev; @@ -126,9 +123,10 @@ vkdopen(struct dev_open_args *ap) return(ENXIO); bzero(&info, sizeof(info)); - info.d_media_blksize = DEV_BSIZE; + info.d_media_blksize = 2048; info.d_media_blocks = st.st_size / info.d_media_blksize; - + info.d_dsflags = DSO_ONESLICE | DSO_COMPATLABEL | DSO_COMPATPARTA | + DSO_RAWEXTENSIONS; info.d_nheads = 1; info.d_ncylinders = 1; info.d_secpertrack = info.d_media_blocks; @@ -139,11 +137,11 @@ vkdopen(struct dev_open_args *ap) } static int -vkdstrategy(struct dev_strategy_args *ap) +vcdstrategy(struct dev_strategy_args *ap) { struct bio *bio = ap->a_bio; struct buf *bp; - struct vkd_softc *sc; + struct vcd_softc *sc; cdev_t dev; int n; @@ -168,7 +166,7 @@ vkdstrategy(struct dev_strategy_args *ap) n = write(sc->fd, bp->b_data, bp->b_bcount); break; default: - panic("vkd: bad b_cmd %d", bp->b_cmd); + panic("vcd: bad b_cmd %d", bp->b_cmd); break; /* not reached */ } if (n != bp->b_bcount) { diff --git a/sys/dev/virtual/disk/vdisk.c b/sys/dev/virtual/disk/vdisk.c index 7ff6d747fe..8ad10da98b 100644 --- a/sys/dev/virtual/disk/vdisk.c +++ b/sys/dev/virtual/disk/vdisk.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/dev/virtual/disk/vdisk.c,v 1.5 2007/05/17 21:08:49 dillon Exp $ + * $DragonFly: src/sys/dev/virtual/disk/vdisk.c,v 1.6 2007/05/25 02:21:14 dillon Exp $ */ /* @@ -84,13 +84,10 @@ vkdinit(void *dummy __unused) struct stat st; int i; - KASSERT(DiskNum <= VKDISK_MAX, ("too many disks: %d\n", DiskNum)); - for (i = 0; i < DiskNum; i++) { - /* check that the 'bus device' has been initialized */ dsk = &DiskInfo[i]; - if (dsk == NULL) + if (dsk == NULL || dsk->type != VKD_DISK) continue; if (dsk->fd < 0 || fstat(dsk->fd, &st) < 0) continue; diff --git a/sys/platform/vkernel/conf/files b/sys/platform/vkernel/conf/files index 885fcd560f..9340e5ebdc 100644 --- a/sys/platform/vkernel/conf/files +++ b/sys/platform/vkernel/conf/files @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $DragonFly: src/sys/platform/vkernel/conf/files,v 1.15 2007/01/19 07:23:42 dillon Exp $ +# $DragonFly: src/sys/platform/vkernel/conf/files,v 1.16 2007/05/25 02:21:15 dillon Exp $ # bf_enc.o optional ipsec ipsec_esp \ dependency "$S/crypto/blowfish/arch/i386/bf_enc.S $S/crypto/blowfish/arch/i386/bf_enc_586.S $S/crypto/blowfish/arch/i386/bf_enc_686.S" \ @@ -44,6 +44,7 @@ kern/subr_diskmbr.c standard # DEVICES # +dev/virtual/cdrom/vcd.c optional vcd dev/virtual/disk/vdisk.c optional vkd dev/virtual/net/if_vke.c optional vke diff --git a/sys/platform/vkernel/include/md_var.h b/sys/platform/vkernel/include/md_var.h index 164e1534f1..a59eaaac57 100644 --- a/sys/platform/vkernel/include/md_var.h +++ b/sys/platform/vkernel/include/md_var.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/include/md_var.h,v 1.18 2007/03/16 13:41:40 swildner Exp $ + * $DragonFly: src/sys/platform/vkernel/include/md_var.h,v 1.19 2007/05/25 02:21:18 dillon Exp $ */ #ifndef _MACHINE_MD_VAR_H_ @@ -57,6 +57,7 @@ struct vknetif_info { struct vkdisk_info { int fd; int unit; + enum vkdisk_type { VKD_EMPTY, VKD_DISK, VKD_CD } type; char fname[MAXPATHLEN]; }; diff --git a/sys/platform/vkernel/platform/console.c b/sys/platform/vkernel/platform/console.c index 48f7d1b527..23156c2c67 100644 --- a/sys/platform/vkernel/platform/console.c +++ b/sys/platform/vkernel/platform/console.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/platform/console.c,v 1.13 2007/05/07 05:21:42 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/platform/console.c,v 1.14 2007/05/25 02:21:19 dillon Exp $ */ #include @@ -69,7 +69,7 @@ cons_unlock(void) * */ -#define CDEV_MAJOR 183 +#define CDEV_MAJOR 12 /* steal the same major as /dev/ttyv* */ static int vcons_tty_param(struct tty *tp, struct termios *tio); static void vcons_tty_start(struct tty *tp); @@ -96,9 +96,6 @@ vcons_open(struct dev_open_args *ap) struct tty *tp; int error; - if (minor(dev) != 255) - return(ENXIO); - tp = dev->si_tty = ttymalloc(dev->si_tty); if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_oproc = vcons_tty_start; @@ -116,11 +113,16 @@ vcons_open(struct dev_open_args *ap) tp->t_ospeed = TTYDEF_SPEED; ttsetwater(tp); } - error = (*linesw[tp->t_line].l_open)(dev, tp); - ioctl(0, TIOCGWINSZ, &tp->t_winsize); + if (minor(dev) == 0) { + error = (*linesw[tp->t_line].l_open)(dev, tp); + ioctl(0, TIOCGWINSZ, &tp->t_winsize); - if (kqueue_console_info == NULL) - kqueue_console_info = kqueue_add(0, vcons_intr, tp); + if (kqueue_console_info == NULL) + kqueue_console_info = kqueue_add(0, vcons_intr, tp); + } else { + /* dummy up other minors so the installer will run */ + error = 0; + } return(error); } @@ -130,8 +132,6 @@ vcons_close(struct dev_close_args *ap) cdev_t dev = ap->a_head.a_dev; struct tty *tp; - if (minor(dev) != 255) - return(ENXIO); tp = dev->si_tty; (*linesw[tp->t_line].l_close)(tp, ap->a_fflag); ttyclose(tp); @@ -145,8 +145,6 @@ vcons_ioctl(struct dev_ioctl_args *ap) struct tty *tp; int error; - if (minor(dev) != 255) - return(ENXIO); tp = dev->si_tty; error = (*linesw[tp->t_line].l_ioctl)(tp, ap->a_cmd, ap->a_data, ap->a_fflag, ap->a_cred); @@ -178,8 +176,13 @@ vcons_tty_start(struct tty *tp) return; } tp->t_state |= TS_BUSY; - while ((n = q_to_b(&tp->t_outq, buf, sizeof(buf))) > 0) - write(1, buf, n); + while ((n = q_to_b(&tp->t_outq, buf, sizeof(buf))) > 0) { + /* + * Dummy up ttyv1, etc. + */ + if (minor(tp->t_dev) == 0) + write(1, buf, n); + } tp->t_state &= ~TS_BUSY; ttwwakeup(tp); } @@ -317,9 +320,19 @@ vconsinit(struct consdev *cp) static void vconsinit_fini(struct consdev *cp) { - cp->cn_dev = make_dev(&vcons_ops, 255, - UID_ROOT, GID_WHEEL, - 0600, "vconsolectl"); + cdev_t dev; + int i; + + /* + * Implement ttyv0-ttyv7. At the moment ttyv1-7 are sink nulls. + */ + dev_ops_add(&vcons_ops, -1 & ~7, 0); + for (i = 0; i < 8; ++i) { + dev = make_dev(&vcons_ops, i, + UID_ROOT, GID_WHEEL, 0600, "ttyv%d", i); + if (i == 0) + cp->cn_dev = dev; + } } static void diff --git a/sys/platform/vkernel/platform/init.c b/sys/platform/vkernel/platform/init.c index 21dba8b9c2..b5fe7c0a26 100644 --- a/sys/platform/vkernel/platform/init.c +++ b/sys/platform/vkernel/platform/init.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/platform/init.c,v 1.35 2007/04/27 23:27:18 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/platform/init.c,v 1.36 2007/05/25 02:21:19 dillon Exp $ */ #include @@ -105,7 +105,7 @@ static void init_sys_memory(char *imageFile); static void init_kern_memory(void); static void init_globaldata(void); static void init_vkernel(void); -static void init_disk(char *diskExp[], int diskFileNum); +static void init_disk(char *diskExp[], int diskFileNum, enum vkdisk_type type); static void init_netif(char *netifExp[], int netifFileNum); static void usage(const char *ctl); @@ -118,9 +118,11 @@ main(int ac, char **av) char *memImageFile = NULL; char *netifFile[VKNETIF_MAX]; char *diskFile[VKDISK_MAX]; + char *cdFile[VKDISK_MAX]; char *suffix; int netifFileNum = 0; int diskFileNum = 0; + int cdFileNum = 0; int c; int i; int n; @@ -130,7 +132,7 @@ main(int ac, char **av) */ kernel_mem_readonly = 1; - while ((c = getopt(ac, av, "svm:r:e:i:I:U")) != -1) { + while ((c = getopt(ac, av, "c:svm:r:e:i:I:U")) != -1) { switch(c) { case 'e': /* @@ -161,9 +163,13 @@ main(int ac, char **av) netifFile[netifFileNum++] = optarg; break; case 'r': - if (diskFileNum < VKDISK_MAX) + if (diskFileNum + cdFileNum < VKDISK_MAX) diskFile[diskFileNum++] = optarg; break; + case 'c': + if (diskFileNum + cdFileNum < VKDISK_MAX) + cdFile[cdFileNum++] = optarg; + break; case 'm': Maxmem_bytes = strtoull(optarg, &suffix, 0); if (suffix) { @@ -200,7 +206,8 @@ main(int ac, char **av) init_globaldata(); init_vkernel(); init_kqueue(); - init_disk(diskFile, diskFileNum); + init_disk(diskFile, diskFileNum, VKD_DISK); + init_disk(cdFile, cdFileNum, VKD_CD); init_netif(netifFile, netifFileNum); init_exceptions(); mi_startup(); @@ -571,7 +578,7 @@ init_vkernel(void) */ static void -init_disk(char *diskExp[], int diskFileNum) +init_disk(char *diskExp[], int diskFileNum, enum vkdisk_type type) { int i; @@ -593,7 +600,10 @@ init_disk(char *diskExp[], int diskFileNum) int fd; size_t l = 0; - fd = open(fname, O_RDWR|O_DIRECT, 0644); + if (type == VKD_DISK) + fd = open(fname, O_RDWR|O_DIRECT, 0644); + else + fd = open(fname, O_RDONLY|O_DIRECT, 0644); if (fd < 0 || fstat(fd, &st) < 0) { err(1, "Unable to open/create %s", fname); /* NOT REACHED */ @@ -604,10 +614,15 @@ init_disk(char *diskExp[], int diskFileNum) info->unit = i; info->fd = fd; + info->type = type; memcpy(info->fname, fname, l); - if (i == 0) - rootdevnames[0] = "ufs:vkd0a"; + if (i == 0) { + if (type == VKD_CD) + rootdevnames[0] = "cd9660:vcd0a"; + else if (type == VKD_DISK) + rootdevnames[0] = "ufs:vkd0a"; + } DiskNum++; } else { -- 2.41.0