Fix some regressions in the floppy image creation script.
authorcoderain <coderain@sdf.org>
Sun, 26 Feb 2017 02:44:39 +0000 (03:44 +0100)
committercoderain <coderain@sdf.org>
Sun, 26 Feb 2017 02:44:39 +0000 (03:44 +0100)
tests/mkfat.sh

index 4a4a06daaf7d7eb2233c7c65ca21d1fc8e0c8555..43569d19502d6c25e7cb3f9867da8f1ebfc52828 100755 (executable)
@@ -78,7 +78,7 @@ function set_next_cluster()
                                             iflag=fullblock \
                                             oflag=seek_bytes \
                                             of=$OUTPUT_FILE \
-                                            seek=$((BYTES_PER_SECTOR + fat * SECTORS_PER_FAT + 3 * (cluster / 2))) \
+                                            seek=$((BYTES_PER_SECTOR * (1 + fat * SECTORS_PER_FAT) + 3 * (cluster / 2))) \
                                             bs=3 \
                                             count=1 \
                                             2>/dev/null
@@ -135,12 +135,12 @@ do
 
     (
         echo -en "${dosname}\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-        printf '%02X%02X' $((first_cluster & 0xFF)) $((first_cluster >> 8)) | xxd -r -p | tr -d '\n'
-        printf "%02X%02X%02X%02X" \
+        printf '%02X%02X' $((first_cluster & 0xFF)) $((first_cluster >> 8)) | xxd -r -p
+        printf '%02X%02X%02X%02X' \
                $((size & 0xFF)) \
                $(((size >> 8) & 0xFF)) \
                $(((size >> 16) & 0xFF)) \
-               $(((size >> 24) & 0xFF)) | xxd -r -p | tr -d '\n'
+               $(((size >> 24) & 0xFF)) | xxd -r -p
     ) | dd conv=notrunc \
            iflag=fullblock \
            of=$OUTPUT_FILE \
@@ -158,8 +158,9 @@ do
            if=$file \
            of=$OUTPUT_FILE \
            skip=$i \
-           seek=$((FIRST_DATA_SECTOR + current_cluster)) \
-           bs=$BYTES_PER_SECTOR count=1 \
+           seek=$((FIRST_DATA_SECTOR + current_cluster - 2)) \
+           bs=$BYTES_PER_SECTOR \
+           count=1 \
            2>/dev/null
 
         set_next_cluster $current_cluster 4095