libparted 3.6
|
PedGeometry represents a continuous region on a device. More...
Files | |
file | geom.h |
file | geom.h |
Data Structures | |
struct | _PedGeometry |
Geometry of the partition. More... | |
Macros | |
#define | _(String) (String) |
Typedefs | |
typedef struct _PedGeometry | PedGeometry |
typedef struct _PedGeometry | PedGeometry |
Functions | |
PedSector | ped_geometry_check (PedGeometry *geom, void *buffer, PedSector buffer_size, PedSector offset, PedSector granularity, PedSector count, PedTimer *timer) |
Checks for physical disk errors. | |
void | ped_geometry_destroy (PedGeometry *geom) |
Destroy a PedGeometry object. | |
PedGeometry * | ped_geometry_duplicate (const PedGeometry *geom) |
Duplicate a PedGeometry object. | |
int | ped_geometry_init (PedGeometry *geom, const PedDevice *dev, PedSector start, PedSector length) |
Initialize the previously allocated PedGeometry geom . | |
PedGeometry * | ped_geometry_intersect (const PedGeometry *a, const PedGeometry *b) |
Return a PedGeometry object that refers to the intersection of a and b . | |
PedSector | ped_geometry_map (const PedGeometry *dst, const PedGeometry *src, PedSector sector) |
This function takes a sector inside the region described by src, and returns that sector's address inside dst. | |
PedGeometry * | ped_geometry_new (const PedDevice *dev, PedSector start, PedSector length) |
Create a new PedGeometry object on disk , starting at start with a size of length sectors. | |
int | ped_geometry_read (const PedGeometry *geom, void *buffer, PedSector offset, PedSector count) |
Reads data from the region represented by geom . | |
int | ped_geometry_read_alloc (const PedGeometry *geom, void **buffer, PedSector offset, PedSector count) |
int | ped_geometry_set (PedGeometry *geom, PedSector start, PedSector length) |
Assign a new start , end (implicitly) and length to geom . | |
int | ped_geometry_set_end (PedGeometry *geom, PedSector end) |
Assign a new end to geom without changing geom->start . | |
int | ped_geometry_set_start (PedGeometry *geom, PedSector start) |
Assign a new start to geom without changing geom->end . | |
int | ped_geometry_sync (PedGeometry *geom) |
Flushes the cache on geom . | |
int | ped_geometry_sync_fast (PedGeometry *geom) |
Flushes the cache on geom . | |
int | ped_geometry_test_equal (const PedGeometry *a, const PedGeometry *b) |
Tests if a and b refer to the same physical region. | |
int | ped_geometry_test_inside (const PedGeometry *a, const PedGeometry *b) |
Tests if b lies completely within a . | |
int | ped_geometry_test_overlap (const PedGeometry *a, const PedGeometry *b) |
Test if a overlaps with b . | |
int | ped_geometry_test_sector_inside (const PedGeometry *geom, PedSector sector) |
Tests if sector is inside geom . | |
int | ped_geometry_write (PedGeometry *geom, const void *buffer, PedSector offset, PedSector count) |
Writes data into the region represented by geom . | |
PedGeometry represents a continuous region on a device.
All addressing through a PedGeometry object is in terms of the start of the continuous region.
The following conditions are always true on a PedGeometry object manipulated with the GNU Parted API:
start + length - 1 == end
length > 0
start >= 0
end < dev->length
#define _ | ( | String | ) | (String) |
typedef struct _PedGeometry PedGeometry |
typedef struct _PedGeometry PedGeometry |
PedSector ped_geometry_check | ( | PedGeometry * | geom, |
void * | buffer, | ||
PedSector | buffer_size, | ||
PedSector | offset, | ||
PedSector | granularity, | ||
PedSector | count, | ||
PedTimer * | timer | ||
) |
Checks for physical disk errors.
Checks a region for physical defects on geom
. buffer
is used for temporary storage for ped_geometry_check(), and has an undefined value. buffer
is buffer_size
sectors long. The region checked starts at offset
sectors inside the region represented by geom
, and is count
sectors long. granularity
specificies how sectors should be grouped together. The first bad sector to be returned will always be in the form: offset + n * granularity
void ped_geometry_destroy | ( | PedGeometry * | geom | ) |
Destroy a PedGeometry object.
PedGeometry * ped_geometry_duplicate | ( | const PedGeometry * | geom | ) |
Duplicate a PedGeometry object.
This function constructs a PedGeometry object that is an identical but independent copy of geom
. Both the input, geom
, and the output should be destroyed with ped_geometry_destroy() when they are no longer needed.
int ped_geometry_init | ( | PedGeometry * | geom, |
const PedDevice * | dev, | ||
PedSector | start, | ||
PedSector | length | ||
) |
Initialize the previously allocated PedGeometry geom
.
PedGeometry * ped_geometry_intersect | ( | const PedGeometry * | a, |
const PedGeometry * | b | ||
) |
Return a PedGeometry object that refers to the intersection of a
and b
.
This function constructs a PedGeometry object that describes the region that is common to both a and b. If there is no such common region, it returns NULL. (This situation is not treated as an error by much of GNU Parted.)
PedSector ped_geometry_map | ( | const PedGeometry * | dst, |
const PedGeometry * | src, | ||
PedSector | sector | ||
) |
This function takes a sector
inside the region described by src, and returns that sector's address inside dst.
This means that
does the same thing as
Clearly, this will only work if src
and dst
overlap.
sector
is not within dst's
space, or sector's
address inside dst
PedGeometry * ped_geometry_new | ( | const PedDevice * | dev, |
PedSector | start, | ||
PedSector | length | ||
) |
Create a new PedGeometry object on disk
, starting at start
with a size of length
sectors.
int ped_geometry_read | ( | const PedGeometry * | geom, |
void * | buffer, | ||
PedSector | offset, | ||
PedSector | count | ||
) |
Reads data from the region represented by geom
.
offset
is the location from within the region, not from the start of the disk. count
sectors are read into buffer
. This is essentially equivalent to:
PED_EXCEPTION_ERROR | when attempting to read sectors outside of partition |
int ped_geometry_read_alloc | ( | const PedGeometry * | geom, |
void ** | buffer, | ||
PedSector | offset, | ||
PedSector | count | ||
) |
int ped_geometry_set | ( | PedGeometry * | geom, |
PedSector | start, | ||
PedSector | length | ||
) |
Assign a new start
, end
(implicitly) and length
to geom
.
geom->end
is calculated from start
and length
.
int ped_geometry_set_end | ( | PedGeometry * | geom, |
PedSector | end | ||
) |
Assign a new end to geom
without changing geom->start
.
geom->length
is updated accordingly.
int ped_geometry_set_start | ( | PedGeometry * | geom, |
PedSector | start | ||
) |
Assign a new start to geom
without changing geom->end
.
geom->length
is updated accordingly.
int ped_geometry_sync | ( | PedGeometry * | geom | ) |
Flushes the cache on geom
.
This function flushes all write-behind caches that might be holding writes made by ped_geometry_write() to geom
. It is slow, because it guarantees cache coherency among all relevant caches.
int ped_geometry_sync_fast | ( | PedGeometry * | geom | ) |
Flushes the cache on geom
.
This function flushes all write-behind caches that might be holding writes made by ped_geometry_write() to geom
. It does NOT ensure cache coherency with other caches that cache data in the region described by geom
. If you need cache coherency, use ped_geometry_sync() instead.
int ped_geometry_test_equal | ( | const PedGeometry * | a, |
const PedGeometry * | b | ||
) |
Tests if a and b
refer to the same physical region.
a
and b
describe the same regions int ped_geometry_test_inside | ( | const PedGeometry * | a, |
const PedGeometry * | b | ||
) |
Tests if b
lies completely within a
.
That is, they lie on the same physical device, and all of the b's
region is contained inside a's
.
b
describes is contained entirely inside a
int ped_geometry_test_overlap | ( | const PedGeometry * | a, |
const PedGeometry * | b | ||
) |
Test if a
overlaps with b
.
That is, they lie on the same physical device, and they share the same physical region at least partially.
a
and b
overlap. int ped_geometry_test_sector_inside | ( | const PedGeometry * | geom, |
PedSector | sector | ||
) |
Tests if sector
is inside geom
.
region
that geom
describes int ped_geometry_write | ( | PedGeometry * | geom, |
const void * | buffer, | ||
PedSector | offset, | ||
PedSector | count | ||
) |
Writes data into the region represented by geom
.
offset
is the location from within the region, not from the start of the disk. count
sectors are written.