]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
hostdisk: fix device detection
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sun, 10 Jan 2016 07:41:04 +0000 (10:41 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sun, 10 Jan 2016 07:41:04 +0000 (10:41 +0300)
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

index 610518d0ca74d94ff4c0e2e5322630c5c739df87..87e3e251204f90348a45ea9079c716e052b5106b 100644 (file)
@@ -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;
     }