本文整理汇总了C++中dkcksum函数的典型用法代码示例。如果您正苦于以下问题:C++ dkcksum函数的具体用法?C++ dkcksum怎么用?C++ dkcksum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dkcksum函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setdisklabel
/*
* Check new disk label for sensibility
* before setting it.
*/
int
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
struct cpu_disklabel *osdep)
{
int i;
struct partition *opp, *npp;
if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
dkcksum(nlp) != 0)
return EINVAL;
while ((i = ffs(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;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:39,代码来源:disksubr.c
示例2: setdisklabel
/*
* Check new disk label for sensibility
* before setting it.
*/
int
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
struct cpu_disklabel *osdep)
{
int i;
struct partition *opp, *npp;
/* sanity clause */
if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0
|| (nlp->d_secsize % DEV_BSIZE) != 0)
return(EINVAL);
/* special case to allow disklabel to be invalidated */
if (nlp->d_magic == 0xffffffff) {
*olp = *nlp;
return (0);
}
if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
dkcksum(nlp) != 0)
return (EINVAL);
/* XXX missing check if other dos partitions will be overwritten */
while (openmask != 0) {
i = ffs(openmask) - 1;
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);
}
开发者ID:MarginC,项目名称:kame,代码行数:53,代码来源:disksubr.c
示例3: vndgetdefaultlabel
static void
vndgetdefaultlabel(struct vnd_softc *sc, struct disklabel *lp)
{
struct vndgeom *vng = &sc->sc_geom;
struct partition *pp;
memset(lp, 0, sizeof(*lp));
lp->d_secperunit = sc->sc_size / (vng->vng_secsize / DEV_BSIZE);
lp->d_secsize = vng->vng_secsize;
lp->d_nsectors = vng->vng_nsectors;
lp->d_ntracks = vng->vng_ntracks;
lp->d_ncylinders = vng->vng_ncylinders;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
strncpy(lp->d_typename, "vnd", sizeof(lp->d_typename));
lp->d_type = DTYPE_VND;
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_flags = 0;
pp = &lp->d_partitions[RAW_PART];
pp->p_offset = 0;
pp->p_size = lp->d_secperunit;
pp->p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:32,代码来源:vnd.c
示例4: fdgetdisklabel
int
fdgetdisklabel(dev_t dev, struct fd_softc *fd, struct disklabel *lp,
int spoofonly)
{
bzero(lp, sizeof(struct disklabel));
lp->d_type = DTYPE_FLOPPY;
lp->d_secsize = FD_BSIZE(fd);
lp->d_secpercyl = fd->sc_type->seccyl;
lp->d_nsectors = fd->sc_type->sectrac;
lp->d_ncylinders = fd->sc_type->tracks;
lp->d_ntracks = fd->sc_type->heads; /* Go figure... */
DL_SETDSIZE(lp, fd->sc_type->size);
strncpy(lp->d_typename, "floppy disk", sizeof(lp->d_typename));
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
lp->d_version = 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
/*
* Call the generic disklabel extraction routine. If there's
* not a label there, fake it.
*/
return readdisklabel(DISKLABELDEV(dev), fdstrategy, lp, spoofonly);
}
开发者ID:toddfries,项目名称:OpenBSD-sys-patches,代码行数:28,代码来源:fd.c
示例5: maru_getdefaultlabel
/*
* build standard adaptec ficticious geometry
*/
static void
maru_getdefaultlabel(struct maru_softc *sc, struct disklabel *lp)
{
struct partition *pp;
DB("maru_getdefaultlabel(%p, %p)\n", sc, lp);
bzero(lp, sizeof *lp);
lp->d_secsize = 512;
lp->d_secperunit = sc->sc_size / lp->d_secsize;
lp->d_nsectors = 32;
lp->d_ntracks = 16;
lp->d_ncylinders = sc->sc_size / (lp->d_nsectors * lp->d_secsize * lp->d_ntracks);
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
strncpy(lp->d_typename, "maru", sizeof(lp->d_typename));
lp->d_type = DTYPE_VND; /* XXX compat */
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_flags = 0;
pp = &lp->d_partitions[RAW_PART];
pp->p_offset = 0;
pp->p_size = lp->d_secperunit;
pp->p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
}
开发者ID:MerlijnWajer,项目名称:rubberhose,代码行数:32,代码来源:nbsd_maru.c
示例6: wdgetdefaultlabel
void
wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp)
{
WDCDEBUG_PRINT(("wdgetdefaultlabel\n"), DEBUG_FUNCS);
bzero(lp, sizeof(struct disklabel));
lp->d_secsize = DEV_BSIZE;
DL_SETDSIZE(lp, wd->sc_capacity);
lp->d_ntracks = wd->sc_params.atap_heads;
lp->d_nsectors = wd->sc_params.atap_sectors;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_secpercyl;
if (wd->drvp->ata_vers == -1) {
lp->d_type = DTYPE_ST506;
strncpy(lp->d_typename, "ST506/MFM/RLL", sizeof lp->d_typename);
} else {
lp->d_type = DTYPE_ESDI;
strncpy(lp->d_typename, "ESDI/IDE disk", sizeof lp->d_typename);
}
/* XXX - user viscopy() like sd.c */
strncpy(lp->d_packname, wd->sc_params.atap_model, sizeof lp->d_packname);
lp->d_flags = 0;
lp->d_version = 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:28,代码来源:wd.c
示例7: dk_getdefaultlabel
/* ARGSUSED */
void
dk_getdefaultlabel(struct dk_softc *dksc, struct disklabel *lp)
{
struct disk_geom *dg = &dksc->sc_dkdev.dk_geom;
memset(lp, 0, sizeof(*lp));
if (dg->dg_secperunit > UINT32_MAX)
lp->d_secperunit = UINT32_MAX;
else
lp->d_secperunit = dg->dg_secperunit;
lp->d_secsize = dg->dg_secsize;
lp->d_nsectors = dg->dg_nsectors;
lp->d_ntracks = dg->dg_ntracks;
lp->d_ncylinders = dg->dg_ncylinders;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
strlcpy(lp->d_typename, dksc->sc_xname, sizeof(lp->d_typename));
lp->d_type = dksc->sc_dtype;
strlcpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_flags = 0;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(dksc->sc_dkdev.dk_label);
}
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:34,代码来源:dksubr.c
示例8: presto_getdisklabel
/*
* Read the disklabel. If none is present, use a fictitious one instead.
*/
void
presto_getdisklabel(struct presto_softc *sc)
{
struct disklabel *lp = sc->sc_dk.dk_label;
bzero(sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
bzero(sc->sc_dk.dk_label, sizeof(struct disklabel));
lp->d_secsize = DEV_BSIZE;
lp->d_ntracks = 1;
lp->d_nsectors = 32;
lp->d_secperunit = (sc->sc_memsize - PSERVE_OFFSET) >> DEV_BSHIFT;
lp->d_ncylinders = lp->d_secperunit / lp->d_nsectors;
lp->d_secpercyl = lp->d_nsectors;
strncpy(lp->d_typename, "Prestoserve", 16);
lp->d_type = DTYPE_SCSI; /* what better to put here? */
strncpy(lp->d_packname, sc->sc_model, 16);
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
readdisklabel(DISKLABELDEV(sc->sc_dev.dv_unit), prestostrategy,
sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel, 0);
}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:36,代码来源:presto.c
示例9: vndgetdisklabel
/*
* Load the label information on the named device
*/
int
vndgetdisklabel(dev_t dev, struct vnd_softc *sc, struct disklabel *lp,
int spoofonly)
{
memset(lp, 0, sizeof(struct disklabel));
lp->d_secsize = sc->sc_secsize;
lp->d_nsectors = sc->sc_nsectors;
lp->d_ntracks = sc->sc_ntracks;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
lp->d_ncylinders = sc->sc_size / lp->d_secpercyl;
strncpy(lp->d_typename, "vnd device", sizeof(lp->d_typename));
lp->d_type = DTYPE_VND;
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
DL_SETDSIZE(lp, sc->sc_size);
lp->d_flags = 0;
lp->d_version = 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
/* Call the generic disklabel extraction routine */
return readdisklabel(DISKLABELDEV(dev), vndstrategy, lp, spoofonly);
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:29,代码来源:vnd.c
示例10: ldgetdefaultlabel
/*
* Construct a ficticious label.
*/
static void
ldgetdefaultlabel(struct ld_softc *sc, struct disklabel *lp)
{
memset(lp, 0, sizeof(struct disklabel));
lp->d_secsize = sc->sc_secsize;
lp->d_ntracks = sc->sc_nheads;
lp->d_nsectors = sc->sc_nsectors;
lp->d_ncylinders = sc->sc_ncylinders;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
lp->d_type = DTYPE_LD;
strcpy(lp->d_typename, "unknown");
strcpy(lp->d_packname, "fictitious");
lp->d_secperunit = sc->sc_secperunit;
lp->d_rpm = 7200;
lp->d_interleave = 1;
lp->d_flags = 0;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size =
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
}
开发者ID:MarginC,项目名称:kame,代码行数:32,代码来源:ld.c
示例11: mcdgetdefaultlabel
void
mcdgetdefaultlabel(struct mcd_softc *sc, struct disklabel *lp)
{
memset(lp, 0, sizeof(struct disklabel));
lp->d_secsize = sc->blksize;
lp->d_ntracks = 1;
lp->d_nsectors = 100;
lp->d_ncylinders = (sc->disksize / 100) + 1;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
strncpy(lp->d_typename, "Mitsumi CD-ROM", 16);
lp->d_type = 0; /* XXX */
strncpy(lp->d_packname, "fictitious", 16);
lp->d_secperunit = sc->disksize;
lp->d_rpm = 300;
lp->d_interleave = 1;
lp->d_flags = D_REMOVABLE;
lp->d_partitions[0].p_offset = 0;
lp->d_partitions[0].p_size =
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
lp->d_partitions[0].p_fstype = FS_ISO9660;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size =
lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
lp->d_partitions[RAW_PART].p_fstype = FS_ISO9660;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:34,代码来源:mcd.c
示例12: ofdisk_getdefaultlabel
void
ofdisk_getdefaultlabel(struct ofdisk_softc *of, struct disklabel *lp)
{
memset(lp, 0, sizeof *lp);
/*
* XXX Firmware bug? Asking for block size gives a
* XXX ridiculous number! So we use what the boot program
* XXX uses.
*/
lp->d_secsize = DEV_BSIZE;
lp->d_secperunit = OF_call_method_1("#blocks",
of->sc_ihandle, 0);
if (lp->d_secperunit == (u_int32_t)-1)
lp->d_secperunit = 0x7fffffff;
lp->d_secpercyl = 1;
lp->d_nsectors = 1;
lp->d_ntracks = 1;
lp->d_ncylinders = lp->d_secperunit;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
lp->d_npartitions = RAW_PART + 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:31,代码来源:ofdisk.c
示例13: rdgetdisklabel
int
rdgetdisklabel(dev_t dev, struct rd_softc *sc, struct disklabel *lp,
int spoofonly)
{
bzero(lp, sizeof(struct disklabel));
lp->d_secsize = DEV_BSIZE;
lp->d_ntracks = 1;
lp->d_nsectors = rd_root_size >> DEV_BSHIFT;
lp->d_ncylinders = 1;
lp->d_secpercyl = lp->d_nsectors;
if (lp->d_secpercyl == 0) {
lp->d_secpercyl = 100;
/* as long as it's not 0 - readdisklabel divides by it */
}
strncpy(lp->d_typename, "RAM disk", sizeof(lp->d_typename));
lp->d_type = DTYPE_SCSI;
strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
DL_SETDSIZE(lp, lp->d_nsectors);
lp->d_version = 1;
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
lp->d_checksum = dkcksum(lp);
/* Call the generic disklabel extraction routine. */
return (readdisklabel(DISKLABELDEV(dev), rdstrategy, lp, spoofonly));
}
开发者ID:sofuture,项目名称:bitrig,代码行数:29,代码来源:rd.c
示例14: dk_makedisklabel
/* ARGSUSED */
static void
dk_makedisklabel(struct dk_softc *dksc)
{
struct disklabel *lp = dksc->sc_dkdev.dk_label;
lp->d_partitions[RAW_PART].p_fstype = FS_BSDFFS;
strlcpy(lp->d_packname, "default label", sizeof(lp->d_packname));
lp->d_checksum = dkcksum(lp);
}
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:10,代码来源:dksubr.c
示例15: readdisklabel
/*
* Attempt to read a disk label from a device
* using the indicated strategy 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.
*/
const char *
readdisklabel(dev_t dev, void (*strat)(struct buf *bp), struct disklabel *lp,
struct cpu_disklabel *osdep)
{
struct buf *bp;
struct disklabel *dlp;
const char *msg = NULL;
if (lp->d_secperunit == 0)
lp->d_secperunit = 0x1fffffff;
lp->d_npartitions = 1;
if (lp->d_partitions[0].p_size == 0)
lp->d_partitions[0].p_size = 0x1fffffff;
lp->d_partitions[0].p_offset = 0;
bp = geteblk((int)lp->d_secsize);
bp->b_dev = dev;
bp->b_blkno = LABELSECTOR;
bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ;
bp->b_cylinder = LABELSECTOR / lp->d_secpercyl;
(*strat)(bp);
if (biowait(bp)) {
msg = "I/O error";
} else for (dlp = (struct disklabel *)bp->b_data;
dlp <= (struct disklabel *)
((char *)bp->b_data + DEV_BSIZE - sizeof(*dlp));
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
if (msg == NULL)
msg = "no disk label";
} else if (dlp->d_npartitions > MAXPARTITIONS ||
dkcksum(dlp) != 0)
msg = "disk label corrupted";
else {
*lp = *dlp;
msg = NULL;
break;
}
}
brelse(bp, 0);
/*
* If no NetBSD label was found, check for an Ultrix label and
* construct tne incore label from the Ultrix partition information.
*/
if (msg != NULL) {
msg = compat_label(dev, strat, lp, osdep);
if (msg == NULL) {
printf("WARNING: using Ultrix partition information\n");
/* set geometry? */
}
}
/* XXX If no NetBSD label or Ultrix label found, generate default label here */
return msg;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:63,代码来源:disksubr.c
示例16: readdisklabel
/*
* Attempt to read a disk label from a device
* using the indicated strategy 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.
*/
const char *
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
struct cpu_disklabel *osdep)
{
struct buf *bp;
struct disklabel *dlp;
const char *msg = NULL;
int i;
if (lp->d_secsize == 0)
lp->d_secsize = DEV_BSIZE;
if (lp->d_secperunit == 0)
lp->d_secperunit = 0x1fffffff;
if (lp->d_npartitions < RAW_PART + 1)
lp->d_npartitions = RAW_PART + 1;
for (i = 0; i < RAW_PART; i++) {
lp->d_partitions[i].p_size = 0;
lp->d_partitions[i].p_offset = 0;
}
if (lp->d_partitions[RAW_PART].p_size == 0)
lp->d_partitions[RAW_PART].p_size = lp->d_secperunit;
lp->d_partitions[RAW_PART].p_offset = 0;
lp->d_partitions[0].p_size = lp->d_partitions[RAW_PART].p_size;
lp->d_partitions[0].p_fstype = FS_BSDFFS;
bp = geteblk((int)lp->d_secsize);
bp->b_dev = dev;
bp->b_blkno = LABELSECTOR;
bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ;
bp->b_cylinder = LABELSECTOR / lp->d_secpercyl;
(*strat)(bp);
if (biowait(bp))
msg = "I/O error";
else for (dlp = (struct disklabel *)bp->b_data;
dlp <= (struct disklabel *)((char *)bp->b_data + DEV_BSIZE
- sizeof(*dlp));
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
if (msg == NULL)
msg = "no disk label";
} else if (dlp->d_npartitions > MAXPARTITIONS ||
dkcksum(dlp) != 0)
msg = "disk label corrupted";
else {
*lp = *dlp;
msg = NULL;
break;
}
}
brelse(bp, 0);
return msg;
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:62,代码来源:disksubr.c
示例17: setdisklabel
/* Perform some checks and then copy a disk label */
scsi_ret_t
setdisklabel(
struct disklabel *lp,
struct disklabel *nlp)
{
if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
(dkcksum(nlp) != 0))
return D_INVALID_OPERATION;
*lp = *nlp;
return D_SUCCESS;
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:12,代码来源:rz_disk.c
示例18: targettohlabel
void
targettohlabel(struct disklabel *hlp, const struct disklabel *tlp)
{
if (bswap32(tlp->d_magic) == DISKMAGIC)
bswaplabel(hlp, tlp);
else
*hlp = *tlp;
/* update checksum in host endian */
hlp->d_checksum = 0;
hlp->d_checksum = dkcksum(hlp);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:12,代码来源:bswap.c
示例19: cputobsdlabel
int
cputobsdlabel(struct disklabel *lp, struct mvmedisklabel *clp)
{
int i;
if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC)
return (EINVAL); /* no disk label */
lp->d_magic = clp->magic1;
lp->d_type = clp->type;
lp->d_subtype = clp->subtype;
strncpy(lp->d_typename, clp->vid_vd, sizeof lp->d_typename);
strncpy(lp->d_packname, clp->packname, sizeof lp->d_packname);
lp->d_secsize = clp->cfg_psm;
lp->d_nsectors = clp->cfg_spt;
lp->d_ncylinders = clp->cfg_trk; /* trk is really num of cyl! */
lp->d_ntracks = clp->cfg_hds;
lp->d_secpercyl = clp->secpercyl;
if (DL_GETDSIZE(lp) == 0)
DL_SETDSIZE(lp, clp->secperunit);
lp->d_acylinders = clp->acylinders;
lp->d_flags = clp->flags;
for (i = 0; i < NDDATA; i++)
lp->d_drivedata[i] = clp->drivedata[i];
for (i = 0; i < NSPARE; i++)
lp->d_spare[i] = clp->spare[i];
lp->d_magic2 = clp->magic2;
lp->d_npartitions = clp->partitions;
lp->d_bbsize = clp->bbsize;
lp->d_sbsize = clp->sbsize;
bcopy(clp->vid_4, &lp->d_partitions[0], sizeof(struct partition) * 4);
bcopy(clp->cfg_4, &lp->d_partitions[4], sizeof(struct partition) * 12);
if (clp->version < 2) {
struct __partitionv0 *v0pp = (struct __partitionv0 *)lp->d_partitions;
struct partition *pp = lp->d_partitions;
for (i = 0; i < lp->d_npartitions; i++, pp++, v0pp++) {
pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(v0pp->
p_fsize, v0pp->p_frag);
pp->p_offseth = 0;
pp->p_sizeh = 0;
}
}
lp->d_version = 1;
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
return (0);
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:53,代码来源:disksubr.c
示例20: rewritelabel
void
rewritelabel(char *s, int fd, struct disklabel *lp)
{
if (unlabeled)
return;
lp->d_checksum = 0;
lp->d_checksum = dkcksum(lp);
if (ioctl(fd, DIOCWDINFO, (char *)lp) < 0) {
warn("ioctl (WDINFO)");
fatal("%s: can't rewrite disk label", s);
}
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:13,代码来源:newfs.c
注:本文中的dkcksum函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论