]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: fix symlink bug in integrity test
authorAdrian Hunter <ext-adrian.hunter@nokia.com>
Tue, 12 Aug 2008 11:08:06 +0000 (14:08 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 13 Aug 2008 15:43:29 +0000 (18:43 +0300)
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/integck.c

index f1a544ab266e2c59f19b7dfcadcb582de316719e..be93d3e0cc2881edd544dfc20eb83c5148c2b21f 100644 (file)
@@ -1655,22 +1655,31 @@ static char *pick_symlink_target(const char *symlink_path)
        return rel_path;
 }
 
-static void symlink_new(struct dir_info *dir, const char *name)
+static void symlink_new(struct dir_info *dir, const char *name_)
 {
        struct symlink_info *s;
-       char *path;
+       char *path, *target, *name = copy_string(name_);
        size_t sz;
 
+       path = dir_path(dir, name);
+       target = pick_symlink_target(path);
+       if (symlink(target, path) == -1) {
+               CHECK(errno == ENOSPC);
+               full = 1;
+               free(target);
+               free(path);
+               free(name);
+               return;
+       }
+       free(path);
+
        sz = sizeof(struct symlink_info);
        s = malloc(sz);
        CHECK(s != NULL);
        memset(s, 0, sz);
        add_dir_entry(dir, 's', name, s);
-
-       path = dir_path(dir, name);
-       s->target_pathname = pick_symlink_target(path);
-       CHECK(symlink(s->target_pathname, path) != -1);
-       free(path);
+       s->target_pathname = target;
+       free(name);
 }
 
 static void symlink_remove(struct symlink_info *symlink)