diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2018-06-13 12:17:28 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-06-25 13:43:51 +0000 |
commit | e60d337201854e391fe32ceb86c72a4cb7f23467 (patch) | |
tree | f842386f8ca7952479f9e885879746a6cff9b8d7 /tests/basic/posix/zero-fill-enospace.c | |
parent | 6d19297f5bc09a6eb9d90aab5836fb099fe32783 (diff) |
storage/posix: Handle ENOSPC correctly in zero_fill
Change-Id: Icc521d86cc510f88b67d334b346095713899087a
BUG: 1591187
fixes: bz#1591187
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'tests/basic/posix/zero-fill-enospace.c')
-rw-r--r-- | tests/basic/posix/zero-fill-enospace.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/basic/posix/zero-fill-enospace.c b/tests/basic/posix/zero-fill-enospace.c new file mode 100644 index 00000000000..b1aaa57c9ca --- /dev/null +++ b/tests/basic/posix/zero-fill-enospace.c @@ -0,0 +1,64 @@ +#include <stdio.h> +#include <glusterfs/api/glfs.h> +#include <glusterfs/api/glfs-handles.h> + +int +main (int argc, char *argv[]) +{ + glfs_t *fs = NULL; + glfs_fd_t *fd = NULL; + int ret = 1; + int size = 0; + + if (argc != 6) { + fprintf (stderr, "Syntax: %s <host> <volname> <file-path> <log-file> <size>\n", argv[0]); + return 1; + } + + fs = glfs_new (argv[2]); + if (!fs) { + fprintf (stderr, "glfs_new: returned NULL\n"); + return 1; + } + + ret = glfs_set_volfile_server (fs, "tcp", argv[1], 24007); + if (ret != 0) { + fprintf (stderr, "glfs_set_volfile_server: retuned %d\n", ret); + goto out; + } + ret = glfs_set_logging (fs, argv[4], 7); + if (ret != 0) { + fprintf (stderr, "glfs_set_logging: returned %d\n", ret); + goto out; + } + ret = glfs_init (fs); + if (ret != 0) { + fprintf (stderr, "glfs_init: returned %d\n", ret); + goto out; + } + + fd = glfs_open (fs, argv[3], O_RDWR); + if (fd == NULL) { + fprintf (stderr, "glfs_open: returned NULL\n"); + goto out; + } + + size = atoi(argv[5]); + if (size < 0) { + fprintf (stderr, "Wrong size %s", argv[5]); + goto out; + } + ret = glfs_zerofill (fd, 0, atoi(argv[5])); + if (ret <= 0) { + fprintf (stderr, "glfs_zerofill: returned %d\n", ret); + goto out; + } + + ret = 0; + +out: + if (fd) + glfs_close(fd); + glfs_fini (fs); + return ret; +} |