PedGeometry

PedGeometry represents a continuous region on a device. More...

Files

file  geom.h

Data Structures

struct  _PedGeometry
 Geometry of the partition. More...

Defines

#define _(String)   (String)

Typedefs

typedef _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.
PedGeometryped_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.
PedGeometryped_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.
PedGeometryped_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_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.

Detailed Description

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:


Function Documentation

PedSector ped_geometry_check ( PedGeometry geom,
void *  buffer,
PedSector  buffer_size,
PedSector  offset,
PedSector  granularity,
PedSector  count,
PedTimer *  timer 
)

Checks for physical disk errors.

Todo:
use ped_device_check()
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

Returns:
the first bad sector, or 0 if there were no physical errors

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.

Returns:
NULL on failure.

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

        ped_geometry_read (dst, buf, ped_geometry_map(dst, src, sector), 1)

does the same thing as

        ped_geometry_read (src, buf, sector, 1)

Clearly, this will only work if src and dst overlap.

Returns:
-1 if 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.

Returns:
NULL on failure.

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_device_read (geom->disk->dev, buffer, geom->start + offset, count)

Exceptions:
PED_EXCEPTION_ERROR when attempting to read sectors outside of partition
Returns:
0 on failure

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.

Returns:
0 on failure

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.

Returns:
0 on failure

int ped_geometry_test_equal ( const PedGeometry a,
const PedGeometry b 
)

Tests if a and b refer to the same physical region.

Returns:
1 if 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.

Returns:
1 if the region 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.

Returns:
1 if a and b overlap.

int ped_geometry_test_sector_inside ( const PedGeometry geom,
PedSector  sector 
)

Tests if sector is inside geom.

Returns:
1 if sector lies within the 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.

Returns:
0 on failure


Generated on Fri May 4 05:15:31 2007 for libparted by  doxygen 1.5.2