Commit Graph

298 Commits

Author SHA1 Message Date
Marcel Moolenaar
03e432ad9c 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
Robert Watson
f9657fb6bf 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
David E. O'Brien
e6f1abaa68 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
Scott Long
4e89f2d88f 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 Wemm
2512cd4e8f Teach libdisk that AMD64 works just like i386 2003-04-30 21:03:16 +00:00
David E. O'Brien
9be6d929b1 Only define platform once -- in a C file. 2003-04-30 17:14:58 +00:00
Poul-Henning Kamp
604c210c15 Fix a compiler warning.
Submitted by:	David Leimbach <leimy2k@mac.com>
2003-04-23 12:15:31 +00:00
Poul-Henning Kamp
32c44cd7bb Fix compilation errors.
I wonder how I managed to cross-compile this yesterday.
2003-04-22 05:34:35 +00:00
Poul-Henning Kamp
9ad2132174 Update libdisk to use the explicing encoding function for sunlabel data
structures.
2003-04-21 20:36:44 +00:00
Poul-Henning Kamp
a12b1b124a Use sized cast matching the sized pointer. 2003-04-04 16:59:39 +00:00
Poul-Henning Kamp
197e5e73ef 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
Philippe Charnier
592bb5e477 The .Nm library 2003-03-24 16:01:01 +00:00
Poul-Henning Kamp
2082addf66 Ignore GBDE devices.
Spotted by:	Lucky Green <shamrock@cypherpunks.to>
2003-03-17 07:25:50 +00:00
Yoshihiro Takahashi
60469a5bf3 Fix build error. 2003-02-06 14:26:41 +00:00
John Baldwin
9284f8f522 - 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
John Baldwin
58b5f01edc Remove mostly unused disk arguments from Fixup_*_Names() functions. 2003-02-04 17:26:45 +00:00
John Baldwin
f3c6522625 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
John Baldwin
53465bf736 - 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
Yoshihiro Takahashi
404a379e4a Rename the dos_partition structure for pc98 to pc98_partition. 2003-01-04 08:50:48 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Yoshihiro Takahashi
7a6b06168b 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
Ruslan Ermilov
ae82896268 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
John Baldwin
ba0b471d64 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
Yoshihiro Takahashi
1cfcbbd71c - 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
Yoshihiro Takahashi
021587f8c1 Fixed style(9) 2002-11-15 13:24:29 +00:00
Marcel Moolenaar
c3e6b1182b 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
Chad David
86b62d35bf - Document the chunk_name() function that replaces chunk_n[].
- Rearrange things a tiny bit.
2002-11-11 19:37:19 +00:00
Chad David
8ff8da756b Remove parameter names from function prototypes (at least one collided
with stdlib.h).

