FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 10-29-2009, 12:39 PM
Hans de Goede
 
Default libparted: add ped_device_get_xxx_aligned_constraint() functions

Add ped_device_get_minimal_aligned_constraint() and
ped_device_get_optimal_aligned_constraint() functions to libparted.

These functions can be used to get a device constraint taking alignment into
account.
---
include/parted/device.h | 5 +++
libparted/device.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/include/parted/device.h b/include/parted/device.h
index 7c34081..2a6c51b 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -146,6 +146,11 @@ extern PedSector ped_device_check (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern PedConstraint* ped_device_get_constraint (PedDevice* dev);

+extern PedConstraint *ped_device_get_minimal_aligned_constraint(
+ const PedDevice *dev);
+extern PedConstraint *ped_device_get_optimal_aligned_constraint(
+ const PedDevice *dev);
+
extern PedAlignment *ped_device_get_minimal_aligment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimal_aligment(const PedDevice *dev);

diff --git a/libparted/device.c b/libparted/device.c
index 6210a23..c53c202 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -445,6 +445,75 @@ ped_device_get_constraint (PedDevice* dev)
return c;
}

+static PedConstraint*
+_ped_device_get_aligned_constraint(const PedDevice *dev,
+ PedAlignment* start_align)
+{
+ PedAlignment *end_align = NULL;
+ PedGeometry *whole_dev_geom = NULL;
+ PedConstraint *c = NULL;
+
+ if (start_align) {
+ end_align = ped_alignment_new(start_align->offset - 1,
+ start_align->grain_size);
+ if (!end_align)
+ goto free_start_align;
+ }
+
+ whole_dev_geom = ped_geometry_new (dev, 0, dev->length);
+
+ if (start_align)
+ c = ped_constraint_new (start_align, end_align,
+ whole_dev_geom, whole_dev_geom,
+ 1, dev->length);
+ else
+ c = ped_constraint_new (ped_alignment_any, ped_alignment_any,
+ whole_dev_geom, whole_dev_geom,
+ 1, dev->length);
+
+ free (whole_dev_geom);
+ free (end_align);
+free_start_align:
+ free (start_align);
+ return c;
+}
+
+/**
+ * Get a constraint that represents hardware requirements on geometry and
+ * alignment.
+ *
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk and the minimal alignment requirements for proper
+ * performance of the disk.
+ *
+ *
eturn NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
+ */
+PedConstraint*
+ped_device_get_minimal_aligned_constraint(const PedDevice *dev)
+{
+ return _ped_device_get_aligned_constraint(dev,
+ ped_device_get_minimal_aligment(dev));
+}
+
+/**
+ * Get a constraint that represents hardware requirements on geometry and
+ * alignment.
+ *
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk and the alignment requirements for optimal
+ * performance of the disk.
+ *
+ *
eturn NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
+ */
+PedConstraint*
+ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
+{
+ return _ped_device_get_aligned_constraint(dev,
+ ped_device_get_optimal_aligment(dev));
+}
+
/**
* Get an alignment that represents minimum hardware requirements on aligment.
* When for example using media that has a physical sector size that is a
--
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 10-29-2009, 02:26 PM
Hans de Goede
 
Default libparted: add ped_device_get_xxx_aligned_constraint() functions

Add ped_device_get_minimal_aligned_constraint() and
ped_device_get_optimal_aligned_constraint() functions to libparted.

These functions can be used to get a device constraint taking alignment into
account.
---
include/parted/device.h | 5 +++
libparted/device.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/include/parted/device.h b/include/parted/device.h
index 5095b18..3580c2a 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -146,6 +146,11 @@ extern PedSector ped_device_check (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern PedConstraint* ped_device_get_constraint (PedDevice* dev);

+extern PedConstraint *ped_device_get_minimal_aligned_constraint(
+ const PedDevice *dev);
+extern PedConstraint *ped_device_get_optimal_aligned_constraint(
+ const PedDevice *dev);
+
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);

diff --git a/libparted/device.c b/libparted/device.c
index 483011a..cd10a91 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -445,6 +445,75 @@ ped_device_get_constraint (PedDevice* dev)
return c;
}

+static PedConstraint*
+_ped_device_get_aligned_constraint(const PedDevice *dev,
+ PedAlignment* start_align)
+{
+ PedAlignment *end_align = NULL;
+ PedGeometry *whole_dev_geom = NULL;
+ PedConstraint *c = NULL;
+
+ if (start_align) {
+ end_align = ped_alignment_new(start_align->offset - 1,
+ start_align->grain_size);
+ if (!end_align)
+ goto free_start_align;
+ }
+
+ whole_dev_geom = ped_geometry_new (dev, 0, dev->length);
+
+ if (start_align)
+ c = ped_constraint_new (start_align, end_align,
+ whole_dev_geom, whole_dev_geom,
+ 1, dev->length);
+ else
+ c = ped_constraint_new (ped_alignment_any, ped_alignment_any,
+ whole_dev_geom, whole_dev_geom,
+ 1, dev->length);
+
+ free (whole_dev_geom);
+ free (end_align);
+free_start_align:
+ free (start_align);
+ return c;
+}
+
+/**
+ * Get a constraint that represents hardware requirements on geometry and
+ * alignment.
+ *
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk and the minimal alignment requirements for proper
+ * performance of the disk.
+ *
+ *
eturn NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
+ */
+PedConstraint*
+ped_device_get_minimal_aligned_constraint(const PedDevice *dev)
+{
+ return _ped_device_get_aligned_constraint(dev,
+ ped_device_get_minimum_alignment(dev));
+}
+
+/**
+ * Get a constraint that represents hardware requirements on geometry and
+ * alignment.
+ *
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk and the alignment requirements for optimal
+ * performance of the disk.
+ *
+ *
eturn NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
+ */
+PedConstraint*
+ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
+{
+ return _ped_device_get_aligned_constraint(dev,
+ ped_device_get_optimum_alignment(dev));
+}
+
/**
* Get an alignment that represents minimum hardware requirements on alignment.
* When for example using media that has a physical sector size that is a
--
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 10-30-2009, 10:59 AM
Hans de Goede
 
Default libparted: add ped_device_get_xxx_aligned_constraint() functions

Add ped_device_get_minimal_aligned_constraint() and
ped_device_get_optimal_aligned_constraint() functions to libparted.

These functions can be used to get a device constraint taking alignment into
account.
---
include/parted/device.h | 5 +++
libparted/device.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/include/parted/device.h b/include/parted/device.h
index 5095b18..3580c2a 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -146,6 +146,11 @@ extern PedSector ped_device_check (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern PedConstraint* ped_device_get_constraint (PedDevice* dev);

+extern PedConstraint *ped_device_get_minimal_aligned_constraint(
+ const PedDevice *dev);
+extern PedConstraint *ped_device_get_optimal_aligned_constraint(
+ const PedDevice *dev);
+
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);

diff --git a/libparted/device.c b/libparted/device.c
index 483011a..cd10a91 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -445,6 +445,75 @@ ped_device_get_constraint (PedDevice* dev)
return c;
}

+static PedConstraint*
+_ped_device_get_aligned_constraint(const PedDevice *dev,
+ PedAlignment* start_align)
+{
+ PedAlignment *end_align = NULL;
+ PedGeometry *whole_dev_geom = NULL;
+ PedConstraint *c = NULL;
+
+ if (start_align) {
+ end_align = ped_alignment_new(start_align->offset - 1,
+ start_align->grain_size);
+ if (!end_align)
+ goto free_start_align;
+ }
+
+ whole_dev_geom = ped_geometry_new (dev, 0, dev->length);
+
+ if (start_align)
+ c = ped_constraint_new (start_align, end_align,
+ whole_dev_geom, whole_dev_geom,
+ 1, dev->length);
+ else
+ c = ped_constraint_new (ped_alignment_any, ped_alignment_any,
+ whole_dev_geom, whole_dev_geom,
+ 1, dev->length);
+
+ free (whole_dev_geom);
+ free (end_align);
+free_start_align:
+ free (start_align);
+ return c;
+}
+
+/**
+ * Get a constraint that represents hardware requirements on geometry and
+ * alignment.
+ *
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk and the minimal alignment requirements for proper
+ * performance of the disk.
+ *
+ *
eturn NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
+ */
+PedConstraint*
+ped_device_get_minimal_aligned_constraint(const PedDevice *dev)
+{
+ return _ped_device_get_aligned_constraint(dev,
+ ped_device_get_minimum_alignment(dev));
+}
+
+/**
+ * Get a constraint that represents hardware requirements on geometry and
+ * alignment.
+ *
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk and the alignment requirements for optimal
+ * performance of the disk.
+ *
+ *
eturn NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
+ */
+PedConstraint*
+ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
+{
+ return _ped_device_get_aligned_constraint(dev,
+ ped_device_get_optimum_alignment(dev));
+}
+
/**
* Get an alignment that represents minimum hardware requirements on alignment.
* When for example using media that has a physical sector size that is a
--
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:28 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org