1996-03-17 23:20:09 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1996 Joerg Wunsch
|
|
|
|
.\"
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This program is free software.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1996-03-17 23:20:09 +00:00
|
|
|
.\" "
|
2006-01-30 08:26:59 +00:00
|
|
|
.Dd January 30, 2006
|
1996-03-17 23:20:09 +00:00
|
|
|
.Dt LIBDISK 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm Open_Disk ,
|
|
|
|
.Nm Free_Disk ,
|
|
|
|
.Nm Debug_Disk ,
|
|
|
|
.Nm Set_Bios_Geom ,
|
|
|
|
.Nm Delete_Chunk ,
|
|
|
|
.Nm Collapse_Disk ,
|
|
|
|
.Nm Collapse_Chunk ,
|
|
|
|
.Nm Create_Chunk ,
|
|
|
|
.Nm All_FreeBSD ,
|
|
|
|
.Nm CheckRules ,
|
|
|
|
.Nm Disk_Names ,
|
|
|
|
.Nm Set_Boot_Mgr ,
|
|
|
|
.Nm Set_Boot_Blocks ,
|
|
|
|
.Nm Write_Disk ,
|
|
|
|
.Nm Cyl_Aligned ,
|
|
|
|
.Nm Next_Cyl_Aligned ,
|
|
|
|
.Nm Prev_Cyl_Aligned ,
|
|
|
|
.Nm Track_Aligned ,
|
|
|
|
.Nm Next_Track_Aligned ,
|
|
|
|
.Nm Prev_Track_Aligned ,
|
|
|
|
.Nm Create_Chunk_DWIM ,
|
|
|
|
.Nm MakeDev ,
|
|
|
|
.Nm MakeDevDisk ,
|
|
|
|
.Nm ShowChunkFlags ,
|
2002-11-11 19:37:19 +00:00
|
|
|
.Nm chunk_name ,
|
1997-01-23 06:29:01 +00:00
|
|
|
.Nm slice_type_name
|
2000-04-22 15:58:49 +00:00
|
|
|
.Nd library interface to slice and partition labels
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libdisk
|
1996-03-17 23:20:09 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In libdisk.h
|
2000-12-29 14:08:20 +00:00
|
|
|
.Pp
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft struct disk *
|
1996-03-24 18:55:39 +00:00
|
|
|
.Fn Open_Disk "const char *devname"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn Free_Disk "struct disk *disk"
|
|
|
|
.Ft void
|
|
|
|
.Fn Debug_Disk "struct disk *disk"
|
|
|
|
.Ft void
|
|
|
|
.Fn Set_Bios_Geom "struct disk *disk" "u_long cyl" "u_long heads" "u_long sects"
|
|
|
|
.Ft int
|
|
|
|
.Fn Delete_Chunk "struct disk *disk" "struct chunk *"
|
|
|
|
.Ft void
|
|
|
|
.Fn Collapse_Disk "struct disk *disk"
|
|
|
|
.Ft int
|
|
|
|
.Fn Collapse_Chunk "struct disk *disk" "struct chunk *chunk"
|
|
|
|
.Ft int
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Create_Chunk "struct disk *disk" "daddr_t offset" "daddr_t size" "chunk_e type" "int subtype" "u_long flags" "const char *sname"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn All_FreeBSD "struct disk *d" "int force_all"
|
|
|
|
.Ft char *
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn CheckRules "const struct disk *"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft char **
|
|
|
|
.Fn Disk_Names "void"
|
|
|
|
.Ft void
|
2001-02-05 23:56:05 +00:00
|
|
|
.Fn Set_Boot_Mgr "struct disk *d" "const u_char *bootmgr" "const size_t bootmgr_size"
|
2001-10-03 03:49:48 +00:00
|
|
|
.Ft int
|
1996-03-24 18:55:39 +00:00
|
|
|
.Fn Set_Boot_Blocks "struct disk *d" "const u_char *boot1" "const u_char *boot2"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft int
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Write_Disk "const struct disk *d"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft int
|
2004-03-16 17:07:06 +00:00
|
|
|
.Fn Cyl_Aligned "struct disk *d" "daddr_t offset"
|
|
|
|
.Ft daddr_t
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Next_Cyl_Aligned "const struct disk *d" "daddr_t offset"
|
2004-03-16 17:07:06 +00:00
|
|
|
.Ft daddr_t
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Prev_Cyl_Aligned "const struct disk *d" "daddr_t offset"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft int
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Track_Aligned "const struct disk *d" "daddr_t offset"
|
2004-03-16 17:07:06 +00:00
|
|
|
.Ft daddr_t
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Next_Track_Aligned "const struct disk *d" "daddr_t offset"
|
2004-03-16 17:07:06 +00:00
|
|
|
.Ft daddr_t
|
2005-11-24 10:30:44 +00:00
|
|
|
.Fn Prev_Track_Aligned "const struct disk *d" "daddr_t offset"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft struct chunk *
|
2004-03-16 17:07:06 +00:00
|
|
|
.Fn Create_Chunk_DWIM "struct disk *d" "struct chunk *parent" "daddr_t size" "chunk_e type" "int subtype" "u_long flags"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft int
|
1996-03-24 18:55:39 +00:00
|
|
|
.Fn MakeDev "struct chunk *c" "const char *path"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft int
|
1996-03-24 18:55:39 +00:00
|
|
|
.Fn MakeDevDisk "struct disk *d" "const char *path"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ft char *
|
|
|
|
.Fn ShowChunkFlags "struct chunk *c"
|
2002-11-11 19:37:19 +00:00
|
|
|
.Ft const char *
|
|
|
|
.Fn chunk_name "chunk_e type"
|
|
|
|
.Ft const char *
|
|
|
|
.Fn slice_type_name "int type" "int subtype"
|
1996-03-17 23:20:09 +00:00
|
|
|
.Sh DESCRIPTION
|
2006-01-30 08:26:59 +00:00
|
|
|
.Bf Sy
|
2006-01-27 16:38:05 +00:00
|
|
|
.Nm libdisk
|
2006-01-30 08:26:59 +00:00
|
|
|
is just for the use of
|
2006-01-27 16:32:13 +00:00
|
|
|
.Xr sysinstall 8 .
|
2006-01-30 08:26:59 +00:00
|
|
|
You should consider using
|
2006-01-27 16:32:13 +00:00
|
|
|
.Xr libgeom 3
|
2006-01-30 08:26:59 +00:00
|
|
|
instead.
|
|
|
|
.Ef
|
2006-01-27 16:32:13 +00:00
|
|
|
.Pp
|
2003-03-24 16:01:01 +00:00
|
|
|
The
|
|
|
|
.Nm libdisk
|
|
|
|
library provides an interface to the low-level disk slice and partition labels.
|
1996-03-17 23:20:09 +00:00
|
|
|
Most functions operate with arguments of the types
|
|
|
|
.Ql struct disk ,
|
|
|
|
or
|
|
|
|
.Ql struct chunk .
|
|
|
|
.Pp
|
|
|
|
While both types are mostly opaque to the programmer, the internal
|
|
|
|
structure is mentioned below for the sake of completeness.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct disk {
|
|
|
|
char *name;
|
|
|
|
u_long flags;
|
|
|
|
u_long bios_cyl;
|
|
|
|
u_long bios_hd;
|
|
|
|
u_long bios_sect;
|
|
|
|
u_char *bootmgr;
|
|
|
|
u_char *boot1;
|
|
|
|
u_char *boot2;
|
|
|
|
struct chunk *chunks;
|
2001-05-13 20:08:54 +00:00
|
|
|
u_long sector_size;
|
1996-03-17 23:20:09 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
The only flag value by now is
|
|
|
|
.Ql DISK_ON_TRACK ,
|
|
|
|
meaning that this disk is handled by the On-Track Disk Manager.
|
|
|
|
.Pp
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct chunk {
|
|
|
|
struct chunk *next;
|
|
|
|
struct chunk *part;
|
|
|
|
struct disk *disk;
|
2004-03-16 17:07:06 +00:00
|
|
|
daddr_t offset;
|
|
|
|
daddr_t size;
|
|
|
|
daddr_t end;
|
1996-03-17 23:20:09 +00:00
|
|
|
char *name;
|
|
|
|
char *oname;
|
|
|
|
chunk_e type;
|
|
|
|
int subtype;
|
|
|
|
u_long flags;
|
|
|
|
void (*private_free)(void*);
|
|
|
|
void *(*private_clone)(void*);
|
1996-03-24 18:55:39 +00:00
|
|
|
void *private_data;
|
1996-03-17 23:20:09 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
The
|
|
|
|
.Ql type
|
|
|
|
field can be one of the following values:
|
|
|
|
.Ql whole, unknown, fat, freebsd, extended, part, unused .
|
|
|
|
.Pp
|
|
|
|
These are the valid
|
2004-12-29 02:18:24 +00:00
|
|
|
.Ql flags
|
1996-03-17 23:20:09 +00:00
|
|
|
values for a
|
|
|
|
.Ql struct chunk .
|
|
|
|
.Bl -tag -offset indent -width CHUNK_BSD_COMPATXX
|
|
|
|
.It CHUNK_PAST_1024
|
|
|
|
This chunk cannot be booted from because it extends past cylinder 1024.
|
|
|
|
.It CHUNK_BSD_COMPAT
|
2001-08-14 10:01:54 +00:00
|
|
|
This chunk is in the
|
|
|
|
.Bx Ns -compatibility ,
|
|
|
|
and has a short name too, i.e.\&
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ql wd0s4f -> wd0f .
|
|
|
|
.It CHUNK_ALIGN
|
|
|
|
This chunk should be aligned.
|
|
|
|
.It CHUNK_IS_ROOT
|
|
|
|
This
|
|
|
|
.Ql part
|
|
|
|
is a rootfs, allocate partition
|
|
|
|
.Sq a .
|
|
|
|
.It CHUNK_ACTIVE
|
|
|
|
This is the active slice in the MBR.
|
|
|
|
.It CHUNK_FORCE_ALL
|
2001-07-15 07:53:42 +00:00
|
|
|
Force a dedicated disk for
|
1999-10-28 15:42:48 +00:00
|
|
|
.Fx ,
|
|
|
|
bypassing all BIOS geometry considerations.
|
1996-03-17 23:20:09 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
1996-03-24 18:55:39 +00:00
|
|
|
.Ql private_data ,
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ql private_free ,
|
|
|
|
and
|
|
|
|
.Ql private_clone
|
|
|
|
fields are for data private to the application, and the management
|
2004-07-02 23:52:20 +00:00
|
|
|
thereof.
|
|
|
|
If the functions are not provided, no storage management is
|
1996-03-17 23:20:09 +00:00
|
|
|
done, cloning will just copy the pointer and freeing will just forget
|
|
|
|
it.
|
|
|
|
.Pp
|
|
|
|
.Fn Open_Disk
|
|
|
|
will open the named disk, and return populated tree.
|
|
|
|
.Pp
|
|
|
|
.Fn Free_Disk
|
|
|
|
frees a tree made with
|
|
|
|
.Fn Open_Disk
|
|
|
|
or
|
|
|
|
.Fn Clone_Disk .
|
|
|
|
.Pp
|
|
|
|
.Fn Debug_Disk
|
2002-12-04 18:57:46 +00:00
|
|
|
prints the content of the tree to
|
|
|
|
.Dv stdout .
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
|
|
|
.Fn Set_Bios_Geom
|
|
|
|
sets the geometry the bios uses.
|
|
|
|
.Pp
|
|
|
|
.Fn Delete_Chunk
|
|
|
|
frees a chunk of disk_space.
|
|
|
|
.Pp
|
1999-10-28 15:42:48 +00:00
|
|
|
.Fn Collapse_Disk
|
1996-03-17 23:20:09 +00:00
|
|
|
and
|
|
|
|
.Fn Collapse_Chunk
|
|
|
|
are experimental, do not use.
|
|
|
|
.Pp
|
|
|
|
.Fn Create_Chunk
|
1998-06-06 05:50:53 +00:00
|
|
|
creates a chunk with the specified parameters.
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
|
|
|
.Fn All_FreeBSD
|
2000-11-14 11:20:58 +00:00
|
|
|
makes one
|
|
|
|
.Fx
|
|
|
|
chunk covering the entire disk; if
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ql force_all
|
|
|
|
is set, bypass all BIOS geometry considerations.
|
|
|
|
.Pp
|
|
|
|
.Fn CheckRules
|
|
|
|
returns
|
|
|
|
.Ql char*
|
|
|
|
to warnings about broken design rules in this disklayout.
|
|
|
|
.Pp
|
|
|
|
.Fn Disk_Names
|
|
|
|
returns
|
|
|
|
.Ql char**
|
2004-07-02 23:52:20 +00:00
|
|
|
with all disk's names (wd0, wd1 ...).
|
|
|
|
You must free each pointer, as
|
1996-03-17 23:20:09 +00:00
|
|
|
well as the array by hand.
|
|
|
|
.Pp
|
|
|
|
.Fn Set_Boot_Mgr
|
2004-07-02 23:52:20 +00:00
|
|
|
sets this boot-manager for use on this disk.
|
|
|
|
Gets written when
|
1996-03-17 23:20:09 +00:00
|
|
|
.Fn Write_Disk
|
|
|
|
is called.
|
|
|
|
.Pp
|
|
|
|
.Fn Set_Boot_Blocks
|
2004-07-02 23:52:20 +00:00
|
|
|
sets the boot-blocks for use on this disk.
|
|
|
|
Gets written when
|
1996-03-17 23:20:09 +00:00
|
|
|
.Fn Write_Disk
|
1998-12-31 02:35:43 +00:00
|
|
|
is called.
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
|
|
|
.Fn Write_Disk
|
|
|
|
writes all the MBRs, disklabels, bootblocks and boot managers.
|
|
|
|
.Pp
|
|
|
|
.Fn Cyl_Aligned
|
|
|
|
checks if
|
|
|
|
.Ql offset
|
1999-10-28 15:42:48 +00:00
|
|
|
is aligned on a cylinder according to the BIOS geometry.
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
|
|
|
.Fn Next_Cyl_Aligned
|
|
|
|
rounds
|
|
|
|
.Ql offset
|
|
|
|
up to next cylinder according to the BIOS geometry.
|
|
|
|
.Pp
|
|
|
|
.Fn Prev_Cyl_Aligned
|
|
|
|
rounds
|
|
|
|
.Ql offset
|
|
|
|
down to previous cylinder according to the BIOS geometry.
|
|
|
|
.Pp
|
|
|
|
.Fn Track_Aligned
|
|
|
|
checks if
|
|
|
|
.Ql offset
|
|
|
|
is aligned on a track according to the BIOS geometry.
|
|
|
|
.Pp
|
|
|
|
.Fn Next_Track_Aligned
|
|
|
|
rounds
|
|
|
|
.Ql offset
|
|
|
|
up to next track according to the BIOS geometry.
|
|
|
|
.Pp
|
|
|
|
.Fn Prev_Track_Aligned
|
2004-12-29 02:18:24 +00:00
|
|
|
rounds
|
1996-03-17 23:20:09 +00:00
|
|
|
.Ql offset
|
2004-12-29 02:18:24 +00:00
|
|
|
up to previous track according to the BIOS geometry.
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
|
|
|
.Fn Create_Chunk_DWIM
|
|
|
|
creates a partition inside the given parent of the given size, and
|
2004-07-02 23:52:20 +00:00
|
|
|
returns a pointer to it.
|
|
|
|
The first unused chunk big enough is used.
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
|
|
|
.Fn MakeDev
|
|
|
|
makes the device nodes for this chunk.
|
|
|
|
.Pp
|
|
|
|
.Fn MakeDevDisk
|
|
|
|
makes the device nodes for all chunks on this disk.
|
|
|
|
.Pp
|
|
|
|
.Fn ShowChunkFlags
|
|
|
|
returns a string to show flags.
|
|
|
|
.Pp
|
2002-11-11 19:37:19 +00:00
|
|
|
The
|
|
|
|
.Fn chunk_name
|
|
|
|
function takes the enumerated chunk type and returns its name.
|
|
|
|
.Fn chunk_name
|
|
|
|
replaces the old external array
|
1997-01-23 06:29:01 +00:00
|
|
|
.Va chunk_n .
|
|
|
|
.Pp
|
|
|
|
.Fn slice_type_name
|
2001-07-15 07:53:42 +00:00
|
|
|
returns the name strings associated with the specified
|
1997-01-23 06:29:01 +00:00
|
|
|
.Ql type .
|
|
|
|
.Ql subtype .
|
|
|
|
If
|
|
|
|
.Fn slice_type_name
|
2005-02-13 22:25:33 +00:00
|
|
|
returns "unknown" for slices it is not familiar with.
|
1998-03-19 07:34:22 +00:00
|
|
|
.Sh AUTHORS
|
2000-11-22 09:23:54 +00:00
|
|
|
.An -nosplit
|
|
|
|
The
|
|
|
|
.Nm libdisk
|
|
|
|
library was written by
|
1998-03-19 07:34:22 +00:00
|
|
|
.An Poul-Henning Kamp .
|
1996-03-17 23:20:09 +00:00
|
|
|
.Pp
|
2000-11-22 09:23:54 +00:00
|
|
|
This manual page was written by
|
2000-11-10 17:46:15 +00:00
|
|
|
.An J\(:org Wunsch .
|