History log of /freebsd-9.3-release/lib/libdisk/disk.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 178765 04-May-2008 gonzo

Add MIPS support to libdisk

Approved by: cognet (mentor)


# 176322 15-Feb-2008 antoine

- Make Disk_Names() behave as documented in libdisk(3): return an array
of disk names, where you must free each pointer, as well as the array
by hand. [1]
- Destaticize "disks" in Disk_Names, it has no reasons to be static.

PR: kern/96077 [1]
PR: kern/114110 [1]
MFC after: 1 month
Approved by: rwatson (mentor)


# 158033 25-Apr-2006 maxim

o Add IDs for Plan9, QNX4.X, Mac OS-X, Linux exteneded partitions.

PR: bin/96326
Submitted by: Alex Kozlov
MFC after: 2 weeks


# 154814 25-Jan-2006 cognet

Add a dummy arm Write_Disk() function, and compile libdisk on arm.


# 145013 13-Apr-2005 nyan

Merge two slice_type_name() functions.


# 139167 22-Dec-2004 yongari

Plug memory leak.

MFC after: 1 week


# 137512 10-Nov-2004 phk

Add 0xbf (191) as new Solaris partition identifier.

Submitted by: Lawrence.Lee@sun.com


# 129302 16-May-2004 stefanf

Remove spurious semicolons. Outside of functions they are actually errors but
GCC doesn't warn about them without -pedantic.

Approved by: das (mentor)
PR: 56649
Reviewed by: md5


# 128541 21-Apr-2004 grehan

PowerPC support.

submitted by: Suleiman Souhlal <refugee@segfaulted.com>
approved by: phk, jhb


# 127595 29-Mar-2004 kuriyama

Make libdisk WARNS=4 clean.

Glanced by: jhb


# 121888 02-Nov-2003 marcel

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.


# 119532 28-Aug-2003 obrien

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


# 115981 07-Jun-2003 scottl

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.


# 114329 30-Apr-2003 peter

Teach libdisk that AMD64 works just like i386


# 114300 30-Apr-2003 obrien

Only define platform once -- in a C file.


# 113083 04-Apr-2003 phk

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.


# 112333 17-Mar-2003 phk

Ignore GBDE devices.

Spotted by: Lucky Green <shamrock@cypherpunks.to>


# 109082 10-Jan-2003 jhb

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


# 108292 26-Dec-2002 nyan

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>


# 107011 17-Nov-2002 nyan

- Ease sanity check to get cylinders.
- Get the slice name from the result of kern.geom.conftxt.


# 106949 15-Nov-2002 nyan

Fixed style(9)


# 106837 13-Nov-2002 marcel

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.


# 106761 11-Nov-2002 phk

Remove debugging printfs.


# 106743 10-Nov-2002 marcel

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.


# 106633 08-Nov-2002 nyan

- Recognize FAT partition on MBR and PC98 disks.
- Fix to convert to the name of partition.


# 106621 08-Nov-2002 jhb

Don't set a value to a variable that we don't use.


# 106549 07-Nov-2002 nyan

Fixed pc98 support.
(merged i386 changes from chunk.c 1.41 and disk.c 1.100)


# 106368 02-Nov-2002 marcel

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.


# 106343 02-Nov-2002 marcel

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.


# 106337 02-Nov-2002 phk

Don't claim all MBR's have subtype 165 on i386.

Spotted by: Frode Nordahl <frode@nordahl.net>


# 106240 31-Oct-2002 phk

Set the sector size for the disk.


# 106238 31-Oct-2002 nyan

Restore to pc98 support.


# 106232 31-Oct-2002 jake

Actually save the bootblock in the disk structure. Write the bootblock
to the right place on the disk instead of srewn all over it.


# 106155 29-Oct-2002 phk

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


# 106135 29-Oct-2002 phk

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


# 106008 26-Oct-2002 peter

Add back ia64 support that was removed in the last few revisions.
I've cloned write_ia64_disk.c from write_i386_disk.c.


# 105873 24-Oct-2002 gallatin

