Menuconfig Implementation and auto-qemu refactoring (#44)
[lunaix-os.git] / lunaix-os / kernel / block / blkpart_gpt.c
index 9d49bfcb98d95845449c4e69a8251570f0264cb8..e9770ceaeb8beaebd084c1ad6a8d92f683cfe2b4 100644 (file)
@@ -5,7 +5,9 @@
 #include <lunaix/status.h>
 #include <lunaix/syslog.h>
 
-#include <lib/crc.h>
+#include <sys/muldiv64.h>
+
+#include <klibc/crc.h>
 
 #define GPT_BLKSIZE 512
 #define LBA2OFF(lba) ((lba) * GPT_BLKSIZE)
@@ -46,9 +48,8 @@ blkpart_parse(struct device* master, struct gpt_header* header)
         }
 
         // Convert UEFI's 512B LB representation into local LBA range.
-        u64_t slba_local =
-          (ent->start_lba * GPT_BLKSIZE) / (u64_t)bdev->blk_size;
-        u64_t elba_local = (ent->end_lba * GPT_BLKSIZE) / (u64_t)bdev->blk_size;
+        u64_t slba_local = udiv64(ent->start_lba * GPT_BLKSIZE, bdev->blk_size);
+        u64_t elba_local = udiv64(ent->end_lba * GPT_BLKSIZE, bdev->blk_size);
 
         kprintf("%s: guid part#%d: %d..%d",
                 bdev->bdev_id,
@@ -83,7 +84,7 @@ blkpart_probegpt(struct device* master)
     u32_t crc = gpt_hdr->hdr_cksum;
     gpt_hdr->hdr_cksum = 0;
     if (crc32b((void*)gpt_hdr, sizeof(*gpt_hdr)) != crc) {
-        kprintf(KWARN "checksum failed");
+        WARN("checksum failed");
         // FUTURE check the backup header
         return EINVAL;
     }