Commit Graph

308 Commits

Author SHA1 Message Date
marcel
58594e4f86 The partition naming on ia64 (e.g. da0p1) cannot be selected based
on whether the parent chunk is of type whole. This also applies to
MBR slices for non-GPT disks. Since most of the GPT handling is
conditionally compiled, do the same with the partition naming.

This fixes a braino that caused slices to be named as GPT partitions
and generally messing up an install.

Pointy hat: marcel
2003-11-12 17:44:37 +00:00
marcel
2e797ba95c o Save a copy of the GPT entries for which there's a chunk with an
index referencing it. We need to know the original type and name
   so that we know what to put in the table when we reconstruct it.
o  Clear the table entries before we rebuild it to avoid that we
   end up with stale data.
o  Sequentially populate the table entries from the chunks. For the
   chunks that have an index (now referencing the saved copy) we
   use the saved type and name. This way we can handle unknown types
   better. In all cases we update the start and end LBAs.
2003-11-04 03:49:01 +00:00
marcel
f46a656239 Don't divide the start and end of the chunk by the sector size when
filling in the GPT entry. Both are already in sector numbers (LBA)
and exactly what we need for the entry. We now write a structurally
correct GPT partitioning.
2003-11-03 06:52:30 +00:00
marcel
2464f65e4a Fix two bugs in the calculation of the last LBA of the GPT covered
part of the disk. The first appears to be a typo and instead of
dividing the media size with the sector size, we multiplied. The
second is an off-by-1 error that's the result of mixing up count
and index. The code in question is only applicable for virgin disks
and is used to create the "whole" chunk, which covers only the GPT
usable portion of the disk.
2003-11-03 06:24:48 +00:00
marcel
15f1414b69 Rewrite Write_Disk() so that it creates a GPT. Note that the code is
basicly untested, but the guts is all there. I need to free up a disk
before I give it a spin.
2003-11-03 03:18:34 +00:00
marcel
a72947f900 Turn Write_Disk() into a stub for now. It needs to be rewritten to
write out a GPT and not a MBR.
2003-11-02 08:41:18 +00:00
marcel
f637cc6639 o Move Int_Open_Disk() from disk.c to open_disk.c for use by all
platforms except ia64 and use Int_Open_Disk() in open_ia64_disk.c
   on ia64. We need to know more than GEOM can provide us so we're
   forced to read from the disk. Move uuid_type() to open_ia64_disk.c
   and remove all references on non-ia64.
o  Pass the GEOM conftxt to Int_Open_Disk() so that only Open_Disk()
   needs to know about GEOM and libdisk can more easily be used with
   media not handled by GEOM.
o  Create an ia64 specific definiton of struct disk on ia64, because
   we don't need/have most of the fields other platforms need and
   other fields not applicable on platforms other than ia64.
o  Do not compile change.c on ia64. It's too PC specific.
o  In Fixup_Names() in create_chunk.c, try all partition numbers
   that are valid for the GPT disk. We have the total number of
   partitions that can be allocated in the disk structure on ia64.
   Also, use the GPT partition naming if we're creating one under
   a chunk of type "whole". It's a GPT partition in that case.
o  In Create_Chunk(), compile-out the PC specific code on ia64 that
   checks BIOS geometry restrictions.
o  In Debug_Disk() in disk.c, dump the ia64 specific fields.
o  Save the partition index in the chunk on ia64 so that we can
   preserve it when we write the data back to disk. This avoids that
   partitions get moved around or swapped after installing FreeBSD,
   which may render a disk unusable.
