[PATCH 18/35] fs-tests: integck: teach link_new to return error on creation failure

Artem Bityutskiy dedekind1 at gmail.com
Wed Apr 20 06:18:51 EDT 2011


From: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
---
 tests/fs-tests/integrity/integck.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index fbf24fb..14d112f 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -542,8 +542,8 @@ static int file_new(struct dir_info *parent, const char *name)
 	return 0;
 }
 
-static void link_new(struct dir_info *parent, const char *name,
-		     struct file_info *file)
+static int link_new(struct dir_info *parent, const char *name,
+		    struct file_info *file)
 {
 	struct dir_entry_info *entry;
 	char *path, *target;
@@ -551,21 +551,26 @@ static void link_new(struct dir_info *parent, const char *name,
 
 	entry = file->links;
 	if (!entry)
-		return;
+		return 0;
+
 	path = dir_path(parent, name);
 	target = dir_path(entry->parent, entry->name);
 	ret = link(target, path);
 	if (ret != 0) {
-		CHECK(errno == ENOSPC);
+		if (errno == ENOSPC) {
+			ret = 0;
+			full = 1;
+		} else
+			pcv("cannot create hardlink %s in directory %s to file %s",
+			    path, parent->name, target);
 		free(target);
 		free(path);
-		full = 1;
-		return;
+		return ret;
 	}
 	free(target);
 	free(path);
-
 	add_dir_entry(parent, 'f', name, file);
+	return 0;
 }
 
 static void file_close(struct fd_info *fdi);
@@ -1952,7 +1957,7 @@ static int operate_on_dir(struct dir_info *dir)
 		return dir_new(dir, make_name(dir));
 	else if (r == 2 && grow && (file = pick_file()) != NULL)
 		/* When growing, 1 time in 14 create a hard link */
-		link_new(dir, make_name(dir), file);
+		return link_new(dir, make_name(dir), file);
 	else if (r == 3 && grow && random_no(5) == 0)
 		/* When growing, 1 time in 70 create a symbolic link */
 		return symlink_new(dir, make_name(dir));
-- 
1.7.2.3




More information about the linux-mtd mailing list