Compare commits
10 Commits
61b1abf4cd
...
a528d8fb0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a528d8fb0b | ||
|
|
6baa6be874 | ||
|
|
ca76a7beaf | ||
|
|
46b3361c31 | ||
|
|
0852d0e10c | ||
|
|
c51f5c7d6f | ||
|
|
ab5ffe2f9a | ||
|
|
73ce41b454 | ||
|
|
18577beecc | ||
|
|
908f37a974 |
@ -1,19 +1,26 @@
|
|||||||
From 22be792bfd8e4a4da7495ec60084c23dd8a43677 Mon Sep 17 00:00:00 2001
|
From 7c5b213ab881dbf4a49673908092359f78bc13ce Mon Sep 17 00:00:00 2001
|
||||||
From: huangkaibin <huangkaibin@huawei.com>
|
From: huangkaibin <huangkaibin@huawei.com>
|
||||||
Date: Fri, 25 Jan 2019 19:46:52 +0000
|
Date: Fri, 25 Jan 2019 19:46:52 +0000
|
||||||
Subject: [PATCH] add-support-of-gpt_sync_mbr
|
Subject: [PATCH] add-support-of-gpt_sync_mbr
|
||||||
|
|
||||||
Hybrid MBR support is support by adding a new type of 'gpt_sync_mbr' for mklabel command.
|
Hybrid MBR support is support by adding a new type of 'gpt_sync_mbr' for mklabel command.
|
||||||
This feature is migrated from the path of "parted-gpt-mbr-sync.patch" of SUSE 12 SP1.
|
This feature is migrated from the path of "parted-gpt-mbr-sync.patch" of SUSE 12 SP1.
|
||||||
|
|
||||||
|
Compilation Error:
|
||||||
|
gpt.c:1345:50: error: 'GPTPartitionData' {aka 'struct _GPTPartitionData'}
|
||||||
|
has no member named 'boot'
|
||||||
|
This code has been refactored.'boot' is removed.
|
||||||
|
So we should call ped_partition_get_flag to instead.
|
||||||
|
Signed-off-by: Hongtao Zhang <zhanghongtao22@huawei.com>
|
||||||
---
|
---
|
||||||
libparted/labels/gpt.c | 246 ++++++++++++++++++++++++++++++++++++++++++++++++-
|
libparted/labels/gpt.c | 246 ++++++++++++++++++++++++++++++++++++++++-
|
||||||
1 file changed, 242 insertions(+), 4 deletions(-)
|
1 file changed, 242 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
||||||
index 4f922b2..b2dad71 100644
|
index 780fb70..f63d414 100644
|
||||||
--- a/libparted/labels/gpt.c
|
--- a/libparted/labels/gpt.c
|
||||||
+++ b/libparted/labels/gpt.c
|
+++ b/libparted/labels/gpt.c
|
||||||
@@ -306,6 +306,7 @@ typedef struct _GPTPartitionData
|
@@ -364,6 +364,7 @@ typedef struct _GPTPartitionData
|
||||||
} GPTPartitionData;
|
} GPTPartitionData;
|
||||||
|
|
||||||
static PedDiskType gpt_disk_type;
|
static PedDiskType gpt_disk_type;
|
||||||
@ -21,7 +28,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
|
|
||||||
static inline uint32_t
|
static inline uint32_t
|
||||||
pth_get_size (const PedDevice *dev)
|
pth_get_size (const PedDevice *dev)
|
||||||
@@ -474,8 +475,54 @@ _pmbr_is_valid (const LegacyMBR_t *mbr)
|
@@ -530,8 +531,54 @@ _pmbr_is_valid (const LegacyMBR_t *mbr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +84,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
{
|
{
|
||||||
int gpt_sig_found = 0;
|
int gpt_sig_found = 0;
|
||||||
|
|
||||||
@@ -509,6 +556,19 @@ gpt_probe (const PedDevice *dev)
|
@@ -565,6 +612,19 @@ gpt_probe (const PedDevice *dev)
|
||||||
return gpt_sig_found;
|
return gpt_sig_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,10 +104,11 @@ index 4f922b2..b2dad71 100644
|
|||||||
static PedDisk *
|
static PedDisk *
|
||||||
gpt_alloc (const PedDevice *dev)
|
gpt_alloc (const PedDevice *dev)
|
||||||
{
|
{
|
||||||
@@ -554,6 +614,36 @@ error:
|
@@ -609,6 +669,36 @@ error:
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PedDisk *
|
+static PedDisk *
|
||||||
+gpt_sync_mbr_alloc (const PedDevice *dev)
|
+gpt_sync_mbr_alloc (const PedDevice *dev)
|
||||||
+{
|
+{
|
||||||
+ PedDisk *disk;
|
+ PedDisk *disk;
|
||||||
@ -130,11 +138,10 @@ index 4f922b2..b2dad71 100644
|
|||||||
+ return NULL;
|
+ return NULL;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+static PedDisk *
|
static PedDisk *
|
||||||
gpt_duplicate (const PedDisk *disk)
|
gpt_duplicate (const PedDisk *disk)
|
||||||
{
|
{
|
||||||
PedDisk *new_disk;
|
@@ -983,7 +1073,7 @@ gpt_read (PedDisk *disk)
|
||||||
@@ -967,7 +1057,7 @@ gpt_read (PedDisk *disk)
|
|
||||||
|
|
||||||
/* motivation: let the user decide about the pmbr... during
|
/* motivation: let the user decide about the pmbr... during
|
||||||
ped_disk_probe(), they probably didn't get a choice... */
|
ped_disk_probe(), they probably didn't get a choice... */
|
||||||
@ -143,7 +150,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
GuidPartitionTableHeader_t *gpt = NULL;
|
GuidPartitionTableHeader_t *gpt = NULL;
|
||||||
@@ -1124,11 +1214,61 @@ error:
|
@@ -1140,11 +1230,61 @@ error:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +213,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
/* The UEFI spec is not clear about what to do with the following
|
/* The UEFI spec is not clear about what to do with the following
|
||||||
elements of the Protective MBR (pmbr): BootCode (0-440B),
|
elements of the Protective MBR (pmbr): BootCode (0-440B),
|
||||||
UniqueMBRSignature (440B-444B) and Unknown (444B-446B).
|
UniqueMBRSignature (440B-444B) and Unknown (444B-446B).
|
||||||
@@ -1142,6 +1282,8 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
|
@@ -1158,6 +1298,8 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
|
||||||
memset (pmbr->PartitionRecord, 0, sizeof pmbr->PartitionRecord);
|
memset (pmbr->PartitionRecord, 0, sizeof pmbr->PartitionRecord);
|
||||||
|
|
||||||
pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
|
pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
|
||||||
@ -215,7 +222,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
|
pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
|
||||||
pmbr->PartitionRecord[0].StartSector = 2;
|
pmbr->PartitionRecord[0].StartSector = 2;
|
||||||
pmbr->PartitionRecord[0].EndHead = 0xFF;
|
pmbr->PartitionRecord[0].EndHead = 0xFF;
|
||||||
@@ -1154,6 +1296,60 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
|
@@ -1170,6 +1312,60 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
|
||||||
pmbr->PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32 (dev->length - 1UL);
|
pmbr->PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32 (dev->length - 1UL);
|
||||||
if (pmbr_boot)
|
if (pmbr_boot)
|
||||||
pmbr->PartitionRecord[0].BootIndicator = 0x80;
|
pmbr->PartitionRecord[0].BootIndicator = 0x80;
|
||||||
@ -268,7 +275,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
+ pmbr->PartitionRecord[i].EndSector = 0xFF;
|
+ pmbr->PartitionRecord[i].EndSector = 0xFF;
|
||||||
+ pmbr->PartitionRecord[i].EndTrack = 0xFF;
|
+ pmbr->PartitionRecord[i].EndTrack = 0xFF;
|
||||||
+ pmbr->PartitionRecord[i].StartingLBA = PED_CPU_TO_LE32 (_part_32bitmax(part->geom.start));
|
+ pmbr->PartitionRecord[i].StartingLBA = PED_CPU_TO_LE32 (_part_32bitmax(part->geom.start));
|
||||||
+ if(((GPTPartitionData*)part->disk_specific)->boot)
|
+ if(ped_partition_get_flag(part, PED_PARTITION_BOOT))
|
||||||
+ pmbr->PartitionRecord[i].BootIndicator = 0x80;
|
+ pmbr->PartitionRecord[i].BootIndicator = 0x80;
|
||||||
+ pmbr->PartitionRecord[i].SizeInLBA = PED_CPU_TO_LE32 (_part_32bitmax(part->geom.end - part->geom.start + 1));
|
+ pmbr->PartitionRecord[i].SizeInLBA = PED_CPU_TO_LE32 (_part_32bitmax(part->geom.end - part->geom.start + 1));
|
||||||
+ }
|
+ }
|
||||||
@ -276,7 +283,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
|
|
||||||
int write_ok = ped_device_write (dev, pmbr, GPT_PMBR_LBA,
|
int write_ok = ped_device_write (dev, pmbr, GPT_PMBR_LBA,
|
||||||
GPT_PMBR_SECTORS);
|
GPT_PMBR_SECTORS);
|
||||||
@@ -1273,7 +1469,7 @@ gpt_write (const PedDisk *disk)
|
@@ -1284,7 +1480,7 @@ gpt_write (const PedDisk *disk)
|
||||||
ptes_crc = efi_crc32 (ptes, ptes_bytes);
|
ptes_crc = efi_crc32 (ptes, ptes_bytes);
|
||||||
|
|
||||||
/* Write protective MBR */
|
/* Write protective MBR */
|
||||||
@ -285,7 +292,7 @@ index 4f922b2..b2dad71 100644
|
|||||||
goto error_free_ptes;
|
goto error_free_ptes;
|
||||||
|
|
||||||
/* Write PTH and PTEs */
|
/* Write PTH and PTEs */
|
||||||
@@ -2070,6 +2266,38 @@ static PedDiskOps gpt_disk_ops =
|
@@ -1916,6 +2112,38 @@ static PedDiskOps gpt_disk_ops =
|
||||||
PT_op_function_initializers (gpt)
|
PT_op_function_initializers (gpt)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -324,8 +331,8 @@ index 4f922b2..b2dad71 100644
|
|||||||
static PedDiskType gpt_disk_type =
|
static PedDiskType gpt_disk_type =
|
||||||
{
|
{
|
||||||
next: NULL,
|
next: NULL,
|
||||||
@@ -2078,16 +2306,26 @@ static PedDiskType gpt_disk_type =
|
@@ -1925,16 +2153,26 @@ static PedDiskType gpt_disk_type =
|
||||||
features: PED_DISK_TYPE_PARTITION_NAME
|
PED_DISK_TYPE_DISK_UUID | PED_DISK_TYPE_PARTITION_UUID
|
||||||
};
|
};
|
||||||
|
|
||||||
+static PedDiskType gpt_sync_mbr_disk_type =
|
+static PedDiskType gpt_sync_mbr_disk_type =
|
||||||
@ -352,5 +359,5 @@ index 4f922b2..b2dad71 100644
|
|||||||
|
|
||||||
verify (sizeof (GuidPartitionEntryAttributes_t) == 8);
|
verify (sizeof (GuidPartitionEntryAttributes_t) == 8);
|
||||||
--
|
--
|
||||||
1.8.3.1
|
2.33.0
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
From f7e08c5cb68f84541bb982c3dd6ab50a163bd2c2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
Date: Tue, 29 Mar 2022 11:00:07 +0800
|
||||||
|
Subject: [PATCH 1/6] hfsplus_btree_search: free node when hfsplus_file_read
|
||||||
|
failed
|
||||||
|
|
||||||
|
when hfsplus_file_read() return error, need to free node, otherwise there
|
||||||
|
will be memory leak
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
---
|
||||||
|
libparted/fs/r/hfs/advfs_plus.c | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/fs/r/hfs/advfs_plus.c b/libparted/fs/r/hfs/advfs_plus.c
|
||||||
|
index 55e88cd..b1cc644 100644
|
||||||
|
--- a/libparted/fs/r/hfs/advfs_plus.c
|
||||||
|
+++ b/libparted/fs/r/hfs/advfs_plus.c
|
||||||
|
@@ -101,9 +101,10 @@ hfsplus_btree_search (HfsPPrivateFile* b_tree_file, HfsPPrivateGenericKey* key,
|
||||||
|
|
||||||
|
/* Read the root node */
|
||||||
|
if (!hfsplus_file_read (b_tree_file, node,
|
||||||
|
- (PedSector) node_number * size, size))
|
||||||
|
+ (PedSector) node_number * size, size)) {
|
||||||
|
+ free(node);
|
||||||
|
return 0;
|
||||||
|
-
|
||||||
|
+ }
|
||||||
|
/* Follow the white rabbit */
|
||||||
|
while (1) {
|
||||||
|
record_number = PED_BE16_TO_CPU (desc->rec_nb);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
From 853f6bd35f22092f31595504d27c4910042631c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
Date: Tue, 29 Mar 2022 11:01:43 +0800
|
||||||
|
Subject: [PATCH 2/6] amiga_read: need free part and partition when
|
||||||
|
constraint_exact is NULL
|
||||||
|
|
||||||
|
When constraint_exact is NULL and exit, need to release part and partition,
|
||||||
|
otherwise there will be memory leaks
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
---
|
||||||
|
libparted/labels/rdb.c | 5 ++++-
|
||||||
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
|
||||||
|
index cbbf29a..8096285 100644
|
||||||
|
--- a/libparted/labels/rdb.c
|
||||||
|
+++ b/libparted/labels/rdb.c
|
||||||
|
@@ -545,8 +545,11 @@ amiga_read (PedDisk* disk)
|
||||||
|
|
||||||
|
PedConstraint *constraint_exact
|
||||||
|
= ped_constraint_exact (&part->geom);
|
||||||
|
- if (constraint_exact == NULL)
|
||||||
|
+ if (constraint_exact == NULL) {
|
||||||
|
+ ped_partition_destroy(part);
|
||||||
|
+ free(partition);
|
||||||
|
return 0;
|
||||||
|
+ }
|
||||||
|
bool ok = ped_disk_add_partition (disk, part, constraint_exact);
|
||||||
|
ped_constraint_destroy (constraint_exact);
|
||||||
|
if (!ok) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
From 1fdae37b82d0cf16df80f648b5489f7ffd15eae1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
Date: Tue, 29 Mar 2022 11:02:38 +0800
|
||||||
|
Subject: [PATCH 3/6] scsi_get_product_info: fix memleak and avoid to use NULL
|
||||||
|
pointer
|
||||||
|
|
||||||
|
Need to ensure that *vendor and *product are not NULL in scsi_query_product_info()
|
||||||
|
before return 1, otherwise a null pointer may be used.
|
||||||
|
|
||||||
|
Regardless of whether scsi_query_product_info() returns success or failed,
|
||||||
|
vendor and product should be released, otherwise there will be a memory leak
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
---
|
||||||
|
libparted/arch/linux.c | 9 +++++----
|
||||||
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||||||
|
index 94ea176..23ec55a 100644
|
||||||
|
--- a/libparted/arch/linux.c
|
||||||
|
+++ b/libparted/arch/linux.c
|
||||||
|
@@ -1130,7 +1130,9 @@ scsi_query_product_info (PedDevice* dev, char **vendor, char **product)
|
||||||
|
buf[16] = '\0';
|
||||||
|
*product = strip_name (buf);
|
||||||
|
|
||||||
|
- return 1;
|
||||||
|
+ if (*vendor && *product)
|
||||||
|
+ return 1;
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function provides the vendor and product name for a SCSI device.
|
||||||
|
@@ -1144,7 +1146,6 @@ scsi_get_product_info (PedDevice* dev, char **vendor, char **product)
|
||||||
|
*product = read_device_sysfs_file (dev, "model");
|
||||||
|
if (*vendor && *product)
|
||||||
|
return 1;
|
||||||
|
-
|
||||||
|
return scsi_query_product_info (dev, vendor, product);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1188,11 +1189,11 @@ init_scsi (PedDevice* dev)
|
||||||
|
|
||||||
|
if (scsi_get_product_info (dev, &vendor, &product)) {
|
||||||
|
sprintf (dev->model, "%.8s %.16s", vendor, product);
|
||||||
|
- free (vendor);
|
||||||
|
- free (product);
|
||||||
|
} else {
|
||||||
|
strcpy (dev->model, "Generic SCSI");
|
||||||
|
}
|
||||||
|
+ free (vendor);
|
||||||
|
+ free (product);
|
||||||
|
|
||||||
|
if (!_device_probe_geometry (dev))
|
||||||
|
goto error_close_dev;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
From fa8544b4229e19679db070c31969c9739f702fd0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
Date: Tue, 29 Mar 2022 11:07:33 +0800
|
||||||
|
Subject: [PATCH 4/6] fat_op_context_new: free ctx->remap and goto correct
|
||||||
|
label to avoid memleak
|
||||||
|
|
||||||
|
When calc_deltas returns an error, need to release ctx->remap,
|
||||||
|
and eed to jump to the correct label to release ctx, otherwise
|
||||||
|
there will be memory leaks
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
---
|
||||||
|
libparted/fs/r/fat/context.c | 8 +++++---
|
||||||
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/fs/r/fat/context.c b/libparted/fs/r/fat/context.c
|
||||||
|
index 5ca154c..fce77af 100644
|
||||||
|
--- a/libparted/fs/r/fat/context.c
|
||||||
|
+++ b/libparted/fs/r/fat/context.c
|
||||||
|
@@ -86,9 +86,9 @@ fat_op_context_new (PedFileSystem* new_fs, PedFileSystem* old_fs)
|
||||||
|
ctx->frag_sectors = PED_MIN (old_fs_info->cluster_sectors,
|
||||||
|
new_fs_info->cluster_sectors);
|
||||||
|
if (!fat_set_frag_sectors (new_fs, ctx->frag_sectors))
|
||||||
|
- goto error;
|
||||||
|
+ goto error_free_ctx;
|
||||||
|
if (!fat_set_frag_sectors (old_fs, ctx->frag_sectors))
|
||||||
|
- goto error;
|
||||||
|
+ goto error_free_ctx;
|
||||||
|
|
||||||
|
ctx->buffer_frags = old_fs_info->buffer_sectors / ctx->frag_sectors;
|
||||||
|
ctx->buffer_map = (FatFragment*) ped_malloc (sizeof (FatFragment)
|
||||||
|
@@ -104,10 +104,12 @@ fat_op_context_new (PedFileSystem* new_fs, PedFileSystem* old_fs)
|
||||||
|
ctx->new_fs = new_fs;
|
||||||
|
ctx->old_fs = old_fs;
|
||||||
|
if (!calc_deltas (ctx))
|
||||||
|
- goto error_free_buffer_map;
|
||||||
|
+ goto error_free_remap;
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
|
||||||
|
+error_free_remap:
|
||||||
|
+ free(ctx->remap);
|
||||||
|
error_free_buffer_map:
|
||||||
|
free (ctx->buffer_map);
|
||||||
|
error_free_ctx:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
32
0008-hfsplus_cache_from_extent-fix-memleak.patch
Normal file
32
0008-hfsplus_cache_from_extent-fix-memleak.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From ab6fde7a74ae90446a1ae88da82fee572a8a0466 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
Date: Tue, 29 Mar 2022 11:08:46 +0800
|
||||||
|
Subject: [PATCH 5/6] hfsplus_cache_from_extent: fix memleak
|
||||||
|
|
||||||
|
Need to release node when an error occurs
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
---
|
||||||
|
libparted/fs/r/hfs/reloc_plus.c | 4 +++-
|
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/fs/r/hfs/reloc_plus.c b/libparted/fs/r/hfs/reloc_plus.c
|
||||||
|
index f065406..44e3490 100644
|
||||||
|
--- a/libparted/fs/r/hfs/reloc_plus.c
|
||||||
|
+++ b/libparted/fs/r/hfs/reloc_plus.c
|
||||||
|
@@ -670,8 +670,10 @@ hfsplus_cache_from_extent(HfsCPrivateCache* cache, PedFileSystem* fs,
|
||||||
|
_("The extents overflow file should not"
|
||||||
|
" contain its own extents! You should "
|
||||||
|
"check the file system."))
|
||||||
|
- != PED_EXCEPTION_IGNORE)
|
||||||
|
+ != PED_EXCEPTION_IGNORE) {
|
||||||
|
+ free(node);
|
||||||
|
return 0;
|
||||||
|
+ }
|
||||||
|
where = CR_BTREE_EXT_EXT;
|
||||||
|
break;
|
||||||
|
case PED_CPU_TO_BE32 (HFS_CATALOG_ID) :
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
From 1512dc33b36ad0feff9dbdcfe38e6d2acdcb38a0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
Date: Tue, 29 Mar 2022 11:10:19 +0800
|
||||||
|
Subject: [PATCH 6/6] fat_clobber: set boot_sector = NULL and free boot_sector
|
||||||
|
after failed of fat_boot_sector_read
|
||||||
|
|
||||||
|
When fat_boot_sector_read() returns failure, boot_sector may have
|
||||||
|
allocated memory, and memory leak will occur
|
||||||
|
|
||||||
|
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
|
||||||
|
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||||
|
---
|
||||||
|
libparted/fs/r/fat/fat.c | 6 ++++--
|
||||||
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
|
||||||
|
index 396494a..33a4284 100644
|
||||||
|
--- a/libparted/fs/r/fat/fat.c
|
||||||
|
+++ b/libparted/fs/r/fat/fat.c
|
||||||
|
@@ -117,11 +117,13 @@ fat_set_frag_sectors (PedFileSystem* fs, PedSector frag_sectors)
|
||||||
|
int
|
||||||
|
fat_clobber (PedGeometry* geom)
|
||||||
|
{
|
||||||
|
- FatBootSector *boot_sector;
|
||||||
|
+ FatBootSector *boot_sector = NULL;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
- if (!fat_boot_sector_read (&boot_sector, geom))
|
||||||
|
+ if (!fat_boot_sector_read (&boot_sector, geom)) {
|
||||||
|
+ free(boot_sector);
|
||||||
|
return 1;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
boot_sector->system_id[0] = 0;
|
||||||
|
boot_sector->boot_sign = 0;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
88
9000-parted-remove-patch-which-modifid-cyl-size.patch
Normal file
88
9000-parted-remove-patch-which-modifid-cyl-size.patch
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
From bfce75fd13dd72c6300f0ac3d739e40df90f7dce Mon Sep 17 00:00:00 2001
|
||||||
|
From: lixiaokeng <lixiaokeng@huawei.com>
|
||||||
|
Date: Sun, 7 Jun 2020 15:18:00 +0000
|
||||||
|
Subject: [PATCH] parted: remove patch which modified cyl size
|
||||||
|
|
||||||
|
The cyl size was changed which leaded to "parted /dev/sdb -s mkpart primary 0cyl 128cyl"
|
||||||
|
could not perform as expected. Remove the patch "Use BLKSSZGET to get device sector size
|
||||||
|
in _device_probe_geometry()".
|
||||||
|
|
||||||
|
Signed-off-by:lixiaokeng<lixiaokeng@huawei.com>
|
||||||
|
---
|
||||||
|
linux.c | 52 ++++++++++++++++++----------------------------------
|
||||||
|
1 file changed, 18 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||||||
|
index 37cf555..0d8149d 100644
|
||||||
|
--- a/libparted/arch/linux.c
|
||||||
|
+++ b/libparted/arch/linux.c
|
||||||
|
@@ -868,7 +868,6 @@ _device_probe_geometry (PedDevice* dev)
|
||||||
|
struct stat dev_stat;
|
||||||
|
struct hd_geometry geometry;
|
||||||
|
int geometry_is_valid = 0;
|
||||||
|
- int sector_size = 0;
|
||||||
|
|
||||||
|
if (!_device_stat (dev, &dev_stat))
|
||||||
|
return 0;
|
||||||
|
@@ -880,41 +879,26 @@ _device_probe_geometry (PedDevice* dev)
|
||||||
|
if (!dev->length)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- /* initialize the bios_geom values to something */
|
||||||
|
- dev->bios_geom.sectors = 0;
|
||||||
|
- dev->bios_geom.heads = 0;
|
||||||
|
- dev->bios_geom.cylinders = 0;
|
||||||
|
-
|
||||||
|
- geometry_is_valid = !ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
|
||||||
|
- && geometry.sectors && geometry.heads;
|
||||||
|
-
|
||||||
|
-#if defined __s390__ || defined __s390x__
|
||||||
|
- if (geometry_is_valid) {
|
||||||
|
-#else
|
||||||
|
- if (!ioctl (arch_specific->fd, BLKSSZGET, §or_size)) {
|
||||||
|
- /* get the sector count first */
|
||||||
|
- dev->bios_geom.sectors = 1 + (sector_size / PED_SECTOR_SIZE_DEFAULT);
|
||||||
|
- dev->bios_geom.heads = 255;
|
||||||
|
- } else if (geometry_is_valid) {
|
||||||
|
- /* if BLKSSZGET failed, use deprecated HDIO_GETGEO result */
|
||||||
|
-#endif
|
||||||
|
- dev->bios_geom.sectors = geometry.sectors;
|
||||||
|
- dev->bios_geom.heads = geometry.heads;
|
||||||
|
+ /* The GETGEO ioctl is no longer useful (as of linux 2.6.x). We could
|
||||||
|
+ * still use it in 2.4.x, but this is contentious. Perhaps we should
|
||||||
|
+ * move to EDD. */
|
||||||
|
+ dev->bios_geom.sectors = 63;
|
||||||
|
+ dev->bios_geom.heads = 255;
|
||||||
|
+ dev->bios_geom.cylinders
|
||||||
|
+ = dev->length / (63 * 255);
|
||||||
|
+
|
||||||
|
+ /* FIXME: what should we put here? (TODO: discuss on linux-kernel) */
|
||||||
|
+ if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
|
||||||
|
+ && geometry.sectors && geometry.heads) {
|
||||||
|
+ dev->hw_geom.sectors = geometry.sectors;
|
||||||
|
+ dev->hw_geom.heads = geometry.heads;
|
||||||
|
+ dev->hw_geom.cylinders
|
||||||
|
+ = dev->length / (dev->hw_geom.heads
|
||||||
|
+ * dev->hw_geom.sectors);
|
||||||
|
} else {
|
||||||
|
- ped_exception_throw (
|
||||||
|
- PED_EXCEPTION_WARNING,
|
||||||
|
- PED_EXCEPTION_OK,
|
||||||
|
- _("Could not determine sector size for %s: %s.\n"
|
||||||
|
- "Using the default sector size (%lld)."),
|
||||||
|
- dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
|
||||||
|
- dev->bios_geom.sectors = 2;
|
||||||
|
- dev->bios_geom.heads = 255;
|
||||||
|
+ dev->hw_geom = dev->bios_geom;
|
||||||
|
}
|
||||||
|
|
||||||
|
- dev->bios_geom.cylinders
|
||||||
|
- = dev->length / (dev->bios_geom.heads
|
||||||
|
- * dev->bios_geom.sectors);
|
||||||
|
- dev->hw_geom = dev->bios_geom;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
Binary file not shown.
BIN
parted-3.6.tar.xz
Normal file
BIN
parted-3.6.tar.xz
Normal file
Binary file not shown.
30
parted.spec
30
parted.spec
@ -1,3 +1,5 @@
|
|||||||
|
#needsrootforbuild
|
||||||
|
|
||||||
# This SPEC file come from GNU Parted Project(git://git.savannah.gnu.org/parted.git)
|
# This SPEC file come from GNU Parted Project(git://git.savannah.gnu.org/parted.git)
|
||||||
# Default to disabling device-mapper and SELinux
|
# Default to disabling device-mapper and SELinux
|
||||||
%define use_devmapper 0
|
%define use_devmapper 0
|
||||||
@ -13,8 +15,8 @@
|
|||||||
|
|
||||||
Summary: The GNU disk partition manipulation program
|
Summary: The GNU disk partition manipulation program
|
||||||
Name: parted
|
Name: parted
|
||||||
Version: 3.4
|
Version: 3.6
|
||||||
Release: 2
|
Release: 1
|
||||||
URL: https://www.gnu.org/software/parted/
|
URL: https://www.gnu.org/software/parted/
|
||||||
Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
|
Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
@ -27,6 +29,14 @@ BuildRequires: device-mapper-devel, libselinux-devel libsepol-devel
|
|||||||
Patch1: 0001-add-support-of-gpt_sync_mbr.patch
|
Patch1: 0001-add-support-of-gpt_sync_mbr.patch
|
||||||
Patch2: 0002-Add-extra-judgment-for-a-partition-created-success.patch
|
Patch2: 0002-Add-extra-judgment-for-a-partition-created-success.patch
|
||||||
Patch3: 0003-bugfix-parted-fix-failure-of-mklabel-gpt_sync_mbr.patch
|
Patch3: 0003-bugfix-parted-fix-failure-of-mklabel-gpt_sync_mbr.patch
|
||||||
|
Patch4: 0004-hfsplus_btree_search-free-node-when-hfsplus_file_rea.patch
|
||||||
|
Patch5: 0005-amiga_read-need-free-part-and-partition-when-constra.patch
|
||||||
|
Patch6: 0006-scsi_get_product_info-fix-memleak-and-avoid-to-use-N.patch
|
||||||
|
Patch7: 0007-fat_op_context_new-free-ctx-remap-and-goto-correct-l.patch
|
||||||
|
Patch8: 0008-hfsplus_cache_from_extent-fix-memleak.patch
|
||||||
|
Patch9: 0009-fat_clobber-set-boot_sector-NULL-and-free-boot_secto.patch
|
||||||
|
|
||||||
|
Patch9000: 9000-parted-remove-patch-which-modifid-cyl-size.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The GNU Parted program allows you to create, destroy, resize, move,
|
The GNU Parted program allows you to create, destroy, resize, move,
|
||||||
@ -111,6 +121,22 @@ fi
|
|||||||
%{_libdir}/pkgconfig/libparted*.pc
|
%{_libdir}/pkgconfig/libparted*.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Feb 26 2024 wangzhiqiang <wangzhiqiang95@huawei.com> - 3.6-1
|
||||||
|
- update to 3.6
|
||||||
|
- update version dependency
|
||||||
|
|
||||||
|
* Thu Dec 14 2023 lingsheng <lingsheng@xfusion.com> - 3.5-2
|
||||||
|
- remove patch which modifid cyl-size
|
||||||
|
|
||||||
|
* Wed Oct 26 2022 Hongtao Zhang <zhanghongtao22@huawei.com> - 3.5-1
|
||||||
|
- update to 3.5
|
||||||
|
|
||||||
|
* Thu Mar 3 2022 Li Jinlin <lijinlin3@huawei.com> - 3.4-4
|
||||||
|
- fix memory leak in libparted
|
||||||
|
|
||||||
|
* Thu Mar 3 2022 Li Jinlin <lijinlin3@huawei.com> - 3.4-3
|
||||||
|
- add need root for build
|
||||||
|
|
||||||
* Tue Dec 21 2021 Chenxi Mao <chenxi.mao@suse.com> - 3.4-2
|
* Tue Dec 21 2021 Chenxi Mao <chenxi.mao@suse.com> - 3.4-2
|
||||||
- fix build error on SUSE Euler 2.0
|
- fix build error on SUSE Euler 2.0
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user