aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-core/systemd/files/0001-dissect-Don-t-count-RPMB-and-boot-partitions-8609.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-core/systemd/files/0001-dissect-Don-t-count-RPMB-and-boot-partitions-8609.patch')
-rw-r--r--common/recipes-core/systemd/files/0001-dissect-Don-t-count-RPMB-and-boot-partitions-8609.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/common/recipes-core/systemd/files/0001-dissect-Don-t-count-RPMB-and-boot-partitions-8609.patch b/common/recipes-core/systemd/files/0001-dissect-Don-t-count-RPMB-and-boot-partitions-8609.patch
new file mode 100644
index 00000000..ed50663e
--- /dev/null
+++ b/common/recipes-core/systemd/files/0001-dissect-Don-t-count-RPMB-and-boot-partitions-8609.patch
@@ -0,0 +1,85 @@
+From d6586055923f0b04df64b197f213804681c8200b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= <jprvita@gmail.com>
+Date: Tue, 3 Apr 2018 05:51:18 -0700
+Subject: [PATCH] dissect: Don't count RPMB and boot partitions (#8609)
+
+Filter-out RPMB partitions and boot partitions from MMC devices when
+counting partitions enumerated by the kernel. Also factor out the now
+duplicated code into a separate function.
+
+This complement the previous fixes to the problem reported in
+https://github.com/systemd/systemd/issues/5806
+---
+ src/shared/dissect-image.c | 34 ++++++++++++++++++++++++++--------
+ 1 file changed, 26 insertions(+), 8 deletions(-)
+
+diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
+index 86114e3dd1..c74fcb4db0 100644
+--- a/src/shared/dissect-image.c
++++ b/src/shared/dissect-image.c
+@@ -108,7 +108,20 @@ not_found:
+ #endif
+ }
+
+-int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectImageFlags flags, DissectedImage **ret) {
++/* Detect RPMB and Boot partitions, which are not listed by blkid.
++ * See https://github.com/systemd/systemd/issues/5806. */
++static bool device_is_mmc_special_partition(struct udev_device *d) {
++ const char *sysname = udev_device_get_sysname(d);
++ return (sysname && startswith(sysname, "mmcblk") &&
++ (endswith(sysname, "rpmb") || endswith(sysname, "boot0") || endswith(sysname, "boot1")));
++}
++
++int dissect_image(
++ int fd,
++ const void *root_hash,
++ size_t root_hash_size,
++ DissectImageFlags flags,
++ DissectedImage **ret) {
+
+ #if HAVE_BLKID
+ sd_id128_t root_uuid = SD_ID128_NULL, verity_uuid = SD_ID128_NULL;
+@@ -277,8 +290,17 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
+ /* Count the partitions enumerated by the kernel */
+ n = 0;
+ first = udev_enumerate_get_list_entry(e);
+- udev_list_entry_foreach(item, first)
++ udev_list_entry_foreach(item, first) {
++ _cleanup_udev_device_unref_ struct udev_device *q;
++
++ q = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
++ if (!q)
++ return -errno;
++
++ if (device_is_mmc_special_partition(q))
++ continue;
+ n++;
++ }
+
+ /* Count the partitions enumerated by blkid */
+ z = blkid_partlist_numof_partitions(pl);
+@@ -337,7 +359,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
+ _cleanup_udev_device_unref_ struct udev_device *q;
+ unsigned long long pflags;
+ blkid_partition pp;
+- const char *node, *sysname;
++ const char *node;
+ dev_t qn;
+ int nr;
+
+@@ -352,11 +374,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
+ if (st.st_rdev == qn)
+ continue;
+
+- /* Filter out weird MMC RPMB partitions, which cannot reasonably be read, see
+- * https://github.com/systemd/systemd/issues/5806 */
+- sysname = udev_device_get_sysname(q);
+- if (sysname && startswith(sysname, "mmcblk") &&
+- (endswith(sysname, "rpmb") || endswith(sysname, "boot0" ) || endswith(sysname, "boot1")))
++ if (device_is_mmc_special_partition(q))
+ continue;
+
+ node = udev_device_get_devnode(q);
+--
+2.11.1
+