2003-11-02 08:39:08 +00:00
marcel
d4476d880f Do not fill in d_ncylinders, d_ntracks and d_nsectors in the disklabel
on ia64. Not only do we not have a disklabel by default, we also do
not have a notion of cylinders, tracks and sectors.
2003-11-02 08:07:25 +00:00
marcel
470ee47978 Compile-out support for allfreebsd, dedicate, sanitize and bios on
ia64. These commands are PC specific and not supported.
2003-11-02 08:01:18 +00:00
marcel
ddedcf0a1f Turn Track_Aligned(), Prev_Track_Aligned(), Next_Track_Aligned(),
Cyl_Aligned(), Prev_Cyl_Aligned() and Next_Cyl_Aligned() into
tautologies on ia64. GPT removes all notion of tracks, heads and
sectors per track, so there are no alignment considerations.
2003-11-02 07:58:19 +00:00
marcel
841bb23cd9 o In Print_Chunk(), don't print the address of the chunk on ia64. It
doesn't have any meaning and only results in lines longer than 80
   characters.
o  In Delete_Chunk2(), also look for chunks of type "part" under
   chunks of type "whole" on ia64. They're not only under chunks of
   type "freebsd" there.
2003-11-02 07:44:59 +00:00
rwatson
9c09012ffb Disable #define DEBUG in libdisk by default: since libdisk is primarily
there to support sysinstall, and enabling DEBUG creates spurious
console output that can't be read anyway...  This slightly cleans up
the visual impression of the system install by not spamming the console
during the labeling of the disks.
2003-09-27 17:44:41 +00:00
obrien
c07d7db2a9 Ignore ccd(4)'s. This is not the best solution, but it at least removes
the "BARF 360" ccd(4) user's experience.

Submitted by:	rwatson
2003-08-28 17:39:09 +00:00
scottl
6d40d0ca55 Sanity check the list obtained from the kern.disks sysctl so that Disk_Names()
doesn't get fooled into returning a bogus list.  This should fix sysinstall
from segfaulting when no disk devices are present.
2003-06-07 20:02:56 +00:00
peter
75662965c8 Teach libdisk that AMD64 works just like i386 2003-04-30 21:03:16 +00:00
obrien
e7abd7e44d Only define platform once -- in a C file. 2003-04-30 17:14:58 +00:00
phk
851915e8b2 Fix a compiler warning.
Submitted by:	David Leimbach <leimy2k@mac.com>
2003-04-23 12:15:31 +00:00
phk
d20f3763cb Fix compilation errors.
I wonder how I managed to cross-compile this yesterday.
2003-04-22 05:34:35 +00:00
phk
a981fec797 Update libdisk to use the explicing encoding function for sunlabel data
structures.
2003-04-21 20:36:44 +00:00
phk
01bed5d97b Use sized cast matching the sized pointer. 2003-04-04 16:59:39 +00:00
phk
84d6b36e30 Libdisk does not need to include <sys/diskslice.h> any more.
Move the remaining bits of <sys/diskslice.h> to <i386/include/bootinfo.h>

Move i386/pc98 specific bits from <sys/reboot.h> to
<i386/include/bootinfo.h> as well.

Adjust includes in sys/boot accordingly.
2003-04-04 16:35:16 +00:00
charnier
4a7a5ceb41 The .Nm library 2003-03-24 16:01:01 +00:00
phk
31b892a2b6 Ignore GBDE devices.
Spotted by:	Lucky Green <shamrock@cypherpunks.to>
2003-03-17 07:25:50 +00:00
nyan
11484a52e9 Fix build error. 2003-02-06 14:26:41 +00:00
jhb
21f12932c4 - Remove unused old disk pointers from Write_FreeBSD() and Fill_Disklabel()
functions.
- Clean up a few signed/unsigned warnings.
2003-02-04 17:35:23 +00:00
jhb
06360ae9a9 Remove mostly unused disk arguments from Fixup_*_Names() functions. 2003-02-04 17:26:45 +00:00
jhb
5fc7b42391 Use the fstype obtained from the GEOM dumpconf output to set the fstype
of BSD part chunks when opening a disk.

