Remove inode.h::NIno{Clear,Set,}AttrListNonResident and attr_list_rl field from inode.h::_ntfs_inode struct. Adapt all users.
(Logical change 1.600)edge.strict_endians
parent
07a8918a4c
commit
419e3ce8b7
|
@ -84,6 +84,8 @@ xx/xx/2004 - 2.0.0-WIP
|
|||
- Make ntfs_attr_update_mapping_pairs and ntfs_inode_add_attrlist use
|
||||
ntfs_inode_free_space when there is no enough space for attribute
|
||||
list. (Yura)
|
||||
- Remove inode.h::NIno{Clear,Set,}AttrListNonResident and attr_list_rl
|
||||
field from inode.h::_ntfs_inode struct. Adapt all users. (Yura)
|
||||
|
||||
04/09/2004 - 1.9.4 - Urgent bug fixes.
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ typedef enum {
|
|||
|
||||
/* The NI_AttrList* tests only make sense for base inodes. */
|
||||
NI_AttrList, /* 1: Mft record contains an attribute list. */
|
||||
NI_AttrListNonResident, /* 1: Attribute list is non-resident. Implies
|
||||
NI_AttrList is set. */
|
||||
NI_AttrListDirty, /* 1: Attribute list needs to be written to the
|
||||
mft record and then to disk. */
|
||||
} ntfs_inode_state_bits;
|
||||
|
@ -74,10 +72,6 @@ typedef enum {
|
|||
#define test_and_clear_nino_al_flag(ni, flag) \
|
||||
test_and_clear_nino_flag(ni, AttrList##flag)
|
||||
|
||||
#define NInoAttrListNonResident(ni) test_nino_al_flag(ni, NonResident)
|
||||
#define NInoSetAttrListNonResident(ni) set_nino_al_flag(ni, NonResident)
|
||||
#define NInoClearAttrListNonResident(ni) clear_nino_al_flag(ni, NonResident)
|
||||
|
||||
#define NInoAttrListDirty(ni) test_nino_al_flag(ni, Dirty)
|
||||
#define NInoAttrListSetDirty(ni) set_nino_al_flag(ni, Dirty)
|
||||
#define NInoAttrListClearDirty(ni) clear_nino_al_flag(ni, Dirty)
|
||||
|
@ -97,12 +91,10 @@ struct _ntfs_inode {
|
|||
/*
|
||||
* Attribute list support (for use by the attribute lookup functions).
|
||||
* Setup during ntfs_open_inode() for all inodes with attribute lists.
|
||||
* Only valid if NI_AttrList is set in state, further attr_list_rl is
|
||||
* only valid if NI_AttrListNonResident is set.
|
||||
* Only valid if NI_AttrList is set in state.
|
||||
*/
|
||||
u32 attr_list_size; /* Length of attribute list value in bytes. */
|
||||
u8 *attr_list; /* Attribute list value itself. */
|
||||
runlist *attr_list_rl; /* Run list for the attribute list value. */
|
||||
/* Below fields are always valid. */
|
||||
s32 nr_extents; /* For a base mft record, the number of
|
||||
attached extent inodes (0 if none), for
|
||||
|
|
|
@ -2589,10 +2589,7 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx) {
|
|||
if (type == AT_ATTRIBUTE_LIST) {
|
||||
if (NInoAttrList(base_ni) && base_ni->attr_list)
|
||||
free(base_ni->attr_list);
|
||||
if (NInoAttrListNonResident(base_ni) && base_ni->attr_list_rl)
|
||||
free(base_ni->attr_list_rl);
|
||||
NInoClearAttrList(base_ni);
|
||||
NInoClearAttrListNonResident(base_ni);
|
||||
NInoAttrListClearDirty(base_ni);
|
||||
}
|
||||
|
||||
|
@ -2629,15 +2626,24 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx) {
|
|||
return 0;
|
||||
}
|
||||
/* Deallocate clusters. */
|
||||
if (NInoAttrListNonResident(base_ni)) {
|
||||
if (ntfs_cluster_free_from_rl(base_ni->vol,
|
||||
base_ni->attr_list_rl)) {
|
||||
Dprintf("%s(): Leaking clusters! Run chkdsk. "
|
||||
"Couldn't free clusters from attribute "
|
||||
if (ctx->attr->non_resident) {
|
||||
runlist *al_rl;
|
||||
|
||||
al_rl = ntfs_mapping_pairs_decompress(base_ni->vol,
|
||||
ctx->attr, NULL);
|
||||
if (!al_rl) {
|
||||
Dprintf("%s(): Couldn't decompress attribute "
|
||||
"list runlist. Succeed anyway.\n",
|
||||
__FUNCTION__);
|
||||
__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
if (ntfs_cluster_free_from_rl(base_ni->vol, al_rl)) {
|
||||
Dprintf("%s(): Leaking clusters! Run chkdsk. "
|
||||
"Couldn't free clusters from attribute "
|
||||
"list runlist.\n",
|
||||
__FUNCTION__);
|
||||
}
|
||||
free(al_rl);
|
||||
}
|
||||
/* Remove attribute record itself. */
|
||||
if (ntfs_attr_record_rm(ctx)) {
|
||||
|
|
|
@ -98,8 +98,6 @@ int ntfs_attrlist_need(ntfs_inode *ni)
|
|||
int ntfs_attrlist_set(ntfs_inode *ni, u8 *new_al, int new_al_len)
|
||||
{
|
||||
ntfs_attr *na = NULL;
|
||||
runlist *rl;
|
||||
int rl_size;
|
||||
int err;
|
||||
|
||||
if (!ni || !new_al || new_al_len < 1) {
|
||||
|
@ -145,66 +143,6 @@ int ntfs_attrlist_set(ntfs_inode *ni, u8 *new_al, int new_al_len)
|
|||
goto err_out;
|
||||
}
|
||||
|
||||
/* Update in-memory ntfs inode. */
|
||||
if (NAttrNonResident(na)) {
|
||||
/* Create copy of new runlist. */
|
||||
if (ntfs_attr_map_whole_runlist(na)) {
|
||||
/*
|
||||
* FIXME: Probably leaving inconsist na->attr_list_rl.
|
||||
* What shall we do here? We can't simply restore old
|
||||
* attribute list, because attributes maybe moved. But
|
||||
* we can't get runlist for new attribute list so we
|
||||
* can't update in-memory structs.
|
||||
*/
|
||||
Dprintf("%s(): Failed to map runlist. Probably leaving "
|
||||
"inconsist na->attr_list_rl.\n", __FUNCTION__);
|
||||
if (ntfs_attr_truncate(na, ni->attr_list_size))
|
||||
Dprintf("%s(): Rollback failed. Leaving "
|
||||
"inconsist metadata.\n", __FUNCTION__);
|
||||
if (NAttrNonResident(na))
|
||||
NInoSetAttrListNonResident(ni);
|
||||
else
|
||||
NInoClearAttrListNonResident(ni);
|
||||
err = EIO;
|
||||
goto err_out;
|
||||
}
|
||||
for (rl = na->rl, rl_size = 1; rl->length; rl++)
|
||||
rl_size++;
|
||||
rl_size = (rl_size * sizeof(runlist_element) + 0xfff) & ~0xfff;
|
||||
rl = malloc(rl_size);
|
||||
if (!rl) {
|
||||
/*
|
||||
* FIXME: Probably leaving inconsist na->attr_list_rl.
|
||||
* What shall we do here? We can't simply restore old
|
||||
* attribute list, because attributes maybe moved. But
|
||||
* we can't get runlist for new attribute list so we
|
||||
* can't update in-memory structs.
|
||||
*/
|
||||
Dprintf("%s(): Not enough memory. Probably leaving "
|
||||
"inconsist na->attr_list_rl.\n", __FUNCTION__);
|
||||
if (ntfs_attr_truncate(na, ni->attr_list_size))
|
||||
Dprintf("%s(): Rollback failed. Leaving "
|
||||
"inconsist metadata.\n", __FUNCTION__);
|
||||
if (NAttrNonResident(na))
|
||||
NInoSetAttrListNonResident(ni);
|
||||
else
|
||||
NInoClearAttrListNonResident(ni);
|
||||
err = ENOMEM;
|
||||
goto err_out;
|
||||
}
|
||||
memcpy(rl, na->rl, rl_size);
|
||||
if (NInoAttrListNonResident(ni) && ni->attr_list_rl)
|
||||
free(ni->attr_list_rl);
|
||||
ni->attr_list_rl = rl;
|
||||
NInoSetAttrListNonResident(ni);
|
||||
} else {
|
||||
if (NInoAttrListNonResident(ni)) {
|
||||
if (ni->attr_list_rl)
|
||||
free(ni->attr_list_rl);
|
||||
NInoClearAttrListNonResident(ni);
|
||||
}
|
||||
}
|
||||
|
||||
/* Done! */
|
||||
ntfs_attr_close(na);
|
||||
return 0;
|
||||
|
|
|
@ -72,8 +72,6 @@ static __inline__ int __ntfs_inode_release(ntfs_inode *ni)
|
|||
Dputs("Eeek. Discarding dirty inode!");
|
||||
if (NInoAttrList(ni) && ni->attr_list)
|
||||
free(ni->attr_list);
|
||||
if (NInoAttrListNonResident(ni) && ni->attr_list_rl)
|
||||
free(ni->attr_list_rl);
|
||||
if (ni->mrec)
|
||||
free(ni->mrec);
|
||||
free(ni);
|
||||
|
@ -98,9 +96,7 @@ static __inline__ int __ntfs_inode_release(ntfs_inode *ni)
|
|||
* Finally, search for an attribute list attribute in the mft record and if one
|
||||
* is found, load the attribute list attribute value and attach it to the
|
||||
* ntfs_inode structure (->attr_list). Also set the NI_AttrList bit to indicate
|
||||
* this as well as the NI_AttrListNonResident bit if the the attribute list is
|
||||
* non-resident. In that case, also attach the decompressed runlist to the
|
||||
* ntfs_inode structure (->attr_list_rl).
|
||||
* this.
|
||||
*
|
||||
* Return a pointer to the ntfs_inode structure on success or NULL on error,
|
||||
* with errno set to the error code.
|
||||
|
@ -155,20 +151,8 @@ ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref)
|
|||
err = EIO;
|
||||
goto put_err_out;
|
||||
}
|
||||
if (!ctx->attr->non_resident) {
|
||||
/* Attribute list attribute is resident so we are done. */
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return ni;
|
||||
}
|
||||
NInoSetAttrListNonResident(ni);
|
||||
// FIXME: We are duplicating work here! (AIA)
|
||||
ni->attr_list_rl = ntfs_mapping_pairs_decompress(vol, ctx->attr, NULL);
|
||||
if (ni->attr_list_rl) {
|
||||
/* We got the runlist, so we are done. */
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return ni;
|
||||
}
|
||||
err = EIO;
|
||||
ntfs_attr_put_search_ctx(ctx);
|
||||
return ni;
|
||||
put_err_out:
|
||||
if (!err)
|
||||
err = errno;
|
||||
|
|
|
@ -200,17 +200,6 @@ static int ntfs_mft_load(ntfs_volume *vol)
|
|||
"$MFT/$ATTRIBUTE_LIST.");
|
||||
goto io_error_exit;
|
||||
}
|
||||
if (ctx->attr->non_resident) {
|
||||
NInoSetAttrListNonResident(vol->mft_ni);
|
||||
// FIXME: We are duplicating work here! (AIA)
|
||||
vol->mft_ni->attr_list_rl = ntfs_mapping_pairs_decompress(vol,
|
||||
ctx->attr, NULL);
|
||||
if (!vol->mft_ni->attr_list_rl) {
|
||||
Dperror("Error: failed to get runlist for "
|
||||
"$MFT/$ATTRIBUTE_LIST");
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
mft_has_no_attr_list:
|
||||
/* We now have a fully setup ntfs inode for $MFT in vol->mft_ni. */
|
||||
|
||||
|
|
Loading…
Reference in New Issue