Use DIOCWLABEL ioctl before writing block 0 which might be
protected by (now MI) bounds_check_with_label(9). Fixes a problem on sysinst mentioned in PR port-macppc/38016.
This commit is contained in:
parent
dba35d8b76
commit
a9e4cec8d9
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: macppc.c,v 1.9 2008/04/28 20:24:16 martin Exp $ */
|
||||
/* $NetBSD: macppc.c,v 1.10 2008/05/09 10:14:35 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -35,10 +35,14 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(__lint)
|
||||
__RCSID("$NetBSD: macppc.c,v 1.9 2008/04/28 20:24:16 martin Exp $");
|
||||
__RCSID("$NetBSD: macppc.c,v 1.10 2008/05/09 10:14:35 tsutsui Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/dkio.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
|
@ -92,6 +96,10 @@ writeapplepartmap(ib_params *params, struct bbinfo_params *bb_params,
|
|||
{
|
||||
struct apple_drvr_map dm;
|
||||
struct apple_part_map_entry pme;
|
||||
int rv;
|
||||
#ifdef DIOCWLABEL
|
||||
int enable;
|
||||
#endif
|
||||
|
||||
assert (params != NULL);
|
||||
assert (bb_params != NULL);
|
||||
|
@ -109,8 +117,27 @@ writeapplepartmap(ib_params *params, struct bbinfo_params *bb_params,
|
|||
dm.sbSig = htobe16(APPLE_DRVR_MAP_MAGIC);
|
||||
dm.sbBlockSize = htobe16(512);
|
||||
dm.sbBlkCount = htobe32(0);
|
||||
if (pwrite(params->fsfd, &dm, MACPPC_BOOT_BLOCK_BLOCKSIZE, 0) !=
|
||||
MACPPC_BOOT_BLOCK_BLOCKSIZE) {
|
||||
|
||||
#ifdef DIOCWLABEL
|
||||
/*
|
||||
* block 0 is LABELSECTOR which might be protected by
|
||||
* bounds_check_with_label(9).
|
||||
*/
|
||||
enable = 1;
|
||||
rv = ioctl(params->fsfd, DIOCWLABEL, &enable);
|
||||
if (rv != 0) {
|
||||
warn("Cannot enable writes to the label sector");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
rv = pwrite(params->fsfd, &dm, MACPPC_BOOT_BLOCK_BLOCKSIZE, 0);
|
||||
|
||||
#ifdef DIOCWLABEL
|
||||
/* Reset write-protect. */
|
||||
enable = 0;
|
||||
(void)ioctl(params->fsfd, DIOCWLABEL, &enable);
|
||||
#endif
|
||||
if (rv != MACPPC_BOOT_BLOCK_BLOCKSIZE) {
|
||||
warn("Can't write sector 0 of `%s'", params->filesystem);
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue