mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 15:03:53 +02:00
fs/ntfs3: Unify inode corruption marking with _ntfs_bad_inode()
Also reworked error handling in a couple of places. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
parent
2afd4d267e
commit
55ad333de0
|
@ -1407,7 +1407,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,
|
||||||
*/
|
*/
|
||||||
if (!attr->non_res) {
|
if (!attr->non_res) {
|
||||||
if (vbo[1] + bytes_per_off > le32_to_cpu(attr->res.data_size)) {
|
if (vbo[1] + bytes_per_off > le32_to_cpu(attr->res.data_size)) {
|
||||||
ntfs_inode_err(&ni->vfs_inode, "is corrupted");
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
addr = resident_data(attr);
|
addr = resident_data(attr);
|
||||||
|
@ -2588,7 +2588,7 @@ int attr_force_nonresident(struct ntfs_inode *ni)
|
||||||
|
|
||||||
attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, &mi);
|
attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, &mi);
|
||||||
if (!attr) {
|
if (!attr) {
|
||||||
ntfs_bad_inode(&ni->vfs_inode, "no data attribute");
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -512,7 +512,7 @@ out:
|
||||||
ctx->pos = pos;
|
ctx->pos = pos;
|
||||||
} else if (err < 0) {
|
} else if (err < 0) {
|
||||||
if (err == -EINVAL)
|
if (err == -EINVAL)
|
||||||
ntfs_inode_err(dir, "directory corrupted");
|
_ntfs_bad_inode(dir);
|
||||||
ctx->pos = eod;
|
ctx->pos = eod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,8 +148,10 @@ int ni_load_mi_ex(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = mi_get(ni->mi.sbi, rno, &r);
|
err = mi_get(ni->mi.sbi, rno, &r);
|
||||||
if (err)
|
if (err) {
|
||||||
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
ni_add_mi(ni, r);
|
ni_add_mi(ni, r);
|
||||||
|
|
||||||
|
@ -239,8 +241,7 @@ struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr,
|
||||||
return attr;
|
return attr;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ntfs_inode_err(&ni->vfs_inode, "failed to parse mft record");
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,6 +333,7 @@ struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type,
|
||||||
vcn <= le64_to_cpu(attr->nres.evcn))
|
vcn <= le64_to_cpu(attr->nres.evcn))
|
||||||
return attr;
|
return attr;
|
||||||
|
|
||||||
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1607,8 +1609,8 @@ int ni_delete_all(struct ntfs_inode *ni)
|
||||||
roff = le16_to_cpu(attr->nres.run_off);
|
roff = le16_to_cpu(attr->nres.run_off);
|
||||||
|
|
||||||
if (roff > asize) {
|
if (roff > asize) {
|
||||||
_ntfs_bad_inode(&ni->vfs_inode);
|
/* ni_enum_attr_ex checks this case. */
|
||||||
return -EINVAL;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run==1 means unpack and deallocate. */
|
/* run==1 means unpack and deallocate. */
|
||||||
|
|
|
@ -908,7 +908,11 @@ void ntfs_bad_inode(struct inode *inode, const char *hint)
|
||||||
|
|
||||||
ntfs_inode_err(inode, "%s", hint);
|
ntfs_inode_err(inode, "%s", hint);
|
||||||
make_bad_inode(inode);
|
make_bad_inode(inode);
|
||||||
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
/* Avoid recursion if bad inode is $Volume. */
|
||||||
|
if (inode->i_ino != MFT_REC_VOL &&
|
||||||
|
!(sbi->flags & NTFS_FLAGS_LOG_REPLAYING)) {
|
||||||
|
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1094,8 +1094,7 @@ int indx_read(struct ntfs_index *indx, struct ntfs_inode *ni, CLST vbn,
|
||||||
|
|
||||||
ok:
|
ok:
|
||||||
if (!index_buf_check(ib, bytes, &vbn)) {
|
if (!index_buf_check(ib, bytes, &vbn)) {
|
||||||
ntfs_inode_err(&ni->vfs_inode, "directory corrupted");
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
|
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1117,8 +1116,7 @@ ok:
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (err == -E_NTFS_CORRUPT) {
|
if (err == -E_NTFS_CORRUPT) {
|
||||||
ntfs_inode_err(&ni->vfs_inode, "directory corrupted");
|
_ntfs_bad_inode(&ni->vfs_inode);
|
||||||
ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR);
|
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,9 @@ end_enum:
|
||||||
if (!std5)
|
if (!std5)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (is_bad_inode(inode))
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (!is_match && name) {
|
if (!is_match && name) {
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user