summaryrefslogtreecommitdiff
path: root/lib/ext2fs/test_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/test_io.c')
-rw-r--r--lib/ext2fs/test_io.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index 1bd09b1e..a82f0946 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -104,6 +104,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
io->block_size = 1024;
io->read_error = 0;
io->write_error = 0;
+ io->refcount = 1;
memset(data, 0, sizeof(struct test_private_data));
data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL;
@@ -138,6 +139,9 @@ static errcode_t test_close(io_channel channel)
data = (struct test_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
+ if (--channel->refcount > 0)
+ return 0;
+
if (data->real)
retval = io_channel_close(data->real);