| 2521 | } |
| 2522 | |
| 2523 | int do_set_bytes(ObjectStore *store, coll_t coll, |
| 2524 | ghobject_t &ghobj, int fd) |
| 2525 | { |
| 2526 | ObjectStore::Transaction tran; |
| 2527 | ObjectStore::Transaction *t = &tran; |
| 2528 | |
| 2529 | if (debug) |
| 2530 | cerr << "Write " << ghobj << std::endl; |
| 2531 | |
| 2532 | if (!dry_run) { |
| 2533 | t->touch(coll, ghobj); |
| 2534 | t->truncate(coll, ghobj, 0); |
| 2535 | } |
| 2536 | |
| 2537 | uint64_t offset = 0; |
| 2538 | bufferlist rawdatabl; |
| 2539 | do { |
| 2540 | rawdatabl.clear(); |
| 2541 | ssize_t bytes = rawdatabl.read_fd(fd, max_read); |
| 2542 | if (bytes < 0) { |
| 2543 | cerr << "read_fd error " << cpp_strerror(bytes) << std::endl; |
| 2544 | return bytes; |
| 2545 | } |
| 2546 | |
| 2547 | if (bytes == 0) |
| 2548 | break; |
| 2549 | |
| 2550 | if (debug) |
| 2551 | cerr << "\tdata: offset " << offset << " bytes " << bytes << std::endl; |
| 2552 | if (!dry_run) |
| 2553 | t->write(coll, ghobj, offset, bytes, rawdatabl); |
| 2554 | |
| 2555 | offset += bytes; |
| 2556 | // XXX: Should we queue_transaction() every once in a while for very large files |
| 2557 | } while(true); |
| 2558 | |
| 2559 | auto ch = store->open_collection(coll); |
| 2560 | if (!ch) { |
| 2561 | cerr << "Collection " << coll << " does not exist" << std::endl; |
| 2562 | return -ENOENT; |
| 2563 | } |
| 2564 | if (!dry_run) |
| 2565 | store->queue_transaction(ch, std::move(*t)); |
| 2566 | return 0; |
| 2567 | } |
| 2568 | |
| 2569 | int do_get_attr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key) |
| 2570 | { |
no test coverage detected