http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
for some reason. (But I have no idea why that would be -- if you have one
of these really ancient partitions and you're about to run disklabel, you
can easily run fdisk first and change the partition type to NetBSD.)
As it stands, the code will munch FreeBSD installs under some
circumstances, which is really not acceptable behavior.
The code, along with the kernel support that's been disabled by
default for several years, and some related but less dangerous code in
sysinst, should prboably be removed entirely after -6 is branched.
Discussed on tech-kern and tech-userlevel; closes PR 44496.
This is also almost certainly the cause of PR 42521 and PR 38841.
printed. There's now a lot of PRIu16 and PRIu32, some PRIu8, some
SCNu32, and a few cases where %u and %d were reversed. Multiplication
of 32-bit and 8-bit values is cast to uint64_t and printed with PRIu64.
Inspired by a report from Patrick Welche on current-users.
(treating a target disk as a regular file and suppressing ioctl(2)s)
on reading/writing disklabel in a target file.
This allows cross build enviroment creating bootable disk images
for targets in different endian.
No functional changes to native (non-tools) disklabel(8) command.
Closes PR toolchain/42357.
Instead, use proper macro defined in Makefile per ${MACHINE_ARCH}.
__${MACHINE_ARCH}__ doesn't represent an architecture of tool's target
but an architecture of binaries being compiled, so required features
are not prolery enabled or unintentionally enabled on certain host
and target combinations during src/tools build.
- Use %.40g rather than %g when printing sectors and MB for existing
partition size/offset.
Changes [1.93802e+06c, 1953525105s, 953870M]:
to: [1938021c, 1953525105s, 953869.6875M]:
environment variables to override the sector number, and the
bytes-offset in the sector, where disklabel(8) writes a disklabel.
If disklabel(8) was compiled as a host tool, then the defaults
still come from the port's LABELOFFSET and LABELSECTOR #defines.
Otherwise, the defaults still come from the sysctls, kern.labelsector
and kern.labeloffset.
This change helps me create a bootable CompactFlash image with both
a Master Boot Record (MBR) and a BSD disklabel for the RouterBOARD
153. The RB 153 is an evbmips board with a CompactFlash slot. It
searches the MBR on a CompactFlash card for a partition containing
an ELF kernel. When disklabel(8) is built for evbmips, it will
ordinarily overwrite an MBR with the BSD disklabel.
logical operation, rather than compliment, as in praise, the magic
number of the disk.
There are probably other instances of this in the tree. We should fix
them.
In particular the 'read' part plays 'hunt the disklabel' in order to get a
label into a local buffer - from where it can be displayed/edited.
The 'write' part makes a separate scan of the disk looking for places to
write the label.
The main changes are:
- It can no longer write the first 8k of the mbr to the pbr (or v.v.)
- All labels on the disk (that it can find) get updated during a write
- With -A all the labels are displayed (inc. those deleted by -D)
- Addition of -D which will delete (by one's complimenting dk_magic{2}) and
existing labels before writing labels to the expected locations.
- -v gives some verbose output to stderr, -vv more etc
A better basis for processing incorrect endian labels, or labels from other
architectures.
getlabel{offset,sector} and opendisk functions declared in that file
are not used in this case anyway, and <util.h> pulls in unwatned
includes (e.g. <utmpx.h> doesn't exist on FreeBSD 4.*).
XXX: We can probably undo the #if !HAVE_NBTOOL_CONFIG_H kludge in
<util.h> now.