discussed with: phk
2002-11-11 18:55:57 +00:00
Poul-Henning Kamp
efb14d4614 Remove debugging printfs. 2002-11-11 10:08:46 +00:00
Marcel Moolenaar
cd5a1c3b76 MBR slices are named the same on ia64 as they are on i386. 2002-11-11 04:46:39 +00:00
Jake Burkholder
83702273a3 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 Moolenaar
7593e0d3c5 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 Moolenaar
c9a3bb24d6 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 Moolenaar
255bef40ce 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
Yoshihiro Takahashi
3b6431b5ed - Recognize FAT partition on MBR and PC98 disks.
- Fix to convert to the name of partition.
2002-11-08 15:25:15 +00:00
Yoshihiro Takahashi
8704e2bb35 MFi386: revision 1.4. 2002-11-08 14:49:14 +00:00
John Baldwin
a96977d0ab 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
John Baldwin
7f55ebcd18 Don't set a value to a variable that we don't use. 2002-11-08 14:00:09 +00:00
John Baldwin
2b39144955 - Merge Write_FreeBSD() into Write_Disk().
- Miscellaneous cleanups.
2002-11-08 13:58:00 +00:00
Yoshihiro Takahashi
ba91558ce9 Fixed pc98 support.
(merged i386 changes from chunk.c 1.41 and disk.c 1.100)
2002-11-07 14:54:53 +00:00
John Baldwin
75bd4c1549 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
John Baldwin
da58ad34ef Remove unused MBR gunk leftover from i386. 2002-11-03 21:18:17 +00:00
Yoshihiro Takahashi
0932c866b6 Fix to compile for pc98. 2002-11-03 09:35:08 +00:00
Marcel Moolenaar
62b693d7db 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 Moolenaar
12d76c6fec 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 Moolenaar
0a8575280c 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
Poul-Henning Kamp
a6db5ac980 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
Poul-Henning Kamp
0514d63049 Fill in partition 2 with with "whole disk" parameters. 2002-11-01 16:28:19 +00:00
Poul-Henning Kamp
fd4a61e809 Style(9) improvements. 2002-10-31 07:56:40 +00:00
Poul-Henning Kamp
63abca411d Set the sector size for the disk. 2002-10-31 07:55:38 +00:00
Yoshihiro Takahashi
fe1f2a9a84 Restore to pc98 support. 2002-10-31 05:51:25 +00:00
Yoshihiro Takahashi
fecafa765a Use ${MACHINE} variable instead of using '.if .endif' each machines. 2002-10-31 05:43:49 +00:00
Yoshihiro Takahashi
c540b79f8b Add '#include <err.h>' for warn(). 2002-10-31 05:38:48 +00:00
Jake Burkholder
e03494dd17 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
Poul-Henning Kamp
89a0742e57 Untested alpha disk writer. 2002-10-30 20:54:22 +00:00
Poul-Henning Kamp
ae59d02e12 Write out 15 sectors of boot code. 2002-10-30 20:52:07 +00:00
Poul-Henning Kamp
30820b02ab 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
Poul-Henning Kamp
4730deb1e3 Don't call warn(3). 2002-10-29 14:45:43 +00:00
Poul-Henning Kamp
56d3134bfb 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
Poul-Henning Kamp
2f7fb9cc47 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
Poul-Henning Kamp
bab7e1509c 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
Poul-Henning Kamp
b6c0192ce3 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 Wemm
7e50af21ba 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
Andrew Gallatin
b49cf84452 #ifdef out assignToPartition on non x86 arches to unbreak the world
on alpha, sparc64 and ia64
2002-10-24 13:35:52 +00:00
Poul-Henning Kamp
d7e9a2ad8a 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
Poul-Henning Kamp
943599b348 Remove another 10 mindless #ifdefs. 2002-10-23 20:35:42 +00:00
Poul-Henning Kamp
844c9bb884 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
Poul-Henning Kamp
b485e51552 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
Poul-Henning Kamp
532dd2fa86 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
Poul-Henning Kamp
56c0241de6 Separate the struct disklabel filling stuff from the rest of Write_FreeBSD(). 2002-10-23 19:32:18 +00:00
Yoshihiro Takahashi
7bec978084 - 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
Poul-Henning Kamp
0bb035b962 Add the new extra argument also in the alpha case. 2002-10-23 10:47:00 +00:00
Poul-Henning Kamp
c0e2acef98 No longer needed. 2002-10-22 15:22:36 +00:00
Poul-Henning Kamp
c087f8a1ce Remove the last traces of bogus MAKEDEV functionality. 2002-10-22 15:07:50 +00:00
Poul-Henning Kamp
374ec39bb6 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
Poul-Henning Kamp
1e08b0a637 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
Poul-Henning Kamp
fa9e908771 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
Poul-Henning Kamp
7d6d1e62a7 Lobotomize MakeDev(), we don't need it with devfs. 2002-10-21 22:03:03 +00:00
Poul-Henning Kamp
1c67107149 Sigh, d_ntracks, not d_nheads. 2002-10-21 20:42:20 +00:00
Poul-Henning Kamp
53894badfd fwheads and fwsectors got swapped underway.
Approved by:	sam
2002-10-21 19:44:07 +00:00
Sam Leffler
11480fc6ae 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 Leffler
bf6e74b5f5 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 Leffler
52dee23d90 not sure if this correct, but it compiles again 2002-10-18 00:26:34 +00:00
Sam Leffler
c1623066ca 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 Leffler
dda5b5a58a correct arg order to strlcpy/strlcat under #ifdef alpha 2002-10-17 18:23:21 +00:00
Yoshihiro Takahashi
89335c9f46 Fix to check disk geometry.
Submitted by:	kawanobe@st.rim.or.jp (Kawanobe Koh)
2002-10-14 13:15:14 +00:00
Kris Kennaway
8c12ff22b4 Use buffer-safe string functions for paranoia. 2002-10-12 22:03:22 +00:00
Kris Kennaway
5060afe8bc 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
Yoshihiro Takahashi
6d8c8fabad Fix to support pc98. 2002-10-08 12:13:19 +00:00
Poul-Henning Kamp
a5bdf7706c White-space change only. Move closer to style(9). 2002-10-04 18:10:39 +00:00
Poul-Henning Kamp
ae23634cab #include the right thing for PC98
Sponsored by:	DARPA & NAI Labs.
2002-10-02 08:59:28 +00:00
Poul-Henning Kamp
3bb24c35f2 Split MBR and PC98 on-disk sliceformats out from disklabel.h, step 1:
Peter had repocopied sys/disklabel.h to sys/diskpc98.h and sys/diskmbr.h.