#ifdef out assignToPartition on non x86 arches to unbreak the world
on alpha, sparc64 and ia64


# 105821 23-Oct-2002 phk

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.


# 105818 23-Oct-2002 phk

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...


# 105816 23-Oct-2002 phk

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.


# 105791 23-Oct-2002 nyan

- The GEOM system does not work on pc98.
- Fix to build w/o the HAVE_GEOM option.


# 105784 23-Oct-2002 phk

Add the new extra argument also in the alpha case.


# 105685 22-Oct-2002 phk

Avoid a lot of #ifdef PC98 code by giving a couple of the Chunk functions
an extra argument for all archs.


# 105681 22-Oct-2002 phk

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.


# 105652 21-Oct-2002 phk

Sigh, d_ntracks, not d_nheads.


# 105646 21-Oct-2002 phk

fwheads and fwsectors got swapped underway.

Approved by: sam


# 105575 20-Oct-2002 sam

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


# 105460 19-Oct-2002 sam

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


# 105349 17-Oct-2002 sam

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.


# 105348 17-Oct-2002 sam

correct arg order to strlcpy/strlcat under #ifdef alpha


# 105007 12-Oct-2002 kris

Use buffer-safe string functions for paranoia.


# 105005 12-Oct-2002 kris

Zero memory after malloc. This stops sysinstall from dumping core
during disk probing with malloc debugging enabled.

MFC after: 1 week


# 104674 08-Oct-2002 nyan

Fix to support pc98.


# 104272 01-Oct-2002 phk

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.


# 93149 25-Mar-2002 phk

Modernize my email address.


# 89081 08-Jan-2002 sheldonh

(null delta)

The previous delta was taken from:

PR: bin/33070


# 88448 23-Dec-2001 phk

Sort the disknames when we get them from the kernel.

Submitted by: <anarcat@anarcat.dyndns.org>


# 84965 15-Oct-2001 peter

Add EFI GPT (238, 0xEE) and EFI System Parition (239, 0xEF)


# 84200 30-Sep-2001 dillon

Add __FBSDID()s to libdisk


# 76551 13-May-2001 jkh

+ 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>


# 75069 01-Apr-2001 obrien

Add spaces around operators.
It's OK, the Project and afford them now -- they aren't as expensive as
they used to be.


# 75066 01-Apr-2001 obrien

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)


# 74426 18-Mar-2001 obrien

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


# 68409 06-Nov-2000 jkh

MFS: add ATA raid support for sysinstall


# 67417 21-Oct-2000 nyan

Use kern.disks sysctl on PC-98.


# 65801 13-Sep-2000 msmith

Teach libdisk about 'aac'


# 64555 12-Aug-2000 nyan

- Added support for installing boot0 and boot0.5 for PC-98.
- Cosmetic changes.


# 64379 08-Aug-2000 nyan

- Fixed warnings and typo.
- Recognize slice type 0x24 as FAT (only PC-98).

Submitted by: Nobuyuki Koganemaru <kogane@koganemaru.co.jp>


# 64324 07-Aug-2000 nyan

Don't use kern.disks sysctl on PC-98 because the wd driver doesn't call
disk_create() function.


# 63030 12-Jul-2000 jhb

- Allow support for MBR boot loaders that are longer than one sector. As
with fdisk, ensure that they are a multiple of the sector size in length.
- Axe all the 1024 cylinder checks as they are no longer relevant with the
fixed bootstrap.


# 62223 28-Jun-2000 jhb

_PATH_DEV'ify libdisk


# 62008 23-Jun-2000 nbm

Let Disk_Names() take advantage of the kern.disks sysctl if it's
available. If not, it falls back to the existing hack and slash method.

A positive side effect is that non-root users may now use Disk_Names(),
for non-dangerous libh/disk.tcl testing.

Reviewed by: phk


# 61279 05-Jun-2000 nyan

Re-support "wd" if PC98 is defined. Because PC-98 still uses the wd driver.


# 61101 30-May-2000 msmith

/dev/rXXX -> /dev/XXX

