}
}
+#ifndef NO_IO_CACHE
/*
* Try to find a block in the cache. If the block is not found, and
* eldest is a non-zero pointer, then fill in eldest with the cache
}
return retval2;
}
+#endif /* NO_IO_CACHE */
static errcode_t unix_open(const char *name, int flags, io_channel *channel)
{
if (--channel->refcount > 0)
return 0;
+#ifndef NO_IO_CACHE
retval = flush_cached_blocks(channel, data, 0);
+#endif
if (close(data->dev) < 0)
retval = errno;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
if (channel->block_size != blksize) {
+#ifndef NO_IO_CACHE
if ((retval = flush_cached_blocks(channel, data, 0)))
return retval;
+#endif
channel->block_size = blksize;
free_cache(channel, data);
data = (struct unix_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+#ifdef NO_IO_CACHE
+ return raw_read_blk(channel, data, block, count, buf);
+#else
/*
* If we're doing an odd-sized read or a very large read,
* flush out the cache and then do a direct read.
}
}
return 0;
+#endif /* NO_IO_CACHE */
}
static errcode_t unix_write_blk(io_channel channel, unsigned long block,
data = (struct unix_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+#ifdef NO_IO_CACHE
+ return raw_write_blk(channel, data, block, count, buf);
+#else
/*
* If we're doing an odd-sized write or a very large write,
* flush out the cache completely and then do a direct write.
cp += channel->block_size;
}
return retval;
+#endif /* NO_IO_CACHE */
}
static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
data = (struct unix_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+#ifndef NO_IO_CACHE
/*
* Flush out the cache completely
*/
if ((retval = flush_cached_blocks(channel, data, 1)))
return retval;
+#endif
if (lseek(data->dev, offset, SEEK_SET) < 0)
return errno;
data = (struct unix_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+#ifndef NO_IO_CACHE
retval = flush_cached_blocks(channel, data, 0);
+#endif
fsync(data->dev);
return retval;
}