diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-03-22 22:54:44 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-03-22 22:54:44 +0000 |
commit | 4ac010668e431238d67a9bcc7af35fce2ced9411 (patch) | |
tree | b6a7d62ba7ba306884dfbb619b1e3fddce48aaf5 /sys | |
parent | 0dffa81a118569089faf4f1b7be7cd8a7acf9f82 (diff) |
Add support for DIOCRLDINFO, DIOCGPDINFO, DIOCGPART to the fd
driver(s). Adapted from sd driver.
ok marco@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc/dev/fd.c | 20 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/fd.c | 20 | ||||
-rw-r--r-- | sys/dev/isa/fd.c | 23 |
3 files changed, 58 insertions, 5 deletions
diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c index 7fab915b034..0c071113f25 100644 --- a/sys/arch/sparc/dev/fd.c +++ b/sys/arch/sparc/dev/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.57 2008/03/20 00:59:37 krw Exp $ */ +/* $OpenBSD: fd.c,v 1.58 2008/03/22 22:54:43 krw Exp $ */ /* $NetBSD: fd.c,v 1.51 1997/05/24 20:16:19 pk Exp $ */ /*- @@ -1768,13 +1768,31 @@ fdioctl(dev, cmd, addr, flag, p) struct proc *p; { struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)]; + struct disklabel *lp; int error; switch (cmd) { + case DIOCRLDINFO: + lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK); + fdgetdisklabel(dev, fd, lp, 0); + bcopy(lp, fd->sc_dk.dk_label, sizeof(*lp)); + free(lp, M_TEMP); + return 0; + + case DIOCGPDINFO: + fdgetdisklabel(dev, fd, (struct disklabel *)addr, 1); + return 0; + case DIOCGDINFO: *(struct disklabel *)addr = *(fd->sc_dk.dk_label); return 0; + case DIOCGPART: + ((struct partinfo *)addr)->disklab = fd->sc_dk.dk_label; + ((struct partinfo *)addr)->part = + &fd->sc_dk.dk_label->d_partitions[FDPART(dev)]; + return 0; + case DIOCWLABEL: if ((flag & FWRITE) == 0) return EBADF; diff --git a/sys/arch/sparc64/dev/fd.c b/sys/arch/sparc64/dev/fd.c index 35c8bdc024c..b2813790bf6 100644 --- a/sys/arch/sparc64/dev/fd.c +++ b/sys/arch/sparc64/dev/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.20 2008/03/20 00:59:37 krw Exp $ */ +/* $OpenBSD: fd.c,v 1.21 2008/03/22 22:54:43 krw Exp $ */ /* $NetBSD: fd.c,v 1.112 2003/08/07 16:29:35 agc Exp $ */ /*- @@ -1826,6 +1826,7 @@ fdioctl(dev, cmd, addr, flag, p) { struct fd_softc *fd; struct fdc_softc *fdc; + struct disklabel *lp; int unit; int error; #ifdef FD_DEBUG @@ -1840,10 +1841,27 @@ fdioctl(dev, cmd, addr, flag, p) fdc = (struct fdc_softc *)fd->sc_dv.dv_parent; switch (cmd) { + case DIOCRLDINFO: + lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK); + fdgetdisklabel(dev, fd, lp, 0); + bcopy(lp, fd->sc_dk.dk_label, sizeof(*lp)); + free(lp, M_TEMP); + return 0; + + case DIOCGPDINFO: + fdgetdisklabel(dev, fd, (struct disklabel *)addr, 1); + return 0; + case DIOCGDINFO: *(struct disklabel *)addr = *(fd->sc_dk.dk_label); return 0; + case DIOCGPART: + ((struct partinfo *)addr)->disklab = fd->sc_dk.dk_label; + ((struct partinfo *)addr)->part = + &fd->sc_dk.dk_label->d_partitions[DISKPART(dev)]; + return 0; + case DIOCWLABEL: if ((flag & FWRITE) == 0) return EBADF; diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 8d1f5ba0893..1c99189ca49 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.70 2008/03/21 20:30:02 krw Exp $ */ +/* $OpenBSD: fd.c,v 1.71 2008/03/22 22:54:42 krw Exp $ */ /* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */ /*- @@ -1038,9 +1038,26 @@ fdioctl(dev, cmd, addr, flag, p) if (((struct mtop *)addr)->mt_op != MTOFFL) return EIO; return (0); - case DIOCGDINFO: + + case DIOCRLDINFO: + lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK); fdgetdisklabel(dev, fd, lp, 0); - *(struct disklabel *)addr = *lp; + bcopy(lp, fd->sc_dk.dk_label, sizeof(*lp)); + free(lp, M_TEMP); + return 0; + + case DIOCGPDINFO: + fdgetdisklabel(dev, fd, (struct disklabel *)addr, 1); + return 0; + + case DIOCGDINFO: + *(struct disklabel *)addr = *(fd->sc_dk.dk_label); + return 0; + + case DIOCGPART: + ((struct partinfo *)addr)->disklab = fd->sc_dk.dk_label; + ((struct partinfo *)addr)->part = + &fd->sc_dk.dk_label->d_partitions[FDPART(dev)]; return 0; case DIOCWLABEL: |