summaryrefslogtreecommitdiff
path: root/emulators/qemu/files/patch-block.c
diff options
context:
space:
mode:
Diffstat (limited to 'emulators/qemu/files/patch-block.c')
-rw-r--r--emulators/qemu/files/patch-block.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/emulators/qemu/files/patch-block.c b/emulators/qemu/files/patch-block.c
index d174d8f96e27..c924d2d96039 100644
--- a/emulators/qemu/files/patch-block.c
+++ b/emulators/qemu/files/patch-block.c
@@ -1,5 +1,4 @@
---- qemu/block.c.orig Thu Sep 30 06:27:57 2004
-+++ qemu/block.c Thu Nov 4 23:19:37 2004
+Index: qemu/block.c
@@ -21,6 +21,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
@@ -18,6 +17,42 @@
#include "vl.h"
#include "block_int.h"
+@@ -103,14 +103,25 @@
+ {
+ int fd, ret, score, score_max;
+ BlockDriver *drv1, *drv;
+- uint8_t buf[1024];
++ uint8_t *buf;
++ size_t bufsize = 1024;
++ u_int sectorsize = 512;
+
+ fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
+ if (fd < 0)
+ return NULL;
+- ret = read(fd, buf, sizeof(buf));
++#ifdef DIOCGSECTORSIZE
++ if (!ioctl(fd, DIOCGSECTORSIZE, &sectorsize) &&
++ sectorsize > bufsize)
++ bufsize = sectorsize;
++#endif
++ buf = malloc(bufsize);
++ if (!buf)
++ return NULL;
++ ret = read(fd, buf, bufsize);
+ if (ret < 0) {
+ close(fd);
++ free(buf);
+ return NULL;
+ }
+ close(fd);
+@@ -124,6 +135,7 @@
+ drv = drv1;
+ }
+ }
++ free(buf);
+ return drv;
+ }
+
@@ -522,6 +533,15 @@
return -1;
bs->read_only = 1;