diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-04-18 12:48:50 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-04-22 14:29:51 +0300 |
commit | f17494d93bb8b4d95ead5fa18b8893a645820d8c (patch) | |
tree | e0a6f673856421cbb743d31fd926392c3e64139b /tests/fs-tests/integrity | |
parent | 30f39fa07e630349a7e360f3f6e88352fa82b947 (diff) |
fs-tests: integck: make file_new return error on create failure
Teach 'file_new()' to return -1 if it fails to create a file.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'tests/fs-tests/integrity')
-rw-r--r-- | tests/fs-tests/integrity/integck.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index f2223d4..471fcf4 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -509,23 +509,27 @@ static void dir_remove(struct dir_info *dir) free(dir); } -static struct file_info *file_new(struct dir_info *parent, const char *name) +static int file_new(struct dir_info *parent, const char *name) { - struct file_info *file = NULL; + struct file_info *file; char *path; mode_t mode; int fd; - CHECK(parent != NULL); + assert(parent != NULL); path = dir_path(parent, name); mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; fd = open(path, O_CREAT | O_EXCL | O_RDWR, mode); if (fd == -1) { - CHECK(errno == ENOSPC); + if (errno == ENOSPC) { + full = 1; + free(path); + return 0; + } + pcv("cannot create file %s", path); free(path); - full = 1; - return NULL; + return -1; } free(path); @@ -533,10 +537,8 @@ static struct file_info *file_new(struct dir_info *parent, const char *name) file->name = dup_string(name); add_dir_entry(parent, 'f', name, file); - add_fd(file, fd); - - return file; + return 0; } static void link_new(struct dir_info *parent, const char *name, @@ -1932,7 +1934,7 @@ static int operate_on_dir(struct dir_info *dir) r = random_no(14); if (r == 0 && grow) /* When growing, 1 time in 14 create a file */ - file_new(dir, make_name(dir)); + return file_new(dir, make_name(dir)); else if (r == 1 && grow) /* When growing, 1 time in 14 create a directory */ dir_new(dir, make_name(dir)); |