From 269a522c7db1f383ccf0998a7cf9c4b1797ea0d9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 10:41:04 +0300 Subject: [PATCH] hostdisk: fix device detection Condition was apparently reversed so GRUB assumed all devices were files. This later made it skip BLKFLSBUF ioctl on Linux which caused various page cache coherency issues. Observed were - failure to validate blocklist install (read content did not match just written) - failure to detect Linux MD on disk after online hot addition (GRUB got stale superblock) Closes: 46691 --- grub-core/kern/emu/hostdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 610518d0c..87e3e2512 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -161,9 +161,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) { struct stat st; # if GRUB_DISK_DEVS_ARE_CHAR - if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode)) + if (fstat (fd, &st) >= 0 && S_ISCHR (st.st_mode)) # else - if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode)) + if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode)) # endif data->is_disk = 1; }