While testing some stuff in generic_write_checks() in the
kernel I realized that you can't actually use xfs_io to send
a 0-byte write in. This is actually a condition worth testing:
If count is zero and fd refers to a regular file,
then write() may return a failure status if one of
the errors below is detected. If no errors are
detected, 0 will be returned without causing any
other effect.
So fix that up.
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
int ops = 0;
*total = 0;
- while (count > 0) {
+ while (count >= 0) {
if (fd > 0) { /* input file given, read buffer first */
if (read_buffer(fd, skip + *total, bs, &bar, 0, 1) < 0)
break;
break;
offset += bytes;
count -= bytes;
+ if (count == 0)
+ break;
}
return ops;
}