KR> - lseek(ctx->fd, 0, SEEK_SET);
KR> + close(ctx->fd);
KR> + ctx->fd = open(ctx->filename, O_RDWR|O_TRUNC, 0600);
KR> + if (ctx->fd < 0) {
KR> + CU_DEBUG("Unable to open `%s': %m",
ctx->filename);
KR> + goto out;
KR> + }
Why not just leave the lseek() in place, and then call an ftruncate() on
the file descriptor? That saves us from adding all the infrastructure
for saving the filename, etc.
It's my fault for not calling for the truncate in the original
code... Good catch!
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com