According to Linux man page, the system call read() may return zero to indicate
that end of file reached on success. So below here we need to convert the result
code to a customized one in this case as errno is not set and we actually want
let caller know something is going wrong.
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
VOID_TEMP_FAILURE_RETRY(::close(fd));
fd = -1; // defensive
if (r <= 0) {
- r = -errno;
+ if (r == 0) {
+ r = -EINVAL;
+ } else {
+ r = -errno;
+ }
derr << __func__ << " unable to read " << p << ": " << cpp_strerror(r) << dendl;
return r;
}