public static void WriteToDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, KernelUpdateLogPage record) { ulong sectorIndex = privateHeader.PrivateRegionStartLBA + tocBlock.LogStart + record.PageIndex; byte[] sector = record.GetBytes(); disk.WriteSectors((long)sectorIndex, sector); }
public static void WriteToDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, KernelUpdateLogPage page) { ulong sectorIndex = privateHeader.PrivateRegionStartLBA + tocBlock.LogStart + (uint)(page.PageIndex * Length / disk.BytesPerSector); int pageOffset = ((int)page.PageIndex * Length) % disk.BytesPerSector; byte[] pageBytes = page.GetBytes(); if (disk.BytesPerSector > Length) { byte[] sectorBytes = disk.ReadSector((long)sectorIndex); ByteWriter.WriteBytes(sectorBytes, pageOffset, pageBytes); disk.WriteSectors((long)sectorIndex, sectorBytes); } else { disk.WriteSectors((long)sectorIndex, pageBytes); } }