push_back(std::move(bp));
}
-int buffer::list::pread_file(const char *fn, uint64_t off, uint64_t len, std::string *error)
+ssize_t buffer::list::pread_file(const char *fn, uint64_t off, uint64_t len, std::string *error)
{
int fd = TEMP_FAILURE_RETRY(::open(fn, O_RDONLY|O_CLOEXEC));
if (fd < 0) {
if (off > st.st_size) {
std::ostringstream oss;
- oss << "bufferlist::read_file(" << fn << "): read error: size < offset";
+ oss << "bufferlist::read_file(" << fn << "): read error: size < offset "
+ << cpp_strerror(-1);
VOID_TEMP_FAILURE_RETRY(::close(fd));
- return -1;
+ return 0;
}
if (len > st.st_size - off) {
void write_stream(std::ostream &out) const;
void hexdump(std::ostream &out, bool trailing_newline = true) const;
- int pread_file(const char *fn, uint64_t off, uint64_t len, std::string *error);
+ ssize_t pread_file(const char *fn, uint64_t off, uint64_t len, std::string *error);
int read_file(const char *fn, std::string *error);
ssize_t read_fd(int fd, size_t len);
int write_file(const char *fn, int mode=0644);