libparted 3.6
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Typedefs | Functions
PedGeometry

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

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:

Macro Definition Documentation

◆ _

#define _ (   String)    (String)

Typedef Documentation

◆ PedGeometry [1/2]

typedef struct _PedGeometry PedGeometry

◆ PedGeometry [2/2]

typedef struct _PedGeometry PedGeometry

Function Documentation

◆ ped_geometry_check()

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

◆ ped_geometry_destroy()

void ped_geometry_destroy ( PedGeometry geom)

Destroy a PedGeometry object.

◆ ped_geometry_duplicate()

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.

◆ ped_geometry_init()

int ped_geometry_init ( PedGeometry geom,
const PedDevice dev,
PedSector  start,
PedSector  length 
)

Initialize the previously allocated PedGeometry geom.

◆ ped_geometry_intersect()

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

◆ ped_geometry_map()

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)
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 in...
Definition: geom.c:467
int ped_geometry_read(const PedGeometry *geom, void *buffer, PedSector offset, PedSector count)
Reads data from the region represented by geom.
Definition: geom.c:283
uint8_t sector
Definition: pc98.c:7

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

◆ ped_geometry_new()

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.

◆ ped_geometry_read()

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)
offset
Definition: fdasd.h:264
int ped_device_read(const PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition: device.c:326
Exceptions
PED_EXCEPTION_ERRORwhen attempting to read sectors outside of partition
Returns
0 on failure

◆ ped_geometry_read_alloc()

int ped_geometry_read_alloc ( const PedGeometry geom,
void **  buffer,
PedSector  offset,
PedSector  count 
)

◆ ped_geometry_set()

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.

◆ ped_geometry_set_end()

int ped_geometry_set_end ( PedGeometry geom,
PedSector  end 
)

Assign a new end to geom without changing geom->start.

geom->length is updated accordingly.

◆ ped_geometry_set_start()

int ped_geometry_set_start ( PedGeometry geom,
PedSector  start 
)

Assign a new start to geom without changing geom->end.

geom->length is updated accordingly.

◆ ped_geometry_sync()

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

◆ ped_geometry_sync_fast()

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

◆ ped_geometry_test_equal()

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

◆ ped_geometry_test_inside()

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

◆ ped_geometry_test_overlap()

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.

◆ ped_geometry_test_sector_inside()

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

◆ ped_geometry_write()

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