3 * exFAT file system implementation library.
5 * Created by Andrew Nayenko on 03.09.09.
6 * This software is distributed under the GNU General Public License
7 * version 3 or any later.
15 static uint32_t c2b(const struct exfat* ef, cluster_t cluster)
17 if (cluster < EXFAT_FIRST_DATA_CLUSTER)
18 exfat_bug("invalid cluster number %u", cluster);
19 return le32_to_cpu(ef->sb->cluster_block_start) +
20 ((cluster - EXFAT_FIRST_DATA_CLUSTER) << ef->sb->bpc_bits);
24 * Cluster to absolute offset.
26 off_t exfat_c2o(const struct exfat* ef, cluster_t cluster)
28 return (off_t) c2b(ef, cluster) << ef->sb->block_bits;
32 * Block to absolute offset.
34 static off_t b2o(const struct exfat* ef, uint32_t block)
36 return (off_t) block << ef->sb->block_bits;
39 cluster_t exfat_next_cluster(const struct exfat* ef, cluster_t cluster,
47 fat_offset = b2o(ef, le32_to_cpu(ef->sb->fat_block_start))
48 + cluster * sizeof(cluster_t);
49 exfat_read_raw(&next, sizeof(next), fat_offset, ef->fd);
53 cluster_t exfat_advance_cluster(const struct exfat* ef, cluster_t cluster,
54 int contiguous, uint32_t count)
58 for (i = 0; i < count; i++)
60 cluster = exfat_next_cluster(ef, cluster, contiguous);
61 if (CLUSTER_INVALID(cluster))