On 03.04.2011 23:06, Dio Brando wrote: > Yes, I followed the procedure above: > > $ apt-get source grub-pc > $ cd grub2-1.98+20100804 > $ patch -p1 ../readasync.diff > $ dpkg-buildpackage -rfakeroot -b > # dpkg -i /usr/src/grub-common_1.98+20100804-14_amd64.deb (no way, stuck) > > then > It seems like removing O_SYNC is wrong. Attached a patch which should do it correctly
-- Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'grub-core/kern/emu/hostdisk.c' --- grub-core/kern/emu/hostdisk.c 2011-04-03 13:45:20 +0000 +++ grub-core/kern/emu/hostdisk.c 2011-04-03 21:35:46 +0000 @@ -664,7 +664,17 @@ { free (data->dev); if (data->fd != -1) - close (data->fd); + { +#ifdef __linux__ + if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) + { + fsync (data->fd); + ioctl (data->fd, BLKFLSBUF, 0); + } +#endif + + close (data->fd); + } /* Open the partition. */ grub_dprintf ("hostdisk", "opening the device `%s' in open_device()\n", dev); @@ -675,10 +685,6 @@ return -1; } - /* Flush the buffer cache to the physical disk. - XXX: This also empties the buffer cache. */ - ioctl (fd, BLKFLSBUF, 0); - data->dev = xstrdup (dev); data->access_mode = (flags & O_ACCMODE); data->fd = fd; @@ -716,7 +722,16 @@ { free (data->dev); if (data->fd != -1) - close (data->fd); + { +#ifdef __linux__ + if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) + { + fsync (data->fd); + ioctl (data->fd, BLKFLSBUF, 0); + } +#endif + close (data->fd); + } fd = open (map[disk->id].device, flags); if (fd >= 0) @@ -932,7 +947,16 @@ free (data->dev); if (data->fd != -1) - close (data->fd); + { +#ifdef __linux__ + if (data->access_mode == O_RDWR || data->access_mode == O_WRONLY) + { + fsync (data->fd); + ioctl (data->fd, BLKFLSBUF, 0); + } +#endif + close (data->fd); + } free (data); }
signature.asc
Description: OpenPGP digital signature