1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Fix to partition table detection code.

This commit is contained in:
Alasdair Kergon 2004-11-24 20:38:05 +00:00
parent 7f1e8db796
commit 2e6051674b
3 changed files with 11 additions and 11 deletions

View File

@ -1 +1 @@
2.00.27-cvs (2004-11-23) 2.00.27-cvs (2004-11-24)

View File

@ -1,5 +1,6 @@
Version 2.00.27 - Version 2.00.27 - 24th November 2004
==================================== ====================================
Fix to partition table detection code.
Improve filter debug mesgs. Improve filter debug mesgs.
Version 2.00.26 - 23rd November 2004 Version 2.00.26 - 23rd November 2004

View File

@ -20,30 +20,29 @@
#include "filter.h" #include "filter.h"
#define PART_MAGIC 0xAA55 #define PART_MAGIC 0xAA55
#define PART_OFFSET UINT64_C(510)
static int _is_whole_disk(struct device *dev) static int _is_partitionable(struct device *dev)
{ {
int parts = max_partitions(MINOR(dev->dev)); int parts = max_partitions(MAJOR(dev->dev));
if (!parts || !(MINOR(dev->dev) % parts)) if (!parts || (MINOR(dev->dev) % parts))
return 1; return 0;
return 0; return 1;
} }
static int _has_partition_table(struct device *dev) static int _has_partition_table(struct device *dev)
{ {
int ret = 0; int ret = 0;
uint32_t part_magic; uint32_t part_magic;
uint64_t part_offset;
if (!dev_open(dev)) { if (!dev_open(dev)) {
stack; stack;
return -1; return -1;
} }
part_offset = sizeof(unsigned short) * 255; if (dev_read(dev, PART_OFFSET, sizeof(part_magic), &part_magic) &&
if (dev_read(dev, part_offset, sizeof(part_magic), &part_magic) &&
(part_magic == PART_MAGIC)) (part_magic == PART_MAGIC))
ret = 1; ret = 1;
@ -55,7 +54,7 @@ static int _has_partition_table(struct device *dev)
int is_partitioned_dev(struct device *dev) int is_partitioned_dev(struct device *dev)
{ {
if (_is_whole_disk(dev)) if (!_is_partitionable(dev))
return 0; return 0;
return _has_partition_table(dev); return _has_partition_table(dev);