mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
common: bufferlist::read_file: return read errors
Don't ignore errors when reading a file with buffer::list. Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
This commit is contained in:
parent
c846615d8b
commit
51462d6b83
@ -102,17 +102,27 @@ int buffer::list::read_file(const char *fn, bool silent)
|
||||
int got = 0;
|
||||
while (left > 0) {
|
||||
int r = ::read(fd, (void *)(bp.c_str() + got), left);
|
||||
if (r <= 0) {
|
||||
if (r == 0) {
|
||||
// Premature EOF.
|
||||
// Perhaps the file changed between stat() and read()?
|
||||
if (!silent) {
|
||||
derr << "bufferlist::read_file(" << fn << "): warning: got premature "
|
||||
<< "EOF:" << dendl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (r < 0) {
|
||||
int err = errno;
|
||||
if (err == EINTR) {
|
||||
// ignore EINTR, 'tis a silly error
|
||||
continue;
|
||||
}
|
||||
if (!silent) {
|
||||
derr << "buffer::list::read_file: read error:"
|
||||
derr << "bufferlist::read_file(" << fn << "): read error:"
|
||||
<< cpp_strerror(err) << dendl;
|
||||
}
|
||||
break;
|
||||
TEMP_FAILURE_RETRY(::close(fd));
|
||||
return -err;
|
||||
}
|
||||
got += r;
|
||||
left -= r;
|
||||
|
Loading…
Reference in New Issue
Block a user