Commit Graph

276 Commits

Author SHA1 Message Date
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
phk
eb28a1f905 #include the right thing for PC98
Sponsored by:	DARPA & NAI Labs.
2002-10-02 08:59:28 +00:00
phk
19150ba4f8 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
wollman
a50f81e50a Use correct printf format specifier to print unsigned longs. 2002-05-30 21:00:42 +00:00
ru
9f2bc31e30 NOSHARED is meaningless in the bsd.lib.mk context. 2002-05-13 12:00:45 +00:00
phk
02fe70f68e 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
phk
811d04c86c Modernize my email address. 2002-03-25 13:52:45 +00:00
dillon
2a7ecd5129 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
phk
c77a6625c0 Sort the disknames when we get them from the kernel.
Submitted by:	<anarcat@anarcat.dyndns.org>
2001-12-23 21:43:48 +00:00
dillon
c956ace928 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
matusita
44ad8faef3 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
peter
e63461ebd8 Add EFI GPT (238, 0xEE) and EFI System Parition (239, 0xEF) 2001-10-15 07:25:29 +00:00
jkh
3ecc099602 Check to see if the devfs MIB exists and return 1 if it exists rather
than making device node(s).
Submitted by:	Hiroo ONO <hiroo@oikumene.gcd.org>
2001-10-10 07:46:04 +00:00
bde
3f1e09f08e Fixed bitrot in synopsis. The change of the return type of
Set_Boot_Blocks() from void to int had not reached here.  Callers
still don't check the new return value.
2001-10-03 03:49:48 +00:00
ru
623da62a5a mdoc(7) police: Use the new .In macro for #include statements. 2001-10-01 16:09:29 +00:00
dillon
4015450ecd Add __FBSDID()s to libdisk 2001-09-30 21:16:57 +00:00
kris
110fc843a0 Mark some functions as __printflike() and/or taking const char * arguments
instead of char *.

MFC after:	2 weeks
2001-08-20 12:53:36 +00:00
ru
24c7b0a61d mdoc(7) police: s/BSD/.Bx/ where appropriate. 2001-08-14 10:01:54 +00:00
ru
80f060f0cf mdoc(7) police: protect trailing full stops of abbreviations
with a trailing zero-width space: `e.g.\&'.
2001-08-10 13:45:36 +00:00
dd
a145482cf6 Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
jkh
5b33a2af7c + add u_long sector_size to struct disk (documented in libdisk.3)
+ make Open_Disk sense the sector size by trying 512, 1024 and 2048
  in this order. This makes the kernel note that
  dscheck(cd1): bio_bcount 512 is not on a sector boundary (ssize 2048)
  dscheck(cd1): bio_bcount 1024 is not on a sector boundary (ssize 2048)
  if 2048 is the sector size. If this worries anyone: the message is from
  /usr/src/sys/kern/subr_diskslice.c and shutups are to be placed there.
+ Have read_block and write_block use an additional parameter, the
  sector size.
+ replace all barfout calls with return NULL, 0, __LINE__, etc.
  Note that this does NOT emit diagnostics. More often than not,
  you don't want library functions to scribble on stderr -- it may
  not even be available. The right thing is to propagate the error
  condition to upper management. The app should take care of errors.
+ use d1->sector_size instead of 512 in various places. I've left many
  places untouched, especially those writing MBRs. I simply added
  another arg hardcoded as 512. This is because I would not know what
  I'm doing... I felt this approach would be reasonably backward
  compatible and not introduce any new bugs in critical software.
  Famous last words. Messing with MBRs might soon put me in the same
  screwup meister category as, uh, never mind.  :-)
+ bump the max no of disks from 20 to 32 (due to PR 24503).

PR:		8434 / 8436 / 24503
Submitted by:	Jens Schweikhardt <schweikh@schweikhardt.net>
2001-05-13 20:08:54 +00:00
obrien
be7c1d1248 Add spaces around operators.
It's OK, the Project and afford them now -- they aren't as expensive as
they used to be.
2001-04-01 12:18:20 +00:00
obrien
51dae2254a Correct a comment. 2001-04-01 11:44:12 +00:00
obrien
090766603f Try to untangle some of the #ifdef spaghetti.
Also, looking to the future, don't assume all the world is an i386 and all
its disk layout brain damage will be repeated by other platforms.  So all
the diking out if we are an Alpha, becomes adding in if we are an i386.
2001-04-01 11:37:31 +00:00
obrien
e2cf0ccf62 Add back <err.h> for warn().
(of course it's pretty stupid to call it, as printf doesn't work w/in
sysinstall, and sysinstall is the only consumer of libdisk)
2001-04-01 11:32:56 +00:00
obrien
a47898d019 Quiet warnings on the Alpha. 2001-04-01 11:22:40 +00:00
obrien
a5f4cb4970 Add back <err.h> for warn().
(of course it's pretty stupid to call it, as printf doesn't work w/in
sysinstall, and sysinstall is the only consumer of libdisk)
2001-04-01 10:44:52 +00:00
ru
25ef23ac1c MAN[1-9] -> MAN. 2001-03-27 17:27:19 +00:00
obrien
981727ddcf Libraries should _never_ call exit() themselves (or its alternate spelling
`err()').  libdisk does! and additionally libdisk gets confused on Alpha
disks with foreign disklabels, throws up its hands and exits.  This is
the cause of the "going no where without my init" install bug on the Alpha.

So now on the Alpha, rather than call err(), we print the error string and
continue processing.

Submitted by:	jkh
2001-03-18 21:30:11 +00:00
bde
82a1988f70 Fixed bitrot in prototype(s) in synopsis. 2001-02-05 23:56:05 +00:00
ru
8a6f8b5fe4 mdoc(7) police: split punctuation characters + misc fixes. 2001-02-01 16:38:02 +00:00
ru
8ba4187688 Prepare for mdoc(7)NG. 2000-12-29 14:08:20 +00:00
rnordier
6c60f0fcfd Do install-time configuration of the i386 boot0 boot manager. At
present, this is limited to turning on the packet option if any of
disk slices begin above cylinder 1023.  The effect of this change
should therefore be to automatically enable LBA support, as needed,
when installing FreeBSD.

Something-of-the-kind-requested-by: peter
2000-12-12 17:25:06 +00:00