Reviewed by:	phk
MFC after:	2 days
2003-01-10 19:45:10 +00:00
jhb
533d214b96 - Make New_Disk() non-static so it can be used in Create_Chunk_DWIM().
- In Create_Chunk_DWIM(), if there is a freebsd chunk that has no
  children chunks, then trying to add a child part chunk will fail even
  though there is free space.  Handle this special case by adding an
  unused chunk the full size of the freebsd chunk as a child of the
  freebsd chunk before adding the new part chunk.  This situation can
  happen when changing the type of an existing slice to be a FreeBSD
  slice type or when installing onto a blank disk on Alpha (which has
  no slices.)

Reviewed by:	phk
MFC after:	2 days
2003-01-10 19:25:38 +00:00
nyan
864080610e Rename the dos_partition structure for pc98 to pc98_partition. 2003-01-04 08:50:48 +00:00
schweikh
d3367c5f5d Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
nyan
63904a7353 Return an error if the size of the sector is zero. This is for removable
devices that is not inserted any media.

This is MFC candidate.

Submitted by:	ISAKA Yoji <isaka@cory.jp>
2002-12-26 15:50:45 +00:00
ru
ea13b9803b Consistently mark std(in|out|err) with .Dv, because that's how they
are marked up in stdio(3), and because they are defined expressions
of type "FILE *".

