Lines Matching refs:fd
95 android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(last_command_file.c_str(), O_RDONLY))); in ParseLastCommandFile() local
96 if (fd == -1) { in ParseLastCommandFile()
108 if (!android::base::ReadFdToString(fd.get(), &content)) { in ParseLastCommandFile()
195 static bool discard_blocks(int fd, off64_t offset, uint64_t size, bool force = false) { in discard_blocks() argument
202 if (ioctl(fd, BLKDISCARD, &args) == -1) { in discard_blocks()
213 static bool check_lseek(int fd, off64_t offset, int whence) { in check_lseek() argument
214 off64_t rc = TEMP_FAILURE_RETRY(lseek64(fd, offset, whence)); in check_lseek()
235 RangeSinkWriter(int fd, const RangeSet& tgt) in RangeSinkWriter() argument
236 : fd_(fd), in RangeSinkWriter()
482 static int ReadBlocks(const RangeSet& src, std::vector<uint8_t>* buffer, int fd) { in ReadBlocks() argument
485 if (!check_lseek(fd, static_cast<off64_t>(begin) * BLOCKSIZE, SEEK_SET)) { in ReadBlocks()
490 if (!android::base::ReadFully(fd, buffer->data() + p, size)) { in ReadBlocks()
502 static int WriteBlocks(const RangeSet& tgt, const std::vector<uint8_t>& buffer, int fd) { in WriteBlocks() argument
507 if (!discard_blocks(fd, offset, size)) { in WriteBlocks()
511 if (!check_lseek(fd, offset, SEEK_SET)) { in WriteBlocks()
515 if (!android::base::WriteFully(fd, buffer.data() + written, size)) { in WriteBlocks()
537 android::base::unique_fd fd; member
637 static void PrintHashForMissingStashedBlocks(const std::string& id, int fd) { in PrintHashForMissingStashedBlocks() argument
646 if (ReadBlocks(src, &buffer, fd) == -1) { in PrintHashForMissingStashedBlocks()
744 if (ReadBlocks(src, buffer, params.fd) == -1) { in LoadStash()
765 PrintHashForMissingStashedBlocks(id, params.fd); in LoadStash()
777 android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(fn.c_str(), O_RDONLY))); in LoadStash() local
778 if (fd == -1) { in LoadStash()
786 if (!android::base::ReadFully(fd, buffer->data(), sb.st_size)) { in LoadStash()
841 android::base::unique_fd fd( in WriteStash() local
843 if (fd == -1) { in WriteStash()
849 if (fchown(fd, AID_SYSTEM, AID_SYSTEM) != 0) { // system user in WriteStash()
854 if (!android::base::WriteFully(fd, buffer.data(), blocks * BLOCKSIZE)) { in WriteStash()
860 if (fsync(fd) == -1) { in WriteStash()
1016 if (ReadBlocks(src, ¶ms.buffer, params.fd) == -1) { in LoadSourceBlocks()
1116 if (ReadBlocks(*tgt, &tgtbuffer, params.fd) == -1) { in LoadSrcTgtVersion3()
1195 if (WriteBlocks(tgt, params.buffer, params.fd) == -1) { in PerformCommandMove()
1232 if (ReadBlocks(src, ¶ms.buffer, params.fd) == -1) { in PerformCommandStash()
1293 if (!discard_blocks(params.fd, offset, size)) { in PerformCommandZero()
1297 if (!check_lseek(params.fd, offset, SEEK_SET)) { in PerformCommandZero()
1302 if (!android::base::WriteFully(params.fd, params.buffer.data(), BLOCKSIZE)) { in PerformCommandZero()
1333 params.nti.writer = std::make_unique<RangeSinkWriter>(params.fd, tgt); in PerformCommandNew()
1398 RangeSinkWriter writer(params.fd, tgt); in PerformCommandDiff()
1447 if (fstat(params.fd, &sb) == -1) { in PerformCommandErase()
1471 if (!discard_blocks(params.fd, offset, size, true /* force */)) { in PerformCommandErase()
1543 if (!check_lseek(params.fd, static_cast<off64_t>(begin) * BLOCKSIZE, SEEK_SET)) { in PerformCommandComputeHashTree()
1549 if (!android::base::ReadFully(params.fd, buffer, BLOCKSIZE)) { in PerformCommandComputeHashTree()
1575 if (params.canwrite && !builder.WriteHashTreeToFd(params.fd, write_offset)) { in PerformCommandComputeHashTree()
1704 params.fd.reset(TEMP_FAILURE_RETRY(open(block_device_path.c_str(), O_RDWR))); in PerformBlockImageUpdate()
1705 if (params.fd == -1) { in PerformBlockImageUpdate()
1885 if (fsync(params.fd) == -1) { in PerformBlockImageUpdate()
1952 if (fsync(params.fd) == -1) { in PerformBlockImageUpdate()
2098 android::base::unique_fd fd(open(block_device_path.c_str(), O_RDWR)); in RangeSha1Fn() local
2099 if (fd == -1) { in RangeSha1Fn()
2114 if (!check_lseek(fd, static_cast<off64_t>(begin) * BLOCKSIZE, SEEK_SET)) { in RangeSha1Fn()
2121 if (!android::base::ReadFully(fd, buffer.data(), BLOCKSIZE)) { in RangeSha1Fn()
2169 android::base::unique_fd fd(open(block_device_path.c_str(), O_RDONLY)); in CheckFirstBlockFn() local
2170 if (fd == -1) { in CheckFirstBlockFn()
2180 if (ReadBlocks(blk0, &block0_buffer, fd) == -1) { in CheckFirstBlockFn()