Jiri Slaby
a9f17210c7
- grub2: use stat instead of udevadm for partition lookup (bnc#883635) * Added grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch OBS-URL: https://build.opensuse.org/request/show/238198 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=91
33 lines
1008 B
Diff
33 lines
1008 B
Diff
From: Jeff Mahoney <jeffm@suse.com>
|
|
Subject: grub2: use stat instead of udevadm for partition lookup
|
|
References: bnc#883635
|
|
|
|
sysfs_partition_path calls udevadm to resolve the sysfs path for
|
|
a block device. That can be accomplished by stating the device node
|
|
and using the major/minor to follow the symlinks in /sys/dev/block/.
|
|
|
|
This cuts the execution time of grub2-mkconfig from 10s to 2s on
|
|
my system.
|
|
|
|
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
|
|
---
|
|
grub-core/osdep/linux/hostdisk.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
--- a/grub-core/osdep/linux/hostdisk.c
|
|
+++ b/grub-core/osdep/linux/hostdisk.c
|
|
@@ -105,6 +106,13 @@ sysfs_partition_path (const char *dev, c
|
|
char *buf = NULL;
|
|
size_t len = 0;
|
|
char *path = NULL;
|
|
+ struct stat st;
|
|
+ int ret;
|
|
+
|
|
+ ret = stat(dev, &st);
|
|
+ if (ret == 0 && S_ISBLK(st.st_mode))
|
|
+ return xasprintf ("/sys/dev/block/%u:%u/%s",
|
|
+ major (st.st_rdev), minor (st.st_rdev), entry);
|
|
|
|
argv[0] = "udevadm";
|
|
argv[1] = "info";
|