b700b86fc5
removed local pte.h use machine/pte.h
91 lines
2.2 KiB
C
91 lines
2.2 KiB
C
/*
|
|
* $Id: disksubr.c,v 1.6 1994/02/13 21:13:18 chopps Exp $
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
#include <sys/systm.h>
|
|
#include <sys/buf.h>
|
|
#include <sys/disklabel.h>
|
|
#include <sys/syslog.h>
|
|
|
|
|
|
/*
|
|
* Attempt to read a disk label from a device
|
|
* using the indicated stategy routine.
|
|
* The label must be partly set up before this:
|
|
* secpercyl and anything required in the strategy routine
|
|
* (e.g., sector size) must be filled in before calling us.
|
|
* Returns null on success and an error string on failure.
|
|
*/
|
|
char *
|
|
readdisklabel(dev, strat, lp, osdep)
|
|
dev_t dev;
|
|
void (*strat)();
|
|
register struct disklabel *lp;
|
|
struct cpu_disklabel *osdep;
|
|
{
|
|
/* I don't want BSD to fiddle with the RDBs, let the user use
|
|
HDToolbox under AmigaDOS to partition disk drives. */
|
|
return "partition drive under AmigaDOS";
|
|
}
|
|
|
|
/*
|
|
* Check new disk label for sensibility
|
|
* before setting it.
|
|
*/
|
|
int
|
|
setdisklabel(olp, nlp, openmask, osdep)
|
|
register struct disklabel *olp, *nlp;
|
|
u_long openmask;
|
|
struct cpu_disklabel *osdep;
|
|
{
|
|
register i;
|
|
register struct partition *opp, *npp;
|
|
|
|
if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
|
|
dkcksum(nlp) != 0)
|
|
return (EINVAL);
|
|
while ((i = ffs((long)openmask)) != 0) {
|
|
i--;
|
|
openmask &= ~(1 << i);
|
|
if (nlp->d_npartitions <= i)
|
|
return (EBUSY);
|
|
opp = &olp->d_partitions[i];
|
|
npp = &nlp->d_partitions[i];
|
|
if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
|
|
return (EBUSY);
|
|
/*
|
|
* Copy internally-set partition information
|
|
* if new label doesn't include it. XXX
|
|
*/
|
|
if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
|
|
npp->p_fstype = opp->p_fstype;
|
|
npp->p_fsize = opp->p_fsize;
|
|
npp->p_frag = opp->p_frag;
|
|
npp->p_cpg = opp->p_cpg;
|
|
}
|
|
}
|
|
nlp->d_checksum = 0;
|
|
nlp->d_checksum = dkcksum(nlp);
|
|
*olp = *nlp;
|
|
return (0);
|
|
}
|
|
|
|
/* encoding of disk minor numbers, should be elsewhere... */
|
|
#define dkunit(dev) (minor(dev) >> 3)
|
|
#define dkpart(dev) (minor(dev) & 07)
|
|
#define dkminor(unit, part) (((unit) << 3) | (part))
|
|
|
|
/*
|
|
* Write disk label back to device after modification.
|
|
*/
|
|
writedisklabel(dev, strat, lp, osdep)
|
|
dev_t dev;
|
|
void (*strat)();
|
|
register struct disklabel *lp;
|
|
struct cpu_disklabel *osdep;
|
|
{
|
|
return EINVAL;
|
|
}
|
|
|