Approved by:	re
2002-12-04 18:57:46 +00:00
jhb
cfb76a5993 Break up a bunch of crazy if statements to use a case statement instead
to be cleaner.  Also, when deleting a chunk, try to find the mother chunk
as a whole chunk by default if this isn't a BSD partition or a unused or
whole chunk.  Before we just did this for FreeBSD and FAT slices, which
means that other chunk types such as EFI and mbr (mbr is used for slices
that don't have their own chunk type).

Submitted by:	nyan (mostly)
Approved by:	re
2002-12-02 21:42:29 +00:00
nyan
948193c5df - Ease sanity check to get cylinders.
- Get the slice name from the result of kern.geom.conftxt.
2002-11-17 13:51:22 +00:00
nyan
6677381325 Fixed style(9) 2002-11-15 13:24:29 +00:00
marcel
51b18a9ea3 Handle EFI partitions the same as regular FAT partitions. The only
difference between the two from a low-level point of view is that
the partition type is different. This change adds EFI related cases
to existing switch statements with existing FAT related cases.
2002-11-13 05:31:32 +00:00
davidc
95ac1af78c - Document the chunk_name() function that replaces chunk_n[].
- Rearrange things a tiny bit.
2002-11-11 19:37:19 +00:00
davidc
a9e193bc9a Remove parameter names from function prototypes (at least one collided
with stdlib.h).

discussed with: phk
2002-11-11 18:55:57 +00:00
phk
33be7592cc Remove debugging printfs. 2002-11-11 10:08:46 +00:00
marcel
8c44e1c3f9 MBR slices are named the same on ia64 as they are on i386. 2002-11-11 04:46:39 +00:00
jake
8ea3f3d908 Write the boot block to the first 16 sectors of all partitions, instead of
always to the first 16 sectors of the disk.  The firmware reads the boot
code from a partition, defaulting to 'a' if none is specified, which only
corresponds to the first 16 sectors of the disk if 'a' is first.  Solaris
often makes the swap partition first, instead of the root partition, and
users expect to be able to do the same with freebsd as well.  This also
allows one to temporarily boot from another partition if the boot block
on the root partition gets scrambled somehow.
2002-11-10 21:07:29 +00:00
marcel
c0696a1676 Add efi to the list of types for which we need to return tha name.
Also, return chunk type efi in case we find an EFI partition in
the GPT. We used to return FAT due to a lack of EFI type.
2002-11-10 20:53:10 +00:00
marcel
b5cdcf6ad1 Add an efi chunk type. We need to be able to create an EFI partition
on ia64, because that's where we need to put the loader and the
kernel.
2002-11-10 20:49:28 +00:00
marcel
474626e5e1 General cleanup:
o  Remove all code guarded by !defined(__ia64__). This file is
   specifically written for ia64,
o  Handle the case when read_block() or write_block() fails. We
   don't want sysinstall(8) to signal a thumbs-up on error,
o  Set the starting (cyl,hd,sect) triple to 0xFFFFFF when either
   bios_hd or bios_sect is zero or the LBA us not representable
   with the triple. In that case automaticly initialize the
   ending triple with 0xFFFFFF as well,
o  Reindent Write_Int32() as it was different than the rest of
   the file,
o  Remove some unused variables that appeared to be used but
   were effectively useless.
o  Plug a memory leak: The second timne we read the MBR, we write
   out a modified block, but didn't free the memory after writing.
o  Replace d1->sector_size with 512 when we read/write the MBR.
   We ignore the sector size in cases we shouldn't but adhered to
   it in cases it would be wrong if the sector_size wasn't 512.

This file should eventually be rewritten to write out a GPT. For
now, a MBR will do...
2002-11-10 20:47:02 +00:00
nyan
fd118b4af5 - Recognize FAT partition on MBR and PC98 disks.
- Fix to convert to the name of partition.
2002-11-08 15:25:15 +00:00
nyan
aecfe31a1d MFi386: revision 1.4. 2002-11-08 14:49:14 +00:00
jhb
fa9c6cb843 Don't set a variable to a bogus value right before setting it to the
correct value in the next statement.
2002-11-08 14:00:44 +00:00
jhb
c849fe6dd8 Don't set a value to a variable that we don't use. 2002-11-08 14:00:09 +00:00
jhb
481edf29a7 - Merge Write_FreeBSD() into Write_Disk().
- Miscellaneous cleanups.
2002-11-08 13:58:00 +00:00
nyan
2a35147541 Fixed pc98 support.
(merged i386 changes from chunk.c 1.41 and disk.c 1.100)
2002-11-07 14:54:53 +00:00
jhb
2b9783b539 Get this closer to working. The Write_Disk() function's for loop needed
to use the same start condition as the i386 version.  However, since
Alpha's only have one fake "slice" from sysinstall's perspective we don't
need to use a loop, but can just write out the BSD label in the first
fake "slice".
2002-11-07 14:39:21 +00:00
jhb
c558e52c47 Remove unused MBR gunk leftover from i386. 2002-11-03 21:18:17 +00:00
nyan
7479c2d936 Fix to compile for pc98. 2002-11-03 09:35:08 +00:00
marcel
c9f86b731d Initialize d->bios_cyl. We know the media size in sectors, the number
of heads end the number of sectors per track. If there's an obvious
insanity (heads and sectors are both zero or the media size is not
an integral multiple of heads times sector) we set the number of
cylinders to zero.
2002-11-03 01:37:08 +00:00
marcel
27850e5112 Add support for GPT:
1. When the parition type is not an integer, try to parse the type
   as an UUID. If that succeeds, map the UUID to chunk_e.
2. For GPT partitions, pass the type constructed in point 1 above
   to Add_Chunk.

While here, fix the MBREXT case by only checking if the first 3
characters are MBR. This avoids duplication.
2002-11-02 12:14:04 +00:00
marcel
24ab0000c9 Add support for ia64. This is almost identical to i386, except that
with GPT chunks of type "part" do not necessarily live under chunks
of type "freebsd". We don't necessarily have a disklabel.
2002-11-02 12:05:16 +00:00
phk
01e8832a61 Don't claim all MBR's have subtype 165 on i386.
Spotted by:	Frode Nordahl <frode@nordahl.net>
2002-11-02 10:57:44 +00:00
phk
e7002ff1e5 Fill in partition 2 with with "whole disk" parameters. 2002-11-01 16:28:19 +00:00
phk
5dbff154c8 Style(9) improvements. 2002-10-31 07:56:40 +00:00
phk
a1b493e265 Set the sector size for the disk. 2002-10-31 07:55:38 +00:00
nyan
674ee79610 Restore to pc98 support. 2002-10-31 05:51:25 +00:00
nyan
0315c477ee Use ${MACHINE} variable instead of using '.if .endif' each machines. 2002-10-31 05:43:49 +00:00
nyan
2616a319ce Add '#include <err.h>' for warn(). 2002-10-31 05:38:48 +00:00
jake
3523a0f8a2 Actually save the bootblock in the disk structure. Write the bootblock
to the right place on the disk instead of srewn all over it.
2002-10-31 04:25:17 +00:00
phk
c925cf4a99 Untested alpha disk writer. 2002-10-30 20:54:22 +00:00
phk
01d1bdfdb0 Write out 15 sectors of boot code. 2002-10-30 20:52:07 +00:00
phk
d52f4602e2 Getting closer to getting things right:
Always ignore the RAW_PART for BSD.
Having no quirks is not a mistake for an architecture.

Tested by:	DES
2002-10-29 17:12:02 +00:00
phk
885738b312 Don't call warn(3). 2002-10-29 14:45:43 +00:00
phk
9ac588fcdc Since make release is toast anyway, add wood to the pyre:
This significantly rewamps libdisks discovery of existing disk
layout.

Please send me reports if this does not work as expected on
i386 or sparc64 platforms.

I need to sort out alpha, pc98 and ia64 (in that order) before
testing on those platforms make a lot of sense.

Belived to work for:	i386 sparc64
Unknown state:		pc98 alpha ia64
2002-10-29 12:13:36 +00:00
phk
6e81beacf8 Fix various minor issues.
Don't explode on 'write' because we access a pointer we just freed.
2002-10-29 07:39:18 +00:00
phk
4d780c389d the 'd' partition hasn't been magic for years, so allocate it in natural
order instead of last.
2002-10-29 07:37:11 +00:00
phk
aee7fb11fe Add the write_spar64_disk.c to make life easier for testers.
This file depends on some major surgery in the rest of libdisk which is
not yet committed.
2002-10-29 07:35:36 +00:00
peter
29db798cec Add back ia64 support that was removed in the last few revisions.
I've cloned write_ia64_disk.c from write_i386_disk.c.
2002-10-27 00:21:02 +00:00
gallatin
e5963e51d5 #ifdef out assignToPartition on non x86 arches to unbreak the world
on alpha, sparc64 and ia64
2002-10-24 13:35:52 +00:00
phk
f9fe53ba89 More lobotomy:
remove CHUNK_BSD_COMPAT, it was a bad idea, and now its gone.
        remove DOSPTYP_ONTRACK, missed in OnTrack removal commit.
        unifdef -DHAVE_GEOM
make tst01 compile again.
2002-10-23 21:05:42 +00:00
phk
8e1649e9df Remove another 10 mindless #ifdefs. 2002-10-23 20:35:42 +00:00
phk
7be332e622 Rely on sysctl kern.disks to be there, and get rid of one of the far too
many lists of disk device driver names in the system.  At this point
we should really get the names from the XML, but hey...
2002-10-23 20:15:10 +00:00
phk
c17cb9154e Remove unnecessary ioctls tickling kernel side to realize that we fiddled
with the disk.  GEOM will automatically retaste when we closet he filedesc.
2002-10-23 20:02:33 +00:00
phk
3c688df114 Untangle #ifdefs in the write-end of things by giving each arch its
own file and own copy of WriteDisk() to do things in.

This should have happened years ago, instead of adding #ifdefs all
over the place.
2002-10-23 19:52:32 +00:00
phk
a422fc77ae Separate the struct disklabel filling stuff from the rest of Write_FreeBSD(). 2002-10-23 19:32:18 +00:00
nyan
59e14a9b80 - The GEOM system does not work on pc98.
- Fix to build w/o the HAVE_GEOM option.
2002-10-23 13:00:09 +00:00
phk
e3a940d2bf Add the new extra argument also in the alpha case. 2002-10-23 10:47:00 +00:00
phk
260859f738 No longer needed. 2002-10-22 15:22:36 +00:00
phk
35c355e2f2 Remove the last traces of bogus MAKEDEV functionality. 2002-10-22 15:07:50 +00:00
phk
aa430888dc Live with it: I had hoped to find a neat way to deal with all the magic
numbers, but so far havn't come up with anything:  Add an #ifdef PC98.
2002-10-22 11:55:27 +00:00
phk
1bc5baf5c9 Avoid a lot of #ifdef PC98 code by giving a couple of the Chunk functions
an extra argument for all archs.
2002-10-22 10:51:58 +00:00
phk
43441f1d03 Swing the weed-whacker around libdisk:
Constify some things.
Staticize some things.
Remove some unused things.
Prototype some things.
Don't install a gazillion man-pages links.
Drop support for ON-TRACK disk-manager.
2002-10-22 09:13:02 +00:00
phk
57dd722cff Lobotomize MakeDev(), we don't need it with devfs. 2002-10-21 22:03:03 +00:00
phk
f6d2923501 Sigh, d_ntracks, not d_nheads. 2002-10-21 20:42:20 +00:00
phk
c166543507 fwheads and fwsectors got swapped underway.
Approved by:	sam
2002-10-21 19:44:07 +00:00
sam
8199d9ca41 Another baby step toward getting sysinstall working:
o fillin media s/h/c fields from new XML phk just added; need this because
  sysinstall uses them in the fdisk look-alike
o add new tags to xml parser
o cleanup parser a touch; remove unused tags and move tag parsing stuff to
  a table to simplify future additions
o redo callback to pass 64-bit values since mediasize overflows u_int32_t
o loosen parsing sanity checks a touch to deal with new xml we must handle
o move sector size probing to non-geom handling since we now get it from xml
o remove WHOLE_DISK_SLICE buggery now that we get mediasize from xml
2002-10-20 22:19:37 +00:00
sam
715f7b0ad3 o since you can't use DIOCGDINFO and DIOCGSLICEINFO on drive nodes with geom,
get the xml configuration for the devices and "parse" the information to
  get what's needed
o replace #ifdef DEBUG constructs with DPRINT/DPRINTX to make the code more
  readable

Note the xml "parser" is very very hackish and should be replaced with a
real one.  This one was done to be very small and special-purpose; don't
think about copying it elsewhere.

Approved by:	phk
2002-10-19 16:39:28 +00:00
sam
7fb694f053 not sure if this correct, but it compiles again 2002-10-18 00:26:34 +00:00
sam
68349b6d1c o ioctl DIOCGDINFO error wasn't checked
o memory wasn't reclaimed in certain cases
o add more msgs under #ifdef DEBUG
o rewrite tangle of for loops for clarity

NB: Open_Disk should redo how it malloc's memory so the caller can free
    everything.  Documentation says the caller can free the disk list to
    reclaim everything but this leaks the indirect strings.  Fixing this
    is simple for the sysctl case but adds complexity to the fallback,
    non-sysctl, case.
2002-10-17 18:34:32 +00:00
sam
8680a53ace correct arg order to strlcpy/strlcat under #ifdef alpha 2002-10-17 18:23:21 +00:00
nyan
879ba46c82 Fix to check disk geometry.
Submitted by:	kawanobe@st.rim.or.jp (Kawanobe Koh)
2002-10-14 13:15:14 +00:00
kris
78372d114d Use buffer-safe string functions for paranoia. 2002-10-12 22:03:22 +00:00
kris
ab2f5d80c1 Zero memory after malloc. This stops sysinstall from dumping core
during disk probing with malloc debugging enabled.

MFC after:	1 week
2002-10-12 22:01:57 +00:00
nyan
4c34626aa8 Fix to support pc98. 2002-10-08 12:13:19 +00:00
phk
789741b5dc White-space change only. Move closer to style(9). 2002-10-04 18:10:39 +00:00