aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-14 13:12:48 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-22 14:29:51 +0300
commitc251867ba21ea2919831ee2349c77fb773ba5b6b (patch)
tree7ab636958727901d2b0a498b4ed9d69f5132ca12 /tests
parent99d35f31fccfe7812c56ac290168c6a79f6c8864 (diff)
fs-tests: integck: handle write failures in dir_new
Do not die in 'dir_new()' if it cannot create a new directory and this is not because of ENOSPC. Return NULL for all errors. Note, not all callers are ready to properly handle all errors so far. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/fs-tests/integrity/integck.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index dd1ba1c..d138a7d 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -284,19 +284,12 @@ static char *cat_strings(const char *a, const char *b)
static char *cat_paths(const char *a, const char *b)
{
char *str;
- size_t sz;
- int as, bs;
- size_t na, nb;
+ size_t sz, na, nb;
+ int as = 0, bs = 0;
- if (a && !b)
- return dup_string(a);
- if (b && !a)
- return dup_string(b);
- if (!a && !b)
- return NULL;
+ assert(a != NULL);
+ assert(b != NULL);
- as = 0;
- bs = 0;
na = strlen(a);
nb = strlen(b);
if (na && a[na - 1] == '/')
@@ -333,8 +326,7 @@ static void get_fs_space(uint64_t *total, uint64_t *free)
static char *dir_path(struct dir_info *parent, const char *name)
{
- char *parent_path;
- char *path;
+ char *parent_path, *path;
if (!parent)
return cat_paths(fsinfo.mount_point, name);
@@ -454,6 +446,12 @@ static void remove_dir_entry(struct dir_entry_info *entry)
free(entry);
}
+/*
+ * Create a new directory "name" in the parent directory described by "parent"
+ * and add it to the in-memory list of directories. In case of success, returns
+ * a pointer to the new 'struct dir_info' object. Returns 'NULL' in case of
+ * failure.
+ */
static struct dir_info *dir_new(struct dir_info *parent, const char *name)
{
struct dir_info *dir;
@@ -461,8 +459,10 @@ static struct dir_info *dir_new(struct dir_info *parent, const char *name)
path = dir_path(parent, name);
if (mkdir(path, 0777) != 0) {
- CHECK(errno == ENOSPC);
- full = 1;
+ if (errno == ENOSPC)
+ full = 1;
+ else
+ pcv("cannot create directory %s", path);
free(path);
return NULL;
}
@@ -2167,7 +2167,7 @@ void remount_tested_fs(void)
static int integck(void)
{
int ret;
- int64_t rpt;
+ long rpt;
CHECK(chdir(fsinfo.mount_point) == 0);