summaryrefslogtreecommitdiff
path: root/libparted/arch
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-01-05 20:48:19 +0100
committerJim Meyering <meyering@redhat.com>2012-01-05 20:48:31 +0100
commitb6ef0215a241e59ddcd14d5a2f85ac3243bd465d (patch)
treed046123520bb3d4315359955cbe69a49db6610df /libparted/arch
parent9b9913a315fb739fb8b886e84c8dd137539faacf (diff)
downloadparted-b6ef0215a241e59ddcd14d5a2f85ac3243bd465d.tar.gz
libparted: remove _blkpg_get_partition
[I applied Phillip's initial patch, omitting both my adjustments and his own v2 changes. This addresses both of those omissions. ] * libparted/arch/linux.c (_blkpg_get_partition): Remove function and sole use, per patch from Phillip Susi. (_kernel_get_partition_start_and_length): Adjust formatting, remove unnecessary test and correct a diagnostic.
Diffstat (limited to 'libparted/arch')
-rw-r--r--libparted/arch/linux.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 6d7fc56..e2c4139 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2410,24 +2410,6 @@ _blkpg_remove_partition (PedDisk* disk, int n)
BLKPG_DEL_PARTITION);
}
-#ifdef BLKPG_GET_PARTITION
-static int
-_blkpg_get_partition (PedPartition *part, long long *start, long long *length)
-{
- struct blkpg_partition linux_part;
-
- memset (&linux_part, 0, sizeof (linux_part));
- linux_part.pno = part->num;
- if (_blkpg_part_command (part->disk->dev, &linux_part,
- BLKPG_GET_PARTITION)) {
- *start = linux_part.start;
- *length = linux_part.length;
- return 1;
- } else
- return 0;
-}
-#endif
-
/* Read the integer from /sys/block/DEV_BASE/ENTRY and set *VAL
to that value, where DEV_BASE is the last component of DEV->path.
Upon success, return true. Otherwise, return false. */
@@ -2456,7 +2438,7 @@ _sysfs_int_entry_from_dev(PedDevice const* dev, const char *entry, int *val)
Upon success, return true. Otherwise, return false. */
static bool
_sysfs_ull_entry_from_part(PedPartition const* part, const char *entry,
- unsigned long long *val)
+ unsigned long long *val)
{
char path[128];
char *part_name = linux_partition_get_path(part);
@@ -2487,28 +2469,18 @@ _sysfs_ull_entry_from_part(PedPartition const* part, const char *entry,
return false. */
static bool
_kernel_get_partition_start_and_length(PedPartition const *part,
- unsigned long long *start,
- unsigned long long *length)
+ unsigned long long *start,
+ unsigned long long *length)
{
- int fd = -1;
- int ok;
PED_ASSERT(part);
PED_ASSERT(start);
PED_ASSERT(length);
-#ifdef BLKPG_GET_PARTITION
- ok = _blkpg_get_partition (part, start, length);
- if (ok) {
- *length = (*length * 512) / part->disk->dev->sector_size;
- *start = (*start * 512) / part->disk->dev->sector_size;
- return ok;
- }
-#endif
char *dev_name = linux_partition_get_path (part);
if (!dev_name)
return false;
- ok = _sysfs_ull_entry_from_part (part, "start", start);
+ int ok = _sysfs_ull_entry_from_part (part, "start", start);
if (!ok) {
struct hd_geometry geom;
int dev_fd = open (dev_name, O_RDONLY);
@@ -2524,12 +2496,16 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
}
*start = (*start * 512) / part->disk->dev->sector_size;
ok = _sysfs_ull_entry_from_part (part, "size", length);
+
+ int fd;
if (!ok) {
- if (fd == -1)
- fd = open (dev_name, O_RDONLY);
+ fd = open (dev_name, O_RDONLY);
if (fd != -1 && ioctl (fd, BLKGETSIZE64, length))
ok = true;
- } else *length *= 512;
+ } else {
+ fd = -1;
+ *length *= 512;
+ }
*length /= part->disk->dev->sector_size;
if (fd != -1)
close (fd);
@@ -2538,7 +2514,7 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
ped_exception_throw (
PED_EXCEPTION_BUG,
PED_EXCEPTION_CANCEL,
- _("Unable to determine the size and length of %s."),
+ _("Unable to determine the start and length of %s."),
dev_name);
free (dev_name);
return ok;