feat: (vfs) write_page and read_page file operations
[lunaix-os.git] / lunaix-os / kernel / block / blkpart_gpt.c
index 4f9beec83b27c972b745e48b369765c97318a666..22bb48b6d7bb61b9e9afd89d1fc8718446af9611 100644 (file)
@@ -3,11 +3,12 @@
 #include <lunaix/block.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/status.h>
 #include <lunaix/block.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/status.h>
+#include <lunaix/syslog.h>
 
 #include <lib/crc.h>
 
 #define GPT_BLKSIZE 512
 
 #include <lib/crc.h>
 
 #define GPT_BLKSIZE 512
-#define LBA2OFF(lba) (lba * GPT_BLKSIZE)
+#define LBA2OFF(lba) ((lba)*GPT_BLKSIZE)
 #define ENT_PER_BLK (GPT_BLKSIZE / sizeof(struct gpt_entry))
 
 #define GPTSIG_LO 0x20494645UL
 #define ENT_PER_BLK (GPT_BLKSIZE / sizeof(struct gpt_entry))
 
 #define GPTSIG_LO 0x20494645UL
@@ -15,6 +16,8 @@
 
 static u8_t NULL_GUID[16] = { 0 };
 
 
 static u8_t NULL_GUID[16] = { 0 };
 
+LOG_MODULE("GPT")
+
 int
 blkpart_parse(struct device* master, struct gpt_header* header)
 {
 int
 blkpart_parse(struct device* master, struct gpt_header* header)
 {
@@ -46,6 +49,11 @@ blkpart_parse(struct device* master, struct gpt_header* header)
         u64_t slba_local = (ent->start_lba * GPT_BLKSIZE) / bdev->blk_size;
         u64_t elba_local = (ent->end_lba * GPT_BLKSIZE) / (u64_t)bdev->blk_size;
 
         u64_t slba_local = (ent->start_lba * GPT_BLKSIZE) / bdev->blk_size;
         u64_t elba_local = (ent->end_lba * GPT_BLKSIZE) / (u64_t)bdev->blk_size;
 
+        kprintf("%s: guid part#%d: %d..%d\n",
+                bdev->bdev_id,
+                i,
+                (u32_t)slba_local,
+                (u32_t)elba_local);
         // we ignore the partition name, as it rarely used.
         blk_mount_part(bdev, NULL, i, slba_local, elba_local);
     }
         // we ignore the partition name, as it rarely used.
         blk_mount_part(bdev, NULL, i, slba_local, elba_local);
     }
@@ -73,6 +81,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) {
     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\n");
         // FUTURE check the backup header
         return EINVAL;
     }
         // FUTURE check the backup header
         return EINVAL;
     }