After modifying the Apple Disk Partition Map, use the DIOCGDINFO/DIOCWDINFO
ioctls to refresh the in-core disk label. From Bob Nestor.
This commit is contained in:
parent
79e44b9f63
commit
8f69e0c022
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: md.c,v 1.19 2001/01/14 02:38:19 mrg Exp $ */
|
/* $NetBSD: md.c,v 1.20 2001/07/14 07:57:16 scottr Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
@ -683,7 +683,29 @@ md_pre_disklabel()
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Well, if we get here the dirty deed has been done.
|
* Well, if we get here the dirty deed has been done.
|
||||||
|
*
|
||||||
|
* Now we need to force the incore disk table to get updated. This
|
||||||
|
* should be done by disklabel -- which is normally called right after
|
||||||
|
* we return -- but may be commented out for the mac68k port. We'll
|
||||||
|
* instead update the incore table by forcing a dummy write here. This
|
||||||
|
* relies on a change in the mac68k-specific writedisklabel() routine.
|
||||||
|
* If that change doesn't exist nothing bad happens here. If disklabel
|
||||||
|
* properly updates the ondisk and incore labels everything still
|
||||||
|
* works. Only if we fail here and if disklabel fails are we in
|
||||||
|
* in a state where we've updated the disk but not the incore and
|
||||||
|
* a reboot is necessary.
|
||||||
|
*
|
||||||
|
* First, we grab a copy of the incore label as it existed before
|
||||||
|
* we did anything to it. Then we invoke the "write label" ioctl to
|
||||||
|
* rewrite it to disk. As a result, the ondisk partition map is
|
||||||
|
* re-read and the incore label is reconstructed from it. If
|
||||||
|
* disklabel() is then called to update again, either that fails
|
||||||
|
* because the mac68k port doesn't support native disklabels, or it
|
||||||
|
* succeeds and writes out a new ondisk copy.
|
||||||
*/
|
*/
|
||||||
|
ioctl(fd, DIOCGDINFO, &lp); /* Get the current disk label */
|
||||||
|
ioctl(fd, DIOCWDINFO, &lp); /* Write it out again */
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: md.h,v 1.7 2000/12/22 10:12:15 mrg Exp $ */
|
/* $NetBSD: md.h,v 1.8 2001/07/14 07:57:17 scottr Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 Piermont Information Systems Inc.
|
* Copyright 1997 Piermont Information Systems Inc.
|
||||||
@ -179,16 +179,21 @@ EXTERN char *disk_names[]
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Machine-specific command to write a new label to a disk.
|
* Machine-specific command to write a new label to a disk.
|
||||||
* For example, i386 uses "/sbin/disklabel -w -r", just like i386
|
* For example, i386 uses "/sbin/disklabel -w -r", just like i386
|
||||||
* miniroot scripts, though this may leave a bogus incore label.
|
* miniroot scripts, though this may leave a bogus incore label.
|
||||||
* Sun ports should probably use DISKLABEL_CMD "/sbin/disklabel -w"
|
* Sun ports should probably use DISKLABEL_CMD "/sbin/disklabel -w"
|
||||||
* to get incore to ondisk inode translation for the Sun proms.
|
* to get incore to ondisk inode translation for the Sun proms.
|
||||||
* If not defined, we assume the port does not support disklabels and
|
* If not defined, we assume the port does not support disklabels and
|
||||||
* hand-edited disklabel will NOT be written by MI code.
|
* hand-edited disklabel will NOT be written by MI code.
|
||||||
*
|
*
|
||||||
* The mac68k port doesn't support real disklabels so we don't define the
|
* The mac68k port doesn't support real disklabels so we don't define the
|
||||||
* command string. The Mac Disk Partition Map gets written in the
|
* command string. The Apple Disk Partition Map gets written in the
|
||||||
* md_pre_disklabel() routine.
|
* md_pre_disklabel() routine, which also forces the incore copy to be
|
||||||
|
* updated. If native disklabels are supported or if disklabel() is
|
||||||
|
* fixed to work for writing labels, this command should be defined
|
||||||
|
* to a value that will force the writing of the label. In that case,
|
||||||
|
* the code in md_pre_disklabel() which forces the incore update can be
|
||||||
|
* removed, though its presence won't hurt.
|
||||||
*
|
*
|
||||||
* #define DISKLABEL_CMD
|
* #define DISKLABEL_CMD
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user