parted/parted-1.9.0-lo-as-file-rh546622.patch
Hans de Goede c11ab73298 - Fix crash when partitioning loopback devices (#546622)
- Drop no-cylinder-align patch:
- its functionality is superseeded by the per disk flags
- its only user (pyparted) has been updated to use those
- this is not upstream so we don't want other programs to start using it
2009-12-20 10:19:49 +00:00

37 lines
1.5 KiB
Diff

diff -up parted-1.9.0/libparted/arch/linux.c.orig parted-1.9.0/libparted/arch/linux.c
--- parted-1.9.0/libparted/arch/linux.c.orig 2009-12-14 22:44:18.000000000 +0100
+++ parted-1.9.0/libparted/arch/linux.c 2009-12-15 10:25:38.000000000 +0100
@@ -259,6 +259,7 @@ struct blkdev_ioctl_param {
#define SX8_MAJOR2 161
#define XVD_MAJOR 202
#define SDMMC_MAJOR 179
+#define LOOP_MAJOR 7
#define SCSI_BLK_MAJOR(M) ( \
(M) == SCSI_DISK0_MAJOR \
@@ -561,6 +562,8 @@ _device_probe_type (PedDevice* dev)
dev->type = PED_DEVICE_SDMMC;
} else if (_is_virtblk_major(dev_major)) {
dev->type = PED_DEVICE_VIRTBLK;
+ } else if (dev_major == LOOP_MAJOR) {
+ dev->type = PED_DEVICE_FILE;
} else {
dev->type = PED_DEVICE_UNKNOWN;
}
@@ -1048,6 +1048,15 @@ init_file (PedDevice* dev)
if (!ped_device_open (dev))
goto error;
+ dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
+ char *p = getenv ("PARTED_SECTOR_SIZE");
+ if (p) {
+ int s = atoi (p);
+ if (0 < s && s % 512 == 0)
+ dev->sector_size = s;
+ }
+ dev->phys_sector_size = dev->sector_size;
+
if (S_ISBLK(dev_stat.st_mode))
dev->length = _device_get_length (dev);
else