#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/diskslice.h>
int main(int argc, char **argv) {
    struct partinfo pi;
    int fd = open(argv[1], O_RDONLY);
    if (fd < 0) { perror("open"); return 1; }
    if (ioctl(fd, DIOCGPART, &pi) < 0) { perror("DIOCGPART"); return 1; }
    printf("%s: media_offset=%llu media_blocks=%llu blksize=%u reserved=%u\n",
        argv[1], (unsigned long long)pi.media_offset,
        (unsigned long long)pi.media_blocks, pi.media_blksize, pi.reserved_blocks);
    return 0;
}
