$NetBSD: patch-af,v 1.2 2006/03/25 19:50:20 joerg Exp $

--- init.c.orig	2002-05-01 09:57:02.000000000 +0000
+++ init.c
@@ -14,9 +14,6 @@
 #include "xdf_io.h"
 #include "buffer.h"
 
-extern int errno;
-
-
 #define FULL_CYL
 
 unsigned int num_clus;			/* total number of cluster */
@@ -27,15 +24,30 @@ unsigned int num_clus;			/* total number
  */
 static int read_boot(Stream_t *Stream, struct bootsector * boot, int size)
 {	
+	int rc;
+	char *buf;
+
+	buf = (char *)boot;
+
 	/* read the first sector, or part of it */
 	if(!size)
 		size = BOOTSIZE;
-	if(size > 1024)
-		size = 1024;
 
-	if (force_read(Stream, (char *) boot, 0, size) != size)
-		return -1;
-	return 0;
+	if (size > sizeof(struct bootsector)) {
+		buf = malloc(size);
+		if (!buf)
+			return(-1);
+	}
+
+	rc = 0;
+	if (force_read(Stream, buf, 0, size) != size)
+		rc = -1;
+	
+	if (buf != (char *)boot) {
+		memcpy(boot, buf, sizeof(struct bootsector));
+		free(buf);
+	}
+	return rc;
 }
 
 static int fs_flush(Stream_t *Stream)
