static int dump_full(const char* spec, bool used_sectors) { struct exfat ef; uint32_t free_clusters; uint64_t free_sectors; if (exfat_mount(&ef, spec, "ro") != 0) return 1; free_clusters = exfat_count_free_clusters(&ef); free_sectors = (uint64_t) free_clusters << ef.sb->spc_bits; printf("Volume label %15s\n", exfat_get_label(&ef)); print_generic_info(ef.sb); print_sector_info(ef.sb); printf("Free sectors %10"PRIu64"\n", free_sectors); print_cluster_info(ef.sb); printf("Free clusters %10u\n", free_clusters); print_other_info(ef.sb); if (used_sectors) dump_sectors(&ef); exfat_unmount(&ef); return 0; }
int main(int argc, char* argv[]) { char** pp; struct exfat ef; int rc = 0; for (pp = argv + 1; *pp; pp++) if (strcmp(*pp, "-V") == 0) { printf("exfatlabel %u.%u.%u\n", EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH); puts("Copyright (C) 2011-2013 Andrew Nayenko"); return 0; } if (argc != 2 && argc != 3) { fprintf(stderr, "Usage: %s [-V] <device> [label]\n", argv[0]); return 1; } if (argv[2]) { if (exfat_mount(&ef, argv[1], "") != 0) return 1; rc = (exfat_set_label(&ef, argv[2]) != 0); } else { if (exfat_mount(&ef, argv[1], "ro") != 0) return 1; puts(exfat_get_label(&ef)); } exfat_unmount(&ef); return rc; }