Skip to content

Commit

Permalink
fix mbr
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed Jun 14, 2023
1 parent 6a093e8 commit deb387e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/xo-server/src/fatfs-buffer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export function addMbr(buf) {
// 0 - 446 is bootstrap code , keep it empty

// entry
mbr[446] = 0x08 // entry is bootable
mbr[450] = 0x04 // MBR bootable , less than 32MB
mbr[454] = 1 // LBA address of first sector
mbr[455] = TEN_MIB / SECTOR_SIZE // LBA address of last sector
mbr[446] = 0x80 // entry is bootable
mbr[450] = 0x0e // FAT16 LBA
mbr.writeInt32LE(1, 454) // LBA address of first sector
assert.strictEqual(buf.length % SECTOR_SIZE, 0, 'buffer length must be aligned to sector size')
mbr.writeInt32LE(buf.length / SECTOR_SIZE + 1, 458) // LBA address of last sector

// 3 more 16 bytes entry we don't need

Expand Down

0 comments on commit deb387e

Please sign in to comment.