X-Git-Url: http://git.sven.stormbind.net/?a=blobdiff_plain;ds=sidebyside;f=fsck%2Fmain.c;h=9eefd747d1936e74aa8c25fb0557d6a87742d19e;hb=ee70a1672ad3490ac6ef94296cd5819c80614fa2;hp=7ad5b26e0013ff0c8b15a7ae2c92aa6a556d9170;hpb=4cb393cfd9b0ab69392612521ee3dbe481ec492d;p=sven%2Fexfat-utils.git

diff --git a/fsck/main.c b/fsck/main.c
index 7ad5b26..9eefd74 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -2,7 +2,7 @@
 	main.c (02.09.09)
 	exFAT file system checker.
 
-	Copyright (C) 2009, 2010  Andrew Nayenko
+	Copyright (C) 2011-2013  Andrew Nayenko
 
 	This program is free software: you can redistribute it and/or modify
 	it under the terms of the GNU General Public License as published by
@@ -28,12 +28,13 @@
 
 uint64_t files_count, directories_count;
 
-static void nodeck(struct exfat* ef, struct exfat_node* node)
+static int nodeck(struct exfat* ef, struct exfat_node* node)
 {
 	const cluster_t cluster_size = CLUSTER_SIZE(*ef->sb);
 	cluster_t clusters = (node->size + cluster_size - 1) / cluster_size;
 	cluster_t c = node->start_cluster;
-	
+	int rc = 0;
+
 	while (clusters--)
 	{
 		if (CLUSTER_INVALID(c))
@@ -41,8 +42,9 @@ static void nodeck(struct exfat* ef, struct exfat_node* node)
 			char name[EXFAT_NAME_MAX + 1];
 
 			exfat_get_name(node, name, EXFAT_NAME_MAX);
-			exfat_error("file `%s' has invalid cluster", name);
-			return;
+			exfat_error("file `%s' has invalid cluster 0x%x", name, c);
+			rc = 1;
+			break;
 		}
 		if (BMAP_GET(ef->cmap.chunk, c - EXFAT_FIRST_DATA_CLUSTER) == 0)
 		{
@@ -50,9 +52,11 @@ static void nodeck(struct exfat* ef, struct exfat_node* node)
 
 			exfat_get_name(node, name, EXFAT_NAME_MAX);
 			exfat_error("cluster 0x%x of file `%s' is not allocated", c, name);
+			rc = 1;
 		}
 		c = exfat_next_cluster(ef, node, c);
 	}
+	return rc;
 }
 
 static void dirck(struct exfat* ef, const char* path)
@@ -68,6 +72,8 @@ static void dirck(struct exfat* ef, const char* path)
 		exfat_bug("directory `%s' is not found", path);
 	if (!(parent->flags & EXFAT_ATTRIB_DIR))
 		exfat_bug("`%s' is not a directory (0x%x)", path, parent->flags);
+	if (nodeck(ef, parent) != 0)
+		return;
 
 	path_length = strlen(path);
 	entry_path = malloc(path_length + 1 + EXFAT_NAME_MAX);
@@ -99,8 +105,10 @@ static void dirck(struct exfat* ef, const char* path)
 			dirck(ef, entry_path);
 		}
 		else
+		{
 			files_count++;
-		nodeck(ef, node);
+			nodeck(ef, node);
+		}
 		exfat_put_node(ef, node);
 	}
 	exfat_closedir(ef, &it);
@@ -133,7 +141,7 @@ int main(int argc, char* argv[])
 	{
 		if (strcmp(*pp, "-v") == 0)
 		{
-			puts("Copyright (C) 2009  Andrew Nayenko");
+			puts("Copyright (C) 2011-2013  Andrew Nayenko");
 			return 0;
 		}
 		else if (spec == NULL)