File 0003-fsck-fix-return-value-of-check_inode.patch of Package exfatprogs

From 38f74dc623a2c429b19b32d250640ae9b1e4da46 Mon Sep 17 00:00:00 2001
From: Hyunchul Lee <hyc.lee@gmail.com>
Date: Mon, 24 Aug 2020 16:10:45 +0900
Subject: [PATCH 3/9] fsck: fix return value of check_inode

even if files cannot be repaired, check_inode could
return the value which means files are valid.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
(cherry picked from commit ea3ca90b53ea6c370fda7f893b3ac061a041aa50)
Acked-by: David Disseldorp <ddiss@suse.de>
---
 fsck/fsck.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 981d6ab..3618b0d 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -829,6 +829,7 @@ static int check_inode(struct exfat_de_iter *iter, struct exfat_inode *node)
 	struct exfat_dentry *dentry;
 	int ret = 0;
 	uint16_t checksum;
+	bool valid = true;
 
 	ret = check_clus_chain(exfat, node);
 	if (ret < 0)
@@ -839,7 +840,7 @@ static int check_inode(struct exfat_de_iter *iter, struct exfat_inode *node)
 		fsck_err(iter->parent, node,
 			"size %" PRIu64 " is greater than cluster heap\n",
 			node->size);
-		ret = -EINVAL;
+		valid = false;
 	}
 
 	if (node->size == 0 && node->is_contiguous) {
@@ -849,7 +850,7 @@ static int check_inode(struct exfat_de_iter *iter, struct exfat_inode *node)
 			dentry->stream_flags &= ~EXFAT_SF_CONTIGUOUS;
 			ret = 1;
 		} else
-			ret = -EINVAL;
+			valid = false;
 	}
 
 	if ((node->attr & ATTR_SUBDIR) &&
@@ -857,7 +858,7 @@ static int check_inode(struct exfat_de_iter *iter, struct exfat_inode *node)
 		fsck_err(iter->parent, node,
 			"directory size %" PRIu64 " is not divisible by %d\n",
 			node->size, exfat->clus_size);
-		ret = -EINVAL;
+		valid = false;
 	}
 
 	checksum = file_calc_checksum(iter);
@@ -869,10 +870,10 @@ static int check_inode(struct exfat_de_iter *iter, struct exfat_inode *node)
 			dentry->file_checksum = cpu_to_le16(checksum);
 			ret = 1;
 		} else
-			ret = -EINVAL;
+			valid = false;
 	}
 
-	return ret;
+	return valid ? ret : -EINVAL;
 }
 
 static int read_file_dentries(struct exfat_de_iter *iter,
-- 
2.35.3

openSUSE Build Service is sponsored by