On Wed, 28 November 2007 20:27:11 -0700, Andreas Dilger wrote:
That could work. There really isn't a reason for any application to
mess with physical locations when dealing with logfs.
It has the advantage of being easy to use. My completely untested
attempt at a copy loop is just 14 lines. Add some error handling and it
should still be quite small.
off_t data_ofs, hole_ofs;
long count;
for (data_ofs = hole_ofs = 0; ; ) {
if (data_ofs >= hole_ofs) {
data_ofs = llseek(in_fd, data_ofs, SEEK_DATA);
hole_ofs = llseek(in_fd, data_ofs, SEEK_HOLE);
}
count = splice(in_fd, &data_ofs, out_fd, &data_ofs,
hole_ofs - data_ofs, 0);
if (count == 0)
break;
data_ofs += count;
}
And when trying to optimize away some of the system calls, my personal
preference would be to teach splice about seek_hole and seek_data and
just splice the complete file range in one go.
Jörn
--
"Security vulnerabilities are here to stay."
-- Scott Culp, Manager of the Microsoft Security Response Center, 2001
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html