From b2f2facc29ef1a0a04048ca67b55ba58f9a97177 Mon Sep 17 00:00:00 2001 From: "(none)!yura" <(none)!yura> Date: Sun, 26 Sep 2004 19:31:31 +0000 Subject: [PATCH] Make ntfs_attr_record_rm use ntfs_attrlist_need and delete attribute list if it is doesn't need. (Logical change 1.580) --- libntfs/attrib.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libntfs/attrib.c b/libntfs/attrib.c index f6695c48..9d63e962 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -2591,7 +2591,30 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx) { } if (type == AT_ATTRIBUTE_LIST || !NInoAttrList(base_ni)) return 0; - // FIXME: Remove $ATTRIBUTE_LIST if no extents left or it is size == 0. + if (!ntfs_attrlist_need(base_ni)) { + ntfs_attr_reinit_search_ctx(ctx); + if (ntfs_attr_lookup(AT_ATTRIBUTE_LIST, NULL, 0, IGNORE_CASE, + 0, NULL, 0, ctx)) { + /* + * FIXME: Should we succeed here? Definitely something + * goes wrong because NInoAttrList(base_ni) returned + * that we have got attribute list. + */ + Dprintf("%s(): Coudn't find attribute list. Succeed " + "anyway.\n", __FUNCTION__); + return 0; + } + if (ntfs_attr_record_rm(ctx)) { + /* + * FIXME: Should we succeed here? BTW, chkdsk doesn't + * complain if it find MFT record with attribute list, + * but wothout extents. + */ + Dprintf("%s(): Coudn't remove attribute list. Succeed " + "anyway.\n", __FUNCTION__); + return 0; + } + } return 0; }