1 ===============================================================================
3 ===============================================================================
12 <<< This file is deprecated and being converted
13 to Doxygen in-line documentation.
14 Until this is finished, both are incomplete
15 but fully document the API together. >>>
18 ( scroll down to read )
24 by Andrew Clausen <clausen@gnu.org>,
25 Leslie P. Polzer <polzer@gnu.org>
27 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
28 Free Software Foundation, Inc.
30 Permission is granted to copy, distribute and/or modify this document
31 under the terms of the GNU Free Documentation License, Version 1.3
32 or any later version published by the Free Software Foundation;
33 with the no Invariant Sections, with the no Front-Cover Texts, and
34 with no Back-Cover Texts. A copy of the license is included in the
42 2 Initialising libparted
44 4 PedDisk, PedDiskType
46 6 PedPartition, PedPartitionType
47 7 PedFileSystem, PedFileSystemType
48 8 PedConstraint, PedAlignment
53 -------------------------------------------------------------------------------
55 -------------------------------------------------------------------------------
57 GNU Parted is built on top of libparted, which does all of the real work.
58 libparted provides an API capable of manipulating partition tables, and
59 the filesystems on them.
61 The main motivation for separating the back-end into a separate library was
62 to encourage different GNU/Linux distributions to encorporate their own
63 customized front-end into the install process.
65 This documents the API -- not the implementation details of libparted.
66 Documentation that is not relevant to programs using the API are marked with
67 INTERNAL. Apart from this file, a good place to look would be
68 parted/parted.c, the front-end's source, and the TUTORIAL file (not finished
71 This documentation isn't as complete as it should be. Feel free to ask
72 questions, either to me personally (clausen@gnu.org), or to the mailing list
77 Some of the terminology is a bit weird, so you might want to read this.
79 CONSTRAINT a set of conditions that must be satisfied, for
80 a given GEOMETRY of a PARTITION.
82 DEVICE a storage device.
84 DISK a storage device, with a valid partition table.
86 EXCEPTION an event that needs attention.
88 EXTENDED PARTITION a PRIMARY PARTITION, that may contain LOGICAL
89 PARTITIONS instead of a file system. There is at most
90 one extended partition.
92 FILE SYSTEM any data that resides on a partition. For the purposes
93 for GNU Parted, this includes swap devices.
95 GEOMETRY a description of a continuous region on a disk. eg,
96 partitions have a geometry.
98 HIDDEN PARTITION a partition that is hidden from MS operating systems.
99 Only FAT partitions may be hidden.
101 LOGICAL PARTITION like normal partitions, but they lie inside the
104 PARTITION a continuous region on a disk where a file system may
107 PRIMARY PARTITION a normal, vanilla, partition.
109 PARTITION TABLE also, DISK LABEL. A description of where the
110 partitions lie, and information about those partitions.
111 For example, what type of file system resides on them.
112 The partition table is usually at the start of the
115 TIMER a progress meter. It is an entity that keeps track
116 of time, and who to inform when something interesting
121 libparted has a fairly object-oriented design. The most important objects are:
123 PedArchitecture describes support for an "archicture", which is sort
124 of like "operating system", but could also be,
125 for example, another libparted environment, EVMS, etc.
126 PedConstraint a constraint on the geometry of a partition
127 PedDevice a storage device
128 PedDisk a device + partition table
129 PedFileSystem a filesystem, associated with a PedGeometry, NOT a
131 PedGeometry a continious region on a device
132 PedPartition a partition (basically PedGeometry plus some attributes)
133 PedTimer a timer keeps track of progress and time
135 All functions return 0 (or NULL) on failure and non-zero (or non-NULL) on
136 success. If a function fails, an exception is thrown. This may be handled by
137 either an exception handler, or the calling function (see the section on
140 All objects should be considered read-only; they should only be modified by
141 calls to libparted's API.
143 -------------------------------------------------------------------------------
144 2 INITIALISING LIBPARTED
145 -------------------------------------------------------------------------------
147 Headers for libparted can be included with:
149 #include <parted/parted.h>
151 Parted automatically initialises itself via an __attribute__ ((constructor))
154 However, you might want to set the exception handler with
155 ped_exception_set_handler(). libparted does come with a default exception
156 handler, if you're feeling lazy.
158 Here's a minimal example:
160 #include <parted/parted.h>
165 /* automatically initialized */
166 ped_exception_set_handler(exception_handler); /* see section 7 */
168 /* automatically cleaned up */
171 -----------------------------------------------------------------------------
173 -----------------------------------------------------------------------------
182 -----------------------------------------------------------------------------
183 6 PEDPARTITION, PEDPARTITIONTYPE
184 -----------------------------------------------------------------------------
186 interface: <parted/disk.h>
187 implementation: libparted/disk.c
189 A PedPartition represents a partition (surprise!). PedPartitions have weird
190 relationships with PedDisks. Hence, many functions for manipulating partitions
191 will be called ped_disk_* - so have a look at the PedDisk documentation as well.
193 Parted creates "imaginary" free space and metadata partitions. You can't
194 do any operations on these partitions (like set_geometry, {set,get}_flag, etc.)
195 Partitions that are not free space or metadata partitions are said to
196 be "active" partitions. You can use ped_partition_is_active() to check.
206 -----------------------------------------------------------------------------
207 7 PEDFILESYSTEM, PEDFILESYSTEMTYPE
208 -----------------------------------------------------------------------------
219 -----------------------------------------------------------------------------
220 8 PEDCONSTRAINT, PEDALIGNMENT
221 -----------------------------------------------------------------------------
224 "Alignments" are restrictions on the location of a sector in the form of:
226 sector = offset + X * grain_size
228 For example, logical partitions on msdos disk labels usually have a constraint
229 with offset = 63 and grain_size = 16065 (Long story!). An important
230 (and non-obvious!) property of alignment restrictions is they are closed
231 under intersection, i.e. if you take two constraints, like (offset, grain_size)
232 = (63, 16065) and (0, 4), then either:
233 * there are no valid solutions
234 * all solutions can be expressed in the form of (offset + X * grain_size)
235 In the example, the intersection of the constraint is (16128, 64260).
237 For more information on the maths, see the source -- there's a large comment
238 containing proofs above ped_alignment_intersect() in libparted/natmath.c
240 The restrictions on the location of the start and end are in the form of
241 PedGeometry objects -- continous regions in which the start and end must lie.
242 Obviously, these restrictions are also closed under intersection.
244 The other restriction -- the minimum size -- is also closed under intersection.
245 (The intersection of 2 minimum size restrictions is the maximum of the
248 FIXME: mention ped_alignment_any
255 -----------------------------------------------------------------------------
257 -----------------------------------------------------------------------------
262 typedef void PedTimerHandler (PedTimer* timer, void* context);
269 -----------------------------------------------------------------------------
271 -----------------------------------------------------------------------------
281 -----------------------------------------------------------------------------
283 -----------------------------------------------------------------------------