1 --- grub-0.95/grub/asmstub.c.odirect 2004-11-30 16:58:06.577019488 -0500
2 +++ grub-0.95/grub/asmstub.c 2004-11-30 16:59:56.057375944 -0500
5 # define BLKFLSBUF _IO (0x12,97) /* flush buffer cache */
6 # endif /* ! BLKFLSBUF */
8 +# define O_DIRECT 040000
9 +# endif /* ! O_DIRECT */
10 #endif /* __linux__ */
12 /* We want to prevent any circularararity in our stubs, as well as
15 /* The unpartitioned device name: /dev/XdX */
16 char *devname = device_map[drive];
18 + char * buf, * buf_unaligned;
24 /* Open read/write, or read-only if that failed. */
26 - disks[drive].flags = open (devname, O_RDWR);
27 + disks[drive].flags = open (devname, O_RDWR | O_DIRECT);
29 if (disks[drive].flags == -1)
31 if (read_only || errno == EACCES || errno == EROFS || errno == EPERM)
33 - disks[drive].flags = open (devname, O_RDONLY);
34 + disks[drive].flags = open (devname, O_RDONLY | O_DIRECT);
35 if (disks[drive].flags == -1)
37 assign_device_name (drive, 0);
42 + buf_unaligned = malloc((512 * sizeof(char)) + 4095);
43 + buf = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
46 /* Attempt to read the first sector. */
47 if (read (disks[drive].flags, buf, 512) != 512)
51 if (disks[drive].flags != -1)
52 get_drive_geometry (&disks[drive], device_map, drive);
53 + free(buf_unaligned);
56 if (disks[drive].flags == -1)
58 nread (int fd, char *buf, size_t len)
61 + char * buf_unaligned, * buff, * obuff;
64 + buf_unaligned = malloc((len * sizeof(char)) + 4095);
65 + obuff = buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
71 - int ret = read (fd, buf, len);
72 + ret = read (fd, buff, len);
89 + if (!len) ret = size;
91 + buf = memcpy(buf, obuff, size);
95 /* Write LEN bytes from BUF to FD. Return less than or equal to zero if an
97 nwrite (int fd, char *buf, size_t len)
100 + char * buf_unaligned, * buff;
102 + buf_unaligned = malloc((len * sizeof(char)) + 4095);
103 + buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
108 - int ret = write (fd, buf, len);
111 + memcpy(buff, buf, len);
112 + ret = write (fd, buff, len);