DF-2910 / dump.c
#include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <sys/disklabel64.h> #include <sys/ioctl.h> int main(void) { struct disklabel64 l; int fd = open("/dev/vn0s1", O_RDONLY); if (fd < 0) { perror("open"); return 1; } if (ioctl(fd, DIOCGDINFO64, &l) < 0) { perror("ioctl"); return 1; } printf("magic=%08x nparts=%u total=%llu bbase=%llu pbase=%llu pstop=%llu abase=%llu\n", l.d_magic, l.d_npartitions, (unsigned long long)l.d_total_size, (unsigned long long)l.d_bbase, (unsigned long long)l.d_pbase, (unsigned long long)l.d_pstop, (unsigned long long)l.d_abase); for (int i = 0; i < 6; i++) printf(" part[%d] boffset=0x%016llx bsize=0x%llx fstype=%u\n", i, (unsigned long long)l.d_partitions[i].p_boffset, (unsigned long long)l.d_partitions[i].p_bsize, l.d_partitions[i].p_fstype); return 0; } |