This should fix sysinstall and other tools that don't expect the 'r' devices
to exist anymore (and thus don't create them).


# 61093 30-May-2000 msmith

De-support 'wd'; with it making a dual appearance with 'ad', things
depending on libdisk to detect a list of actually-there disk devices
were providing duplicate entries (eg. sysinstall).


# 60908 25-May-2000 msmith

Teach libdisk about 'twe' disks.


# 60886 24-May-2000 jkh

catch up to the modern ATAPI disk naming conventions and add floppy
disks.

Submitted by: bde


# 59399 19-Apr-2000 obrien

Raw devices are now the normal device name, not prefixed with 'r'.


# 58794 29-Mar-2000 kato

Changes for PC-98.


# 57898 10-Mar-2000 imp

Fix fd leak in libdisk's Disk_Names()


# 57831 08-Mar-2000 jlemon

Correct device naming for IDA disk nodes (idad)


# 53784 27-Nov-1999 msmith

Remove 'sd' support. SCSI disks are known as 'da' these days.


# 52786 02-Nov-1999 msmith

Teach libdisk about the AMI and Mylex RAID drivers. You should be able
to install directly to arrays managed by these controllers now.


# 50476 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48585 05-Jul-1999 msmith

Merge from -stable; support for the 'ida' driver, move fla to major 102


# 46787 09-May-1999 dfr

Back out the last change to disk.c - a kernel change removed the need.
Enabled writing to the disklabel when writing a disk (only affects alpha).


# 46731 08-May-1999 dfr

Make libdisk see the existing partitiions on the alpha.


# 46455 04-May-1999 msmith

Clean up after another half-Danish.

Add 'ad' as another known disk driver of the same kind as 'wd'.


# 46079 25-Apr-1999 imp

More egcs warning fixes:
o use braces to avoid potentially ambiguous else
o don't default to type int (and also remove a useless register
modifier).
o Use parens around assignment values used as truth values.
o Remove unused function.

Reviewed by: obrien and chuckr


# 43393 29-Jan-1999 jkh

More support for Alpha installs.

Submitted by: dfr


# 41941 19-Dec-1998 phk

Add "fla" to Disk_Names()


# 40000 06-Oct-1998 dfr

Teach libdisk about alpha boot blocks.


# 39844 30-Sep-1998 jkh

Eliminate unaligned access on Alpha and also neaten up this code a little.
Submitted by: dfr


# 39252 15-Sep-1998 gibbs

Remove references to the "od" device.


# 36182 19-May-1998 obrien

Add new NetBSD FFS with FDISK partition ID 0xa9

Obtained from: Frank van der Linden <frank@wins.uva.nl>


# 36081 15-May-1998 obrien

Change an arbitarly hardcoded `10' to MAX_NO_DISKS, which is currently "20".
Otherwise can't see sd10 (obtained using wired down sd unit numbers),
reguardless of the number of actual disks you have.


# 34776 22-Mar-1998 jkh

Add Compaq & SCO partition types.
PR: 6092
Submitted by: Drew Derbyshire <ahd@kew.com>


# 34729 20-Mar-1998 jkh

MF22: teach about LS-120 devices.


# 34579 14-Mar-1998 ache

Add more AIX/DOS/Win95 partition types


# 34148 07-Mar-1998 ache

Add primary fat-32


# 34037 05-Mar-1998 obrien

Reconized OpenBSD partitions.


# 32558 16-Jan-1998 jkh

Non-intrusive changes to support Justin's CAM stuff.


# 22993 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21958 23-Jan-1997 obrien

Adds slice_type_name() which extends chunk_n[] for subtype's too.

Curorary review by: phk


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 20390 13-Dec-1996 jkh

Close PR#2198:

I've added an installation from optical disk drive facility.
This enables FreeBSD to be installed from an optical disk, which
may be formatted in "super floppy" style or sliced into MSDOS-FS
and UFS partitions.

Note: ncr.c should be reviewed by Stefan Esser <se@freebsd.org>
and cd.c by Joerg Wunsch <joerg@freebsd.org> before bringing this
into 2.2.

Submitted-By: Shunsuke Akiyama <akiyama@kme.mei.co.jp>


# 19989 27-Nov-1996 phk

Improve the Dangerously Dedidcated mode a bit. Not much, but a bit better.


# 15441 29-Apr-1996 jkh

Move some warn()'s into DEBUG space since I don't need them coming
out in my curses interfaces and spamming my screen.


# 14792 24-Mar-1996 joerg

Make libdisk C++ aware:

- add __BEGIN_DECLS and __END_DECLS,
- add a bunch of ``const'' qualifiers all over the place,
- rename the `private' struct member into `private_data' to avoid the
clash with the C++ keyword.


