* ENOSPC - There is no enough space in base mft to resize $ATTRIBUTE_LIST.
*/
static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize,
- BOOL force_non_resident)
+ hole_type holes)
{
ntfs_attr_search_ctx *ctx;
ntfs_volume *vol;
* attribute non-resident if the attribute type supports it. If it is
* smaller we can go ahead and attempt the resize.
*/
- if ((newsize < vol->mft_record_size) && !force_non_resident) {
+ if ((newsize < vol->mft_record_size) && (holes != HOLES_NONRES)) {
/* Perform the resize of the attribute record. */
if (!(ret = ntfs_resident_attr_value_resize(ctx->mrec, ctx->attr,
newsize))) {
* could cause the attribute to be made resident again,
* so size changes are not allowed.
*/
- if (force_non_resident) {
+ if (holes == HOLES_NONRES) {
ret = 0;
if (newsize != na->data_size) {
ntfs_log_error("Cannot change size when"
return (ret);
}
/* Resize non-resident attribute */
- return ntfs_attr_truncate_i(na, newsize, HOLES_OK);
+ return ntfs_attr_truncate_i(na, newsize, holes);
} else if (errno != ENOSPC && errno != EPERM) {
err = errno;
ntfs_log_perror("Failed to make attribute non-resident");
ntfs_inode_mark_dirty(tna->ni);
ntfs_attr_close(tna);
ntfs_attr_put_search_ctx(ctx);
- return ntfs_resident_attr_resize_i(na, newsize, force_non_resident);
+ return ntfs_resident_attr_resize_i(na, newsize, holes);
}
/* Check whether error occurred. */
if (errno != ENOENT) {
ntfs_log_perror("Could not free space in MFT record");
return -1;
}
- return ntfs_resident_attr_resize_i(na, newsize, force_non_resident);
+ return ntfs_resident_attr_resize_i(na, newsize, holes);
}
/*
ntfs_attr_put_search_ctx(ctx);
if (ntfs_inode_add_attrlist(ni))
return -1;
- return ntfs_resident_attr_resize_i(na, newsize, force_non_resident);
+ return ntfs_resident_attr_resize_i(na, newsize, holes);
}
/* Allocate new mft record. */
ni = ntfs_mft_record_alloc(vol, ni);
ntfs_attr_put_search_ctx(ctx);
/* Try to perform resize once again. */
- return ntfs_resident_attr_resize_i(na, newsize, force_non_resident);
+ return ntfs_resident_attr_resize_i(na, newsize, holes);
resize_done:
/*
int ret;
ntfs_log_enter("Entering\n");
- ret = ntfs_resident_attr_resize_i(na, newsize, FALSE);
+ ret = ntfs_resident_attr_resize_i(na, newsize, HOLES_OK);
ntfs_log_leave("\n");
return ret;
}
{
int res;
- res = ntfs_resident_attr_resize_i(na, na->data_size, TRUE);
+ res = ntfs_resident_attr_resize_i(na, na->data_size, HOLES_NONRES);
if (!res && !NAttrNonResident(na)) {
res = -1;
errno = EIO;
else
ret = ntfs_non_resident_attr_shrink(na, fullsize);
} else
- ret = ntfs_resident_attr_resize(na, newsize);
+ ret = ntfs_resident_attr_resize_i(na, newsize, holes);
out:
ntfs_log_leave("Return status %d\n", ret);
return ret;