hdflba: tool I forgot to add
authorAlan Cox <alan@linux.intel.com>
Thu, 30 Aug 2018 21:49:45 +0000 (22:49 +0100)
committerAlan Cox <alan@linux.intel.com>
Thu, 30 Aug 2018 21:49:45 +0000 (22:49 +0100)
Makes an HDF emulated hard disk acquire LBA support

Kernel/tools/hdflba.c [new file with mode: 0644]

diff --git a/Kernel/tools/hdflba.c b/Kernel/tools/hdflba.c
new file mode 100644 (file)
index 0000000..fba093c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *     Mark an HDF file as LBA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+  unsigned char buf[512];
+  FILE *f;
+  
+  if (argc != 2) {
+    fprintf(stderr, "%s: hdffile\n", argv[0]);
+    exit(1);
+  }
+  
+  f = fopen(argv[1], "r+");
+  if (f == NULL) {
+    perror(argv[1]);
+    exit(1);
+  }
+  if (fread(buf, 512, 1, f) != 1) {
+    fprintf(stderr, "%s: short read.\n", argv[1]);
+    exit(1);
+  }
+  if (memcmp(buf, "RS-IDE", 6)) {
+    fprintf(stderr, "%s: not an HDF image.\n", argv[1]);
+    exit(1);
+  }
+  buf[0x16 + 99] |= 2;
+  rewind(f);
+  if (fwrite(buf, 512, 1, f) != 1) {
+    fprintf(stderr, "%s: short write.\n", argv[1]);
+    exit(1);
+  }
+  if (fclose(f)) {
+    perror(argv[1]);
+    exit(1);
+  }
+  exit(0);
+}