# 9202 11-Jun-1995 rgrimes

Merge RELENG_2_0_5 into HEAD


# 8881 30-May-1995 rgrimes

Remove trailing whitespace.


# 8346 08-May-1995 phk

Recognize slice type #6 as dos
handle OnTrack Disk manager correctly.


# 8303 06-May-1995 phk

General sanitation and cleanup. Killed the "reserved" type, it wasn't.


# 8264 04-May-1995 phk

Make the partitions names even more sensible
CheckRules sets the CHUNK_ALIGN & CHUNK_PAST_1024 flags.


# 8250 03-May-1995 phk

Add the private void *pointer to the chunks, and the functions to manage it.
Make the reassignment of partition names less bogus.


# 8241 03-May-1995 jkh

Export the chunk names properly.


# 8233 03-May-1995 phk

Make the target for tst01 more sensible.
Remove bogus targets.
Allocate partition letters as follows:
lowest offset "flags & CHUNK_IS_ROOT" gets 'a',
lowest offset "subtype==FS_SWAP" gets 'b'
the rest is allocated in offset order from this sequence "defghab".
This will generally make sense.
Added rules to complain if more than one CHUNK_IS_ROOT or more than one
FS_SWAP per FreeBSD chunk.
Set CHUNK_IS_ROOT on the 'a' partition in Open_Disk.
Run Fixup_Names in Open_Disk.


# 8228 02-May-1995 jkh

foo -> unknown


# 8227 02-May-1995 jkh

I need Open_Disk() to not spew on my screen. #ifdef out some diagnostic
printfs.


# 8196 01-May-1995 phk

start CHS is 0xff,0xff,0xff if past 1024.
end CHS is 1023,bios_hd,bios_sect if past 1024. This way we can find
bios the geometry again.
Added a primitive "scan" to tst01.


# 8192 30-Apr-1995 phk

Use the DIOCSYNCSLICE ioctl now. (use only with kernel from this morning).
Get the CHS's right.
Get the disklabels (more) right.


# 8183 30-Apr-1995 phk

get bootblocks right.
Add mbr and bteasy17 to tst01
read partitions from kernel instead of disk.
Still problems with writing labels, discussing with Bruce.
Extended slices doesn't get written yet.


# 8180 30-Apr-1995 phk

Use 0xff for CHS when past 1024 cyls.
Fix (hopefully) a bug Gary found.


# 8178 30-Apr-1995 phk

Now we do writes too.


# 8160 29-Apr-1995 phk

Names are assigned when chunks are created.
Rules for only one fat & one extended in MBR.


# 8158 29-Apr-1995 phk

Even More stuff. Disk_Names() is here amongst other things.


# 8157 29-Apr-1995 phk

Next Iteration, getting better.
Made an All_FreeBSD() function.
Added a cmd-line interface (lowest rank) to the tst01 program.
The tst01 program is harmless (worst it can do is coredump), but it
is instructive to run, you can see what the slice-code things of your
disk...


# 8156 28-Apr-1995 phk

Sanitize and explain a little bit... Implement the first rules...


# 8153 28-Apr-1995 phk

This is a revision 0.00 of the backend stuff for the fdisk/disklabel stuff
in the new sysinstall. If you want to give a helping hand, then send email
to phk@FreeBSD.ORG. DO NOT COMMIT TO THIS DIRECTORY!