Implement DIOCGDEFLABEL.
This commit is contained in:
parent
062c3f563a
commit
939e074dcc
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: wd.c,v 1.163 1997/08/27 11:25:14 bouyer Exp $ */
|
/* $NetBSD: wd.c,v 1.164 1997/10/08 23:10:10 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
|
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
|
||||||
@ -94,6 +94,7 @@ struct cfdriver wd_cd = {
|
|||||||
NULL, "wd", DV_DISK
|
NULL, "wd", DV_DISK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void wdgetdefaultlabel __P((struct wd_softc *, struct disklabel *));
|
||||||
void wdgetdisklabel __P((struct wd_softc *));
|
void wdgetdisklabel __P((struct wd_softc *));
|
||||||
int wd_get_parms __P((struct wd_softc *));
|
int wd_get_parms __P((struct wd_softc *));
|
||||||
void wdstrategy __P((struct buf *));
|
void wdstrategy __P((struct buf *));
|
||||||
@ -496,21 +497,14 @@ wdclose(dev, flag, fmt, p)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Fabricate a default disk label, and try to read the correct one.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
wdgetdisklabel(wd)
|
wdgetdefaultlabel(wd, lp)
|
||||||
struct wd_softc *wd;
|
struct wd_softc *wd;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
struct disklabel *lp = wd->sc_dk.dk_label;
|
|
||||||
struct wd_link *d_link = wd->d_link;
|
struct wd_link *d_link = wd->d_link;
|
||||||
char *errstring;
|
|
||||||
|
|
||||||
WDDEBUG_PRINT(("wdgetdisklabel\n"));
|
|
||||||
|
|
||||||
bzero(lp, sizeof(struct disklabel));
|
bzero(lp, sizeof(struct disklabel));
|
||||||
bzero(wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
|
||||||
|
|
||||||
lp->d_secsize = DEV_BSIZE;
|
lp->d_secsize = DEV_BSIZE;
|
||||||
lp->d_ntracks = d_link->sc_params.wdp_heads;
|
lp->d_ntracks = d_link->sc_params.wdp_heads;
|
||||||
@ -537,6 +531,24 @@ wdgetdisklabel(wd)
|
|||||||
lp->d_magic = DISKMAGIC;
|
lp->d_magic = DISKMAGIC;
|
||||||
lp->d_magic2 = DISKMAGIC;
|
lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fabricate a default disk label, and try to read the correct one.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
wdgetdisklabel(wd)
|
||||||
|
struct wd_softc *wd;
|
||||||
|
{
|
||||||
|
struct disklabel *lp = wd->sc_dk.dk_label;
|
||||||
|
struct wd_link *d_link = wd->d_link;
|
||||||
|
char *errstring;
|
||||||
|
|
||||||
|
WDDEBUG_PRINT(("wdgetdisklabel\n"));
|
||||||
|
|
||||||
|
bzero(wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||||
|
|
||||||
|
wdgetdefaultlabel(wd, lp);
|
||||||
|
|
||||||
d_link->sc_badsect[0] = -1;
|
d_link->sc_badsect[0] = -1;
|
||||||
|
|
||||||
@ -662,7 +674,11 @@ wdioctl(dev, xfer, addr, flag, p)
|
|||||||
else
|
else
|
||||||
d_link->sc_flags &= ~WDF_WLABEL;
|
d_link->sc_flags &= ~WDF_WLABEL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
wdgetdefaultlabel(wd, (struct disklabel *)addr);
|
||||||
|
return 0;
|
||||||
|
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
case DIOCWFORMAT:
|
case DIOCWFORMAT:
|
||||||
if ((flag & FWRITE) == 0)
|
if ((flag & FWRITE) == 0)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ccd.c,v 1.43 1997/08/04 10:00:11 fair Exp $ */
|
/* $NetBSD: ccd.c,v 1.44 1997/10/08 23:06:59 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||||
@ -190,6 +190,7 @@ static int ccdinit __P((struct ccddevice *, char **, struct proc *));
|
|||||||
static int ccdlookup __P((char *, struct proc *p, struct vnode **));
|
static int ccdlookup __P((char *, struct proc *p, struct vnode **));
|
||||||
static void ccdbuffer __P((struct ccd_softc *, struct buf *,
|
static void ccdbuffer __P((struct ccd_softc *, struct buf *,
|
||||||
daddr_t, caddr_t, long, struct ccdbuf **));
|
daddr_t, caddr_t, long, struct ccdbuf **));
|
||||||
|
static void ccdgetdefaultlabel __P((struct ccd_softc *, struct disklabel *));
|
||||||
static void ccdgetdisklabel __P((dev_t));
|
static void ccdgetdisklabel __P((dev_t));
|
||||||
static void ccdmakedisklabel __P((struct ccd_softc *));
|
static void ccdmakedisklabel __P((struct ccd_softc *));
|
||||||
static int ccdlock __P((struct ccd_softc *));
|
static int ccdlock __P((struct ccd_softc *));
|
||||||
@ -1093,6 +1094,7 @@ ccdioctl(dev, cmd, data, flag, p)
|
|||||||
case DIOCWDINFO:
|
case DIOCWDINFO:
|
||||||
case DIOCGPART:
|
case DIOCGPART:
|
||||||
case DIOCWLABEL:
|
case DIOCWLABEL:
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
if ((cs->sc_flags & CCDF_INITED) == 0)
|
if ((cs->sc_flags & CCDF_INITED) == 0)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
@ -1300,6 +1302,10 @@ ccdioctl(dev, cmd, data, flag, p)
|
|||||||
cs->sc_flags &= ~CCDF_WLABEL;
|
cs->sc_flags &= ~CCDF_WLABEL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
ccdgetdefaultlabel(cs, (struct disklabel *)data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (ENOTTY);
|
return (ENOTTY);
|
||||||
}
|
}
|
||||||
@ -1413,23 +1419,14 @@ ccdlookup(path, p, vpp)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the disklabel from the ccd. If one is not present, fake one
|
|
||||||
* up.
|
|
||||||
*/
|
|
||||||
static void
|
static void
|
||||||
ccdgetdisklabel(dev)
|
ccdgetdefaultlabel(cs, lp)
|
||||||
dev_t dev;
|
struct ccd_softc *cs;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
int unit = ccdunit(dev);
|
|
||||||
struct ccd_softc *cs = &ccd_softc[unit];
|
|
||||||
char *errstring;
|
|
||||||
struct disklabel *lp = cs->sc_dkdev.dk_label;
|
|
||||||
struct cpu_disklabel *clp = cs->sc_dkdev.dk_cpulabel;
|
|
||||||
struct ccdgeom *ccg = &cs->sc_geom;
|
struct ccdgeom *ccg = &cs->sc_geom;
|
||||||
|
|
||||||
bzero(lp, sizeof(*lp));
|
bzero(lp, sizeof(*lp));
|
||||||
bzero(clp, sizeof(*clp));
|
|
||||||
|
|
||||||
lp->d_secperunit = cs->sc_size;
|
lp->d_secperunit = cs->sc_size;
|
||||||
lp->d_secsize = ccg->ccg_secsize;
|
lp->d_secsize = ccg->ccg_secsize;
|
||||||
@ -1453,6 +1450,25 @@ ccdgetdisklabel(dev)
|
|||||||
lp->d_magic = DISKMAGIC;
|
lp->d_magic = DISKMAGIC;
|
||||||
lp->d_magic2 = DISKMAGIC;
|
lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = dkcksum(cs->sc_dkdev.dk_label);
|
lp->d_checksum = dkcksum(cs->sc_dkdev.dk_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the disklabel from the ccd. If one is not present, fake one
|
||||||
|
* up.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
ccdgetdisklabel(dev)
|
||||||
|
dev_t dev;
|
||||||
|
{
|
||||||
|
int unit = ccdunit(dev);
|
||||||
|
struct ccd_softc *cs = &ccd_softc[unit];
|
||||||
|
char *errstring;
|
||||||
|
struct disklabel *lp = cs->sc_dkdev.dk_label;
|
||||||
|
struct cpu_disklabel *clp = cs->sc_dkdev.dk_cpulabel;
|
||||||
|
|
||||||
|
bzero(clp, sizeof(*clp));
|
||||||
|
|
||||||
|
ccdgetdefaultlabel(cs, lp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the generic disklabel extraction routine.
|
* Call the generic disklabel extraction routine.
|
||||||
@ -1487,6 +1503,8 @@ ccdmakedisklabel(cs)
|
|||||||
lp->d_partitions[RAW_PART].p_fstype = FS_BSDFFS;
|
lp->d_partitions[RAW_PART].p_fstype = FS_BSDFFS;
|
||||||
|
|
||||||
strncpy(lp->d_packname, "default label", sizeof(lp->d_packname));
|
strncpy(lp->d_packname, "default label", sizeof(lp->d_packname));
|
||||||
|
|
||||||
|
lp->d_checksum = dkcksum(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: mcd.c,v 1.54 1997/06/14 08:55:14 thorpej Exp $ */
|
/* $NetBSD: mcd.c,v 1.55 1997/10/08 23:10:06 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
|
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
|
||||||
@ -189,6 +189,7 @@ struct cfdriver mcd_cd = {
|
|||||||
NULL, "mcd", DV_DISK
|
NULL, "mcd", DV_DISK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void mcdgetdefaultlabel __P((struct mcd_softc *, struct disklabel *));
|
||||||
void mcdgetdisklabel __P((struct mcd_softc *));
|
void mcdgetdisklabel __P((struct mcd_softc *));
|
||||||
int mcd_get_parms __P((struct mcd_softc *));
|
int mcd_get_parms __P((struct mcd_softc *));
|
||||||
void mcdstrategy __P((struct buf *));
|
void mcdstrategy __P((struct buf *));
|
||||||
@ -617,6 +618,10 @@ mcdioctl(dev, cmd, addr, flag, p)
|
|||||||
case DIOCWLABEL:
|
case DIOCWLABEL:
|
||||||
return EBADF;
|
return EBADF;
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
mcdgetdefaultlabel(sc, (struct disklabel *)addr);
|
||||||
|
return 0;
|
||||||
|
|
||||||
case CDIOCPLAYTRACKS:
|
case CDIOCPLAYTRACKS:
|
||||||
return mcd_playtracks(sc, (struct ioc_play_track *)addr);
|
return mcd_playtracks(sc, (struct ioc_play_track *)addr);
|
||||||
case CDIOCPLAYMSF:
|
case CDIOCPLAYMSF:
|
||||||
@ -674,18 +679,13 @@ mcdioctl(dev, cmd, addr, flag, p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This could have been taken from scsi/cd.c, but it is not clear
|
|
||||||
* whether the scsi cd driver is linked in.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
mcdgetdisklabel(sc)
|
mcdgetdefaultlabel(sc, lp)
|
||||||
struct mcd_softc *sc;
|
struct mcd_softc *sc;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
struct disklabel *lp = sc->sc_dk.dk_label;
|
|
||||||
|
|
||||||
bzero(lp, sizeof(struct disklabel));
|
bzero(lp, sizeof(struct disklabel));
|
||||||
bzero(sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
|
||||||
|
|
||||||
lp->d_secsize = sc->blksize;
|
lp->d_secsize = sc->blksize;
|
||||||
lp->d_ntracks = 1;
|
lp->d_ntracks = 1;
|
||||||
@ -710,12 +710,27 @@ mcdgetdisklabel(sc)
|
|||||||
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
|
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
|
||||||
lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
|
lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
|
||||||
lp->d_npartitions = RAW_PART + 1;
|
lp->d_npartitions = RAW_PART + 1;
|
||||||
|
|
||||||
lp->d_magic = DISKMAGIC;
|
lp->d_magic = DISKMAGIC;
|
||||||
lp->d_magic2 = DISKMAGIC;
|
lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This could have been taken from scsi/cd.c, but it is not clear
|
||||||
|
* whether the scsi cd driver is linked in.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mcdgetdisklabel(sc)
|
||||||
|
struct mcd_softc *sc;
|
||||||
|
{
|
||||||
|
struct disklabel *lp = sc->sc_dk.dk_label;
|
||||||
|
|
||||||
|
bzero(sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||||
|
|
||||||
|
mcdgetdefaultlabel(sc, lp);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mcd_get_parms(sc)
|
mcd_get_parms(sc)
|
||||||
struct mcd_softc *sc;
|
struct mcd_softc *sc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: wd.c,v 1.163 1997/08/27 11:25:14 bouyer Exp $ */
|
/* $NetBSD: wd.c,v 1.164 1997/10/08 23:10:10 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
|
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
|
||||||
@ -94,6 +94,7 @@ struct cfdriver wd_cd = {
|
|||||||
NULL, "wd", DV_DISK
|
NULL, "wd", DV_DISK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void wdgetdefaultlabel __P((struct wd_softc *, struct disklabel *));
|
||||||
void wdgetdisklabel __P((struct wd_softc *));
|
void wdgetdisklabel __P((struct wd_softc *));
|
||||||
int wd_get_parms __P((struct wd_softc *));
|
int wd_get_parms __P((struct wd_softc *));
|
||||||
void wdstrategy __P((struct buf *));
|
void wdstrategy __P((struct buf *));
|
||||||
@ -496,21 +497,14 @@ wdclose(dev, flag, fmt, p)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Fabricate a default disk label, and try to read the correct one.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
wdgetdisklabel(wd)
|
wdgetdefaultlabel(wd, lp)
|
||||||
struct wd_softc *wd;
|
struct wd_softc *wd;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
struct disklabel *lp = wd->sc_dk.dk_label;
|
|
||||||
struct wd_link *d_link = wd->d_link;
|
struct wd_link *d_link = wd->d_link;
|
||||||
char *errstring;
|
|
||||||
|
|
||||||
WDDEBUG_PRINT(("wdgetdisklabel\n"));
|
|
||||||
|
|
||||||
bzero(lp, sizeof(struct disklabel));
|
bzero(lp, sizeof(struct disklabel));
|
||||||
bzero(wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
|
||||||
|
|
||||||
lp->d_secsize = DEV_BSIZE;
|
lp->d_secsize = DEV_BSIZE;
|
||||||
lp->d_ntracks = d_link->sc_params.wdp_heads;
|
lp->d_ntracks = d_link->sc_params.wdp_heads;
|
||||||
@ -537,6 +531,24 @@ wdgetdisklabel(wd)
|
|||||||
lp->d_magic = DISKMAGIC;
|
lp->d_magic = DISKMAGIC;
|
||||||
lp->d_magic2 = DISKMAGIC;
|
lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fabricate a default disk label, and try to read the correct one.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
wdgetdisklabel(wd)
|
||||||
|
struct wd_softc *wd;
|
||||||
|
{
|
||||||
|
struct disklabel *lp = wd->sc_dk.dk_label;
|
||||||
|
struct wd_link *d_link = wd->d_link;
|
||||||
|
char *errstring;
|
||||||
|
|
||||||
|
WDDEBUG_PRINT(("wdgetdisklabel\n"));
|
||||||
|
|
||||||
|
bzero(wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||||
|
|
||||||
|
wdgetdefaultlabel(wd, lp);
|
||||||
|
|
||||||
d_link->sc_badsect[0] = -1;
|
d_link->sc_badsect[0] = -1;
|
||||||
|
|
||||||
@ -662,7 +674,11 @@ wdioctl(dev, xfer, addr, flag, p)
|
|||||||
else
|
else
|
||||||
d_link->sc_flags &= ~WDF_WLABEL;
|
d_link->sc_flags &= ~WDF_WLABEL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
wdgetdefaultlabel(wd, (struct disklabel *)addr);
|
||||||
|
return 0;
|
||||||
|
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
case DIOCWFORMAT:
|
case DIOCWFORMAT:
|
||||||
if ((flag & FWRITE) == 0)
|
if ((flag & FWRITE) == 0)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: cd.c,v 1.103 1997/10/01 01:18:44 enami Exp $ */
|
/* $NetBSD: cd.c,v 1.104 1997/10/08 23:05:22 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
|
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
|
||||||
@ -94,6 +94,7 @@ int cdlock __P((struct cd_softc *));
|
|||||||
void cdunlock __P((struct cd_softc *));
|
void cdunlock __P((struct cd_softc *));
|
||||||
void cdstart __P((void *));
|
void cdstart __P((void *));
|
||||||
void cdminphys __P((struct buf *));
|
void cdminphys __P((struct buf *));
|
||||||
|
void cdgetdefaultlabel __P((struct cd_softc *, struct disklabel *));
|
||||||
void cdgetdisklabel __P((struct cd_softc *));
|
void cdgetdisklabel __P((struct cd_softc *));
|
||||||
void cddone __P((struct scsipi_xfer *));
|
void cddone __P((struct scsipi_xfer *));
|
||||||
u_long cd_size __P((struct cd_softc *, int));
|
u_long cd_size __P((struct cd_softc *, int));
|
||||||
@ -707,6 +708,10 @@ cdioctl(dev, cmd, addr, flag, p)
|
|||||||
case DIOCWLABEL:
|
case DIOCWLABEL:
|
||||||
return (EBADF);
|
return (EBADF);
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
cdgetdefaultlabel(cd, (struct disklabel *)addr);
|
||||||
|
return (0);
|
||||||
|
|
||||||
case CDIOCPLAYTRACKS: {
|
case CDIOCPLAYTRACKS: {
|
||||||
struct ioc_play_track *args = (struct ioc_play_track *)addr;
|
struct ioc_play_track *args = (struct ioc_play_track *)addr;
|
||||||
|
|
||||||
@ -878,21 +883,13 @@ cdioctl(dev, cmd, addr, flag, p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Load the label information on the named device
|
|
||||||
* Actually fabricate a disklabel
|
|
||||||
*
|
|
||||||
* EVENTUALLY take information about different
|
|
||||||
* data tracks from the TOC and put it in the disklabel
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
cdgetdisklabel(cd)
|
cdgetdefaultlabel(cd, lp)
|
||||||
struct cd_softc *cd;
|
struct cd_softc *cd;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
struct disklabel *lp = cd->sc_dk.dk_label;
|
|
||||||
|
|
||||||
bzero(lp, sizeof(struct disklabel));
|
bzero(lp, sizeof(struct disklabel));
|
||||||
bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
|
||||||
|
|
||||||
lp->d_secsize = cd->params.blksize;
|
lp->d_secsize = cd->params.blksize;
|
||||||
lp->d_ntracks = 1;
|
lp->d_ntracks = 1;
|
||||||
@ -923,6 +920,24 @@ cdgetdisklabel(cd)
|
|||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the label information on the named device
|
||||||
|
* Actually fabricate a disklabel
|
||||||
|
*
|
||||||
|
* EVENTUALLY take information about different
|
||||||
|
* data tracks from the TOC and put it in the disklabel
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cdgetdisklabel(cd)
|
||||||
|
struct cd_softc *cd;
|
||||||
|
{
|
||||||
|
struct disklabel *lp = cd->sc_dk.dk_label;
|
||||||
|
|
||||||
|
bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||||
|
|
||||||
|
cdgetdefaultlabel(cd, lp);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find out from the device what it's capacity is
|
* Find out from the device what it's capacity is
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sd.c,v 1.118 1997/10/01 01:19:17 enami Exp $ */
|
/* $NetBSD: sd.c,v 1.119 1997/10/08 23:05:24 thorpej Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
|
* Copyright (c) 1994, 1995, 1997 Charles M. Hannum. All rights reserved.
|
||||||
@ -118,6 +118,7 @@ void sdattach __P((struct device *, struct device *, void *));
|
|||||||
int sdlock __P((struct sd_softc *));
|
int sdlock __P((struct sd_softc *));
|
||||||
void sdunlock __P((struct sd_softc *));
|
void sdunlock __P((struct sd_softc *));
|
||||||
void sdminphys __P((struct buf *));
|
void sdminphys __P((struct buf *));
|
||||||
|
void sdgetdefaultlabel __P((struct sd_softc *, struct disklabel *));
|
||||||
void sdgetdisklabel __P((struct sd_softc *));
|
void sdgetdisklabel __P((struct sd_softc *));
|
||||||
void sdstart __P((void *));
|
void sdstart __P((void *));
|
||||||
void sddone __P((struct scsipi_xfer *));
|
void sddone __P((struct scsipi_xfer *));
|
||||||
@ -767,6 +768,10 @@ sdioctl(dev, cmd, addr, flag, p)
|
|||||||
return ((sd->sc_link->flags & SDEV_REMOVABLE) == 0 ? ENOTTY :
|
return ((sd->sc_link->flags & SDEV_REMOVABLE) == 0 ? ENOTTY :
|
||||||
scsipi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0));
|
scsipi_start(sd->sc_link, SSS_STOP|SSS_LOEJ, 0));
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
sdgetdefaultlabel(sd, (struct disklabel *)addr);
|
||||||
|
return (0);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (SDPART(dev) != RAW_PART)
|
if (SDPART(dev) != RAW_PART)
|
||||||
return (ENOTTY);
|
return (ENOTTY);
|
||||||
@ -778,28 +783,19 @@ sdioctl(dev, cmd, addr, flag, p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Load the label information on the named device
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
sdgetdisklabel(sd)
|
sdgetdefaultlabel(sd, lp)
|
||||||
struct sd_softc *sd;
|
struct sd_softc *sd;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
struct disklabel *lp = sd->sc_dk.dk_label;
|
|
||||||
char *errstring;
|
|
||||||
|
|
||||||
bzero(lp, sizeof(struct disklabel));
|
bzero(lp, sizeof(struct disklabel));
|
||||||
bzero(sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
|
||||||
|
|
||||||
lp->d_secsize = sd->params.blksize;
|
lp->d_secsize = sd->params.blksize;
|
||||||
lp->d_ntracks = sd->params.heads;
|
lp->d_ntracks = sd->params.heads;
|
||||||
lp->d_nsectors = sd->params.sectors;
|
lp->d_nsectors = sd->params.sectors;
|
||||||
lp->d_ncylinders = sd->params.cyls;
|
lp->d_ncylinders = sd->params.cyls;
|
||||||
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
|
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
|
||||||
if (lp->d_secpercyl == 0) {
|
|
||||||
lp->d_secpercyl = 100;
|
|
||||||
/* as long as it's not 0 - readdisklabel divides by it (?) */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sd->type == T_OPTICAL)
|
if (sd->type == T_OPTICAL)
|
||||||
strncpy(lp->d_typename, "SCSI optical", 16);
|
strncpy(lp->d_typename, "SCSI optical", 16);
|
||||||
@ -821,6 +817,27 @@ sdgetdisklabel(sd)
|
|||||||
lp->d_magic = DISKMAGIC;
|
lp->d_magic = DISKMAGIC;
|
||||||
lp->d_magic2 = DISKMAGIC;
|
lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the label information on the named device
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
sdgetdisklabel(sd)
|
||||||
|
struct sd_softc *sd;
|
||||||
|
{
|
||||||
|
struct disklabel *lp = sd->sc_dk.dk_label;
|
||||||
|
char *errstring;
|
||||||
|
|
||||||
|
bzero(sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||||
|
|
||||||
|
sdgetdefaultlabel(sd, lp);
|
||||||
|
|
||||||
|
if (lp->d_secpercyl == 0) {
|
||||||
|
lp->d_secpercyl = 100;
|
||||||
|
/* as long as it's not 0 - readdisklabel divides by it (?) */
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the generic disklabel extraction routine
|
* Call the generic disklabel extraction routine
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vnd.c,v 1.46 1997/08/26 18:12:58 thorpej Exp $ */
|
/* $NetBSD: vnd.c,v 1.47 1997/10/08 23:07:00 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||||
@ -172,6 +172,7 @@ void vndthrottle __P((struct vnd_softc *, struct vnode *));
|
|||||||
void vndiodone __P((struct buf *));
|
void vndiodone __P((struct buf *));
|
||||||
void vndshutdown __P((void));
|
void vndshutdown __P((void));
|
||||||
|
|
||||||
|
void vndgetdefaultlabel __P((struct vnd_softc *, struct disklabel *));
|
||||||
void vndgetdisklabel __P((dev_t));
|
void vndgetdisklabel __P((dev_t));
|
||||||
|
|
||||||
static int vndlock __P((struct vnd_softc *));
|
static int vndlock __P((struct vnd_softc *));
|
||||||
@ -685,6 +686,7 @@ vndioctl(dev, cmd, data, flag, p)
|
|||||||
case DIOCWDINFO:
|
case DIOCWDINFO:
|
||||||
case DIOCGPART:
|
case DIOCGPART:
|
||||||
case DIOCWLABEL:
|
case DIOCWLABEL:
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
if ((vnd->sc_flags & VNF_INITED) == 0)
|
if ((vnd->sc_flags & VNF_INITED) == 0)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
@ -891,6 +893,10 @@ vndioctl(dev, cmd, data, flag, p)
|
|||||||
vnd->sc_flags &= ~VNF_WLABEL;
|
vnd->sc_flags &= ~VNF_WLABEL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DIOCGDEFLABEL:
|
||||||
|
vndgetdefaultlabel(vnd, (struct disklabel *)data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (ENOTTY);
|
return (ENOTTY);
|
||||||
}
|
}
|
||||||
@ -1034,23 +1040,15 @@ vnddump(dev, blkno, va, size)
|
|||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the disklabel from a vnd. If one is not present, create a fake one.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
vndgetdisklabel(dev)
|
vndgetdefaultlabel(sc, lp)
|
||||||
dev_t dev;
|
struct vnd_softc *sc;
|
||||||
|
struct disklabel *lp;
|
||||||
{
|
{
|
||||||
struct vnd_softc *sc = &vnd_softc[vndunit(dev)];
|
|
||||||
char *errstring;
|
|
||||||
struct disklabel *lp = sc->sc_dkdev.dk_label;
|
|
||||||
struct cpu_disklabel *clp = sc->sc_dkdev.dk_cpulabel;
|
|
||||||
struct vndgeom *vng = &sc->sc_geom;
|
struct vndgeom *vng = &sc->sc_geom;
|
||||||
struct partition *pp;
|
struct partition *pp;
|
||||||
int i;
|
|
||||||
|
|
||||||
bzero(lp, sizeof(*lp));
|
bzero(lp, sizeof(*lp));
|
||||||
bzero(clp, sizeof(*clp));
|
|
||||||
|
|
||||||
lp->d_secperunit = sc->sc_size / (vng->vng_secsize / DEV_BSIZE);
|
lp->d_secperunit = sc->sc_size / (vng->vng_secsize / DEV_BSIZE);
|
||||||
lp->d_secsize = vng->vng_secsize;
|
lp->d_secsize = vng->vng_secsize;
|
||||||
@ -1075,6 +1073,24 @@ vndgetdisklabel(dev)
|
|||||||
lp->d_magic = DISKMAGIC;
|
lp->d_magic = DISKMAGIC;
|
||||||
lp->d_magic2 = DISKMAGIC;
|
lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the disklabel from a vnd. If one is not present, create a fake one.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
vndgetdisklabel(dev)
|
||||||
|
dev_t dev;
|
||||||
|
{
|
||||||
|
struct vnd_softc *sc = &vnd_softc[vndunit(dev)];
|
||||||
|
char *errstring;
|
||||||
|
struct disklabel *lp = sc->sc_dkdev.dk_label;
|
||||||
|
struct cpu_disklabel *clp = sc->sc_dkdev.dk_cpulabel;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
bzero(clp, sizeof(*clp));
|
||||||
|
|
||||||
|
vndgetdefaultlabel(sc, lp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the generic disklabel extraction routine.
|
* Call the generic disklabel extraction routine.
|
||||||
@ -1100,6 +1116,8 @@ vndgetdisklabel(dev)
|
|||||||
|
|
||||||
strncpy(lp->d_packname, "default label",
|
strncpy(lp->d_packname, "default label",
|
||||||
sizeof(lp->d_packname));
|
sizeof(lp->d_packname));
|
||||||
|
|
||||||
|
lp->d_checksum = dkcksum(lp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user