for (i = node->fptr_index; i < count; i++)
{
node->fptr_cluster = exfat_next_cluster(ef, node, node->fptr_cluster);
- if (CLUSTER_INVALID(node->fptr_cluster))
+ if (CLUSTER_INVALID(*ef->sb, node->fptr_cluster))
break; /* the caller should handle this and print appropriate
error message */
}
static void free_cluster(struct exfat* ef, cluster_t cluster)
{
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
exfat_bug("freeing invalid cluster 0x%x", cluster);
if (cluster - EXFAT_FIRST_DATA_CLUSTER >= ef->cmap.size)
exfat_bug("freeing non-existing cluster 0x%x (0x%x)", cluster,
{
/* get the last cluster of the file */
previous = exfat_advance_cluster(ef, node, current - 1);
- if (CLUSTER_INVALID(previous))
+ if (CLUSTER_INVALID(*ef->sb, previous))
{
exfat_error("invalid cluster 0x%x while growing", previous);
return -EIO;
/* file does not have clusters (i.e. is empty), allocate
the first one for it */
previous = allocate_cluster(ef, 0);
- if (CLUSTER_INVALID(previous))
+ if (CLUSTER_INVALID(*ef->sb, previous))
return -ENOSPC;
node->fptr_cluster = node->start_cluster = previous;
allocated = 1;
while (allocated < difference)
{
next = allocate_cluster(ef, previous + 1);
- if (CLUSTER_INVALID(next))
+ if (CLUSTER_INVALID(*ef->sb, next))
{
if (allocated != 0)
shrink_file(ef, node, current + allocated, allocated);
{
cluster_t last = exfat_advance_cluster(ef, node,
current - difference - 1);
- if (CLUSTER_INVALID(last))
+ if (CLUSTER_INVALID(*ef->sb, last))
{
exfat_error("invalid cluster 0x%x while shrinking", last);
return -EIO;
/* free remaining clusters */
while (difference--)
{
- if (CLUSTER_INVALID(previous))
+ if (CLUSTER_INVALID(*ef->sb, previous))
{
exfat_error("invalid cluster 0x%x while freeing after shrink",
previous);
return -EIO;
}
+
next = exfat_next_cluster(ef, node, previous);
if (!set_next_cluster(ef, node->is_contiguous, previous,
EXFAT_CLUSTER_FREE))
cluster_boundary = (begin | (CLUSTER_SIZE(*ef->sb) - 1)) + 1;
cluster = exfat_advance_cluster(ef, node,
begin / CLUSTER_SIZE(*ef->sb));
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
{
exfat_error("invalid cluster 0x%x while erasing", cluster);
return -EIO;
{
cluster = exfat_next_cluster(ef, node, cluster);
/* the cluster cannot be invalid because we have just allocated it */
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
exfat_bug("invalid cluster 0x%x after allocation", cluster);
if (!erase_raw(ef, CLUSTER_SIZE(*ef->sb), exfat_c2o(ef, cluster)))
return -EIO;
return 0;
cluster = exfat_advance_cluster(ef, node, offset / CLUSTER_SIZE(*ef->sb));
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
{
exfat_error("invalid cluster 0x%x while reading", cluster);
return -EIO;
remainder = MIN(size, node->size - offset);
while (remainder > 0)
{
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
{
exfat_error("invalid cluster 0x%x while reading", cluster);
return -EIO;
return 0;
cluster = exfat_advance_cluster(ef, node, offset / CLUSTER_SIZE(*ef->sb));
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
{
exfat_error("invalid cluster 0x%x while writing", cluster);
return -EIO;
remainder = size;
while (remainder > 0)
{
- if (CLUSTER_INVALID(cluster))
+ if (CLUSTER_INVALID(*ef->sb, cluster))
{
exfat_error("invalid cluster 0x%x while writing", cluster);
return -EIO;
node->start_cluster);
ret = false;
}
- if (node->size > 0 && CLUSTER_INVALID(node->start_cluster))
+ if (node->size > 0 && CLUSTER_INVALID(*ef->sb, node->start_cluster))
{
exfat_get_name(node, buffer);
exfat_error("'%s' points to invalid cluster %#x", buffer,
if (ef->upcase != NULL)
break;
upcase = (const struct exfat_entry_upcase*) &entry;
- if (CLUSTER_INVALID(le32_to_cpu(upcase->start_cluster)))
+ if (CLUSTER_INVALID(*ef->sb, le32_to_cpu(upcase->start_cluster)))
{
exfat_error("invalid cluster 0x%x in upcase table",
le32_to_cpu(upcase->start_cluster));
case EXFAT_ENTRY_BITMAP:
bitmap = (const struct exfat_entry_bitmap*) &entry;
ef->cmap.start_cluster = le32_to_cpu(bitmap->start_cluster);
- if (CLUSTER_INVALID(ef->cmap.start_cluster))
+ if (CLUSTER_INVALID(*ef->sb, ef->cmap.start_cluster))
{
exfat_error("invalid cluster 0x%x in clusters bitmap",
ef->cmap.start_cluster);