#include "project.h" void entry_write(DISK *d,GPT_header *h,int n,GPT_entry *e) { uint8_t buf[SECTOR_SIZE]; uint64_t lba=GPT_ENTRY_LBA (h, n); disk_read (d, buf, lba,1); memcpy(&buf[GPT_ENTRY_OFFSET(h,n)],e,sizeof(*e)); disk_write (d, buf, lba, 1); } GPT_entry entry_read(DISK *d,GPT_header *h,int n) { uint8_t buf[SECTOR_SIZE]; GPT_entry e; disk_read (d, buf, GPT_ENTRY_LBA (h, n), 1); memcpy(&e,&buf[GPT_ENTRY_OFFSET(h,n)],sizeof(e)); return e; } int entry_empty(GPT_entry *e) { GUID empty=GUID_TYPE_EMPTY; return !guid_cmp(&e->type,&empty); } void entry_show(GPT_entry *e) { char name[sizeof(e->name)+1]; utf16_to_ascii(e->name,sizeof(e->name),name,sizeof(name)); printf(" Name %s\n",name); printf(" Flags %16x Label %s\n",(int) e->flags,guid_to_a(e->label)); printf(" Start %10lld End %10lld Type %s\n",(long long) e->start,(long long) e->end,guid_to_a(e->type)); }