| 1300 | } |
| 1301 | |
| 1302 | int dump_data(Formatter *formatter, bufferlist &bl, |
| 1303 | const std::string &dump_data_path) |
| 1304 | { |
| 1305 | auto ebliter = bl.cbegin(); |
| 1306 | data_section ds; |
| 1307 | ds.decode(ebliter); |
| 1308 | |
| 1309 | formatter->open_object_section("data_block"); |
| 1310 | formatter->dump_unsigned("offset", ds.offset); |
| 1311 | formatter->dump_unsigned("len", ds.len); |
| 1312 | if (!dump_data_path.empty()) { |
| 1313 | int fd = open(dump_data_path.c_str(), O_WRONLY|O_CREAT|O_LARGEFILE, 0666); |
| 1314 | if (fd == -1) { |
| 1315 | std::cerr << "open " << dump_data_path << " failed: " |
| 1316 | << cpp_strerror(errno) << std::endl; |
| 1317 | } else { |
| 1318 | int ret = ds.databl.write_fd(fd, ds.offset); |
| 1319 | if (ret < 0) { |
| 1320 | std::cerr << "write " << dump_data_path << " failed: " |
| 1321 | << cpp_strerror(ret) << std::endl; |
| 1322 | } else { |
| 1323 | formatter->dump_string("file", dump_data_path); |
| 1324 | } |
| 1325 | close(fd); |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | formatter->close_section(); |
| 1330 | formatter->flush(cout); |
| 1331 | return 0; |
| 1332 | } |
| 1333 | |
| 1334 | int get_data(ObjectStore *store, coll_t coll, ghobject_t hoid, |
| 1335 | ObjectStore::Transaction *t, bufferlist &bl) |
no test coverage detected