3 Prints detailed information about exFAT volume.
5 Copyright (C) 2010 Andrew Nayenko
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 static void dump_sb(const struct exfat_super_block* sb)
30 printf("First block %8"PRIu64"\n",
31 le64_to_cpu(sb->block_start));
32 printf("Blocks count %8"PRIu64"\n",
33 le64_to_cpu(sb->block_count));
34 printf("FAT first block %8u\n",
35 le32_to_cpu(sb->fat_block_start));
36 printf("FAT blocks count %8u\n",
37 le32_to_cpu(sb->fat_block_count));
38 printf("First cluster block %8u\n",
39 le32_to_cpu(sb->cluster_block_start));
40 printf("Clusters count %8u\n",
41 le32_to_cpu(sb->cluster_count));
42 printf("Root directory cluster %8u\n",
43 le32_to_cpu(sb->rootdir_cluster));
44 printf("Volume serial number 0x%08x\n",
45 le32_to_cpu(sb->volume_serial));
46 printf("FS version %hhu.%hhu\n",
47 sb->version.major, sb->version.minor);
48 printf("Volume state 0x%04hx\n",
49 le16_to_cpu(sb->volume_state));
50 printf("Block size %8u\n",
52 printf("Cluster size %8u\n",
54 printf("FATs count %8hhu\n",
56 printf("Drive number 0x%02hhx\n",
58 printf("Allocated space %7hhu%%\n",
59 sb->allocated_percent);
62 int main(int argc, char* argv[])
65 struct exfat_super_block sb;
69 fprintf(stderr, "Usage: %s <device>\n", argv[0]);
73 fd = open(argv[1], O_RDONLY);
76 fprintf(stderr, "failed to open `%s'\n", argv[1]);
79 if (read(fd, &sb, sizeof(struct exfat_super_block))
80 != sizeof(struct exfat_super_block))
83 fprintf(stderr, "failed to read from `%s'.\n", argv[1]);
86 if (memcmp(sb.oem_name, "EXFAT ", sizeof(sb.oem_name)) != 0)
89 fprintf(stderr, "exFAT file system is not found on `%s'.\n", argv[1]);