summaryrefslogtreecommitdiff
path: root/tests/fs-tests/integrity/integck.c
diff options
context:
space:
mode:
authorAdrian Hunter <ext-adrian.hunter@nokia.com>2008-06-11 15:34:00 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-06-16 18:02:31 +0300
commitce6b30790d4cf6831ca261f2df8044ade9655be0 (patch)
tree13ef0a4c34216429651f2e6151a3a2788aac2778 /tests/fs-tests/integrity/integck.c
parenteec4f3ac96a28c4e5f54dd268fa195024ab2bebd (diff)
fs-tests: check link count in integrity test
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Diffstat (limited to 'tests/fs-tests/integrity/integck.c')
-rw-r--r--tests/fs-tests/integrity/integck.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 73eeab6..2e44419 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1144,6 +1144,7 @@ static void file_check(struct file_info *file, int fd)
off_t pos;
struct write_info *w;
struct dir_entry_info *entry;
+ struct stat st;
/* Do not check files that have errored */
if (!check_nospc_files && file->no_space_error)
@@ -1181,6 +1182,8 @@ static void file_check(struct file_info *file, int fd)
}
if (file->length > pos)
file_check_hole(file, fd, pos, file->length - pos);
+ CHECK(fstat(fd, &st) != -1);
+ CHECK(file->link_count == st.st_nlink);
if (open_and_close) {
CHECK(close(fd) != -1);
free(path);
@@ -1232,6 +1235,8 @@ static void dir_check(struct dir_info *dir)
struct dirent *ent;
unsigned checked = 0;
char *path;
+ int link_count = 2; /* Parent and dot */
+ struct stat st;
/* Create an array of entries */
sz = sizeof(struct dir_entry_info *);
@@ -1270,21 +1275,25 @@ static void dir_check(struct dir_info *dir)
}
CHECK(closedir(d) != -1);
CHECK(checked == dir->number_of_entries);
- free(path);
/* Now check each entry */
entry = dir->first;
while (entry) {
- if (entry->type == 'd')
+ if (entry->type == 'd') {
dir_check(entry->entry.dir);
- else if (entry->type == 'f')
+ link_count += 1; /* <subdir>/.. */
+ } else if (entry->type == 'f')
file_check(entry->entry.file, -1);
else
CHECK(0);
entry = entry->next;
}
+ CHECK(stat(path, &st) != -1);
+ CHECK(link_count == st.st_nlink);
+
free(entry_array);
+ free(path);
}
static void check_deleted_files(void)