exFAT file system implementation library.
Free exFAT implementation.
- Copyright (C) 2010-2017 Andrew Nayenko
+ Copyright (C) 2010-2023 Andrew Nayenko
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
for (i = start_index; i < end_index; i++)
{
- if (bitmap[i] == ~((bitmap_t) 0))
+ if (bitmap[i] == (bitmap_t) ~((bitmap_t) 0))
continue;
start_bitindex = MAX(i * sizeof(bitmap_t) * 8, start);
end_bitindex = MIN((i + 1) * sizeof(bitmap_t) * 8, end);
shrink_file(ef, node, current + allocated, allocated);
return -ENOSPC;
}
- if (next != previous - 1 && node->is_contiguous)
+ if (next != previous + 1 && node->is_contiguous)
{
/* it's a pity, but we are not able to keep the file contiguous
anymore */
if (erase)
{
- rc = erase_range(ef, node, node->size, size);
+ rc = erase_range(ef, node, node->valid_size, size);
if (rc != 0)
return rc;
+ node->valid_size = size;
+ }
+ else
+ {
+ node->valid_size = MIN(node->valid_size, size);
}
exfat_update_mtime(node);