These two new copies are still intact copies of disklabel.h and
therefore protected by #ifndef _SYS_DISKLABEL_H_ so #including them
in programs which already include <sys.disklabel.h> is currently a
no-op.

This commit adds a number of such #includes.

Once I have verified that I have fixed all the places which need fixing,
I will commit the updated versions of the three #include files.

Sponsored by:   DARPA & NAI Labs.
2002-10-01 07:24:55 +00:00
Garrett Wollman
d7c98975c5 Use correct printf format specifier to print unsigned longs. 2002-05-30 21:00:42 +00:00
Ruslan Ermilov
ede5bec0ba NOSHARED is meaningless in the bsd.lib.mk context. 2002-05-13 12:00:45 +00:00
Poul-Henning Kamp
77068a7fe2 Retire the bogus uses of the disklabel field d_sbsize and begin to
initialize it to zero so we don't have to have everbody and their
aunt including FFS specific header files.

Sponsored by: DARPA & NAI Labs.
2002-05-12 20:49:41 +00:00
Poul-Henning Kamp
aaead0dfe9 Modernize my email address. 2002-03-25 13:52:45 +00:00
Matthew Dillon
d010343b82 Modify Delete_Chunk() into Delete_Chunk2() which can take a flags
argument.  Leave a compatibility shim for Delete_Chunk().

Implement DELCHUNK_RECOVER flag so sysinstall can ask libdisk
to recover space when deleting a chunk.
2002-01-07 07:47:25 +00:00
Poul-Henning Kamp
257bc17600 Sort the disknames when we get them from the kernel.
Submitted by:	<anarcat@anarcat.dyndns.org>
2001-12-23 21:43:48 +00:00
Matthew Dillon
173592263d Add auto-fill-on-delete. When deleting an 'A'uto created partition
sysinstall will automatically expand the previous partition to take up
the freed up space.  So you can 'D'elete /home and /usr will get the
combined space, or you can 'D'elete /tmp and /var will get the combined space.

This gives the user, developer, or lay person a huge amount of flexibility
in constructing partitions from an 'A'uto base.  It takes only 3 or 4
keystrokes to achieve virtually any combination of having or not having
a /tmp and/or /home after doing an 'A'uto create.

Change 'A'uto creation of /var/tmp to 'A'uto creation /tmp, which should
be less controversial.

MFC after:	6 days
2001-12-09 23:40:02 +00:00
Makoto Matsushita
94eacee1fc One more fix for sysinstall/libdisk to create a device file
if and only if a target directory is devfs.  Previous patch
doesn't correct, it's unconditionally avoid to create a device
file if kernel knows devfs.

PR:		31109
2001-11-11 12:16:50 +00:00