From 721cd172c88b84e79f36ec7a085740acc0ba49f5 Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:53:50 +0300 Subject: [PATCH] damn it I got wrong formula for LBA CHS conversion --- src/chs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chs.c b/src/chs.c index 96995e0..cec0cc5 100644 --- a/src/chs.c +++ b/src/chs.c @@ -16,7 +16,7 @@ uint32_t chs_to_lba(const chs_conf_t* conf, const chs_t* chs) void lba_to_chs(const chs_conf_t* conf, uint32_t lba, chs_t* chs) { - chs->head = lba / (conf->num_heads * conf->num_sectors); - chs->cylinder = (lba / conf->num_sectors) % conf->num_heads; - chs->sector = (lba % conf->num_sectors) + 1; + chs->head = (lba % (conf->num_sectors * 2)) / conf->num_sectors; + chs->cylinder = (lba / (conf->num_sectors * 2)); + chs->sector = (lba % conf->num_sectors + 1); }