Lines Matching refs:fd
114 static int read_all(int fd, uint8_t* data, size_t size) { in read_all() argument
117 ssize_t r = TEMP_FAILURE_RETRY(read(fd, data+so_far, size-so_far)); in read_all()
127 static int write_all(int fd, const uint8_t* data, size_t size) { in write_all() argument
130 ssize_t w = TEMP_FAILURE_RETRY(write(fd, data+written, size-written)); in write_all()
138 if (fsync(fd) == -1) { in write_all()
146 static bool check_lseek(int fd, off64_t offset, int whence) { in check_lseek() argument
147 off64_t rc = TEMP_FAILURE_RETRY(lseek64(fd, offset, whence)); in check_lseek()
170 int fd; member
192 if (write_all(rss->fd, data, write_now) == -1) { in RangeSinkWrite()
209 if (!check_lseek(rss->fd, (off64_t)rss->tgt->pos[rss->p_block*2] * BLOCKSIZE, in RangeSinkWrite()
292 static int ReadBlocks(RangeSet* src, uint8_t* buffer, int fd) { in ReadBlocks() argument
302 if (!check_lseek(fd, (off64_t) src->pos[i * 2] * BLOCKSIZE, SEEK_SET)) { in ReadBlocks()
308 if (read_all(fd, buffer + p, size) == -1) { in ReadBlocks()
318 static int WriteBlocks(RangeSet* tgt, uint8_t* buffer, int fd) { in WriteBlocks() argument
328 if (!check_lseek(fd, (off64_t) tgt->pos[i * 2] * BLOCKSIZE, SEEK_SET)) { in WriteBlocks()
334 if (write_all(fd, buffer + p, size) == -1) { in WriteBlocks()
355 uint8_t** buffer, size_t* buffer_alloc, int fd) { in LoadSrcTgtVersion1() argument
368 rc = ReadBlocks(src, *buffer, fd); in LoadSrcTgtVersion1()
560 int fd = -1; in LoadStash() local
595 fd = TEMP_FAILURE_RETRY(open(fn, O_RDONLY)); in LoadStash()
597 if (fd == -1) { in LoadStash()
604 if (read_all(fd, *buffer, st.st_size) == -1) { in LoadStash()
619 if (fd != -1) { in LoadStash()
620 close(fd); in LoadStash()
634 int fd = -1; in WriteStash() local
674 fd = TEMP_FAILURE_RETRY(open(fn, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, STASH_FILE_MODE)); in WriteStash()
676 if (fd == -1) { in WriteStash()
681 if (write_all(fd, buffer, blocks * BLOCKSIZE) == -1) { in WriteStash()
685 if (fsync(fd) == -1) { in WriteStash()
712 if (fd != -1) { in WriteStash()
713 close(fd); in WriteStash()
816 int fd, int usehash, int* isunresumable) { in SaveStash() argument
839 if (LoadSrcTgtVersion1(wordsave, NULL, &blocks, buffer, buffer_alloc, fd) == -1) { in SaveStash()
909 uint8_t** buffer, size_t* buffer_alloc, int fd, in LoadSrcTgtVersion2() argument
935 res = ReadBlocks(src, *buffer, fd); in LoadSrcTgtVersion2()
996 int fd; member
1057 params->fd, params->stashbase, overlap) == -1) { in LoadSrcTgtVersion3()
1068 if (ReadBlocks(*tgt, tgtbuffer, params->fd) == -1) { in LoadSrcTgtVersion3()
1136 ¶ms->bufsize, params->fd); in PerformCommandMove()
1139 ¶ms->bufsize, params->fd, params->stashbase, NULL); in PerformCommandMove()
1159 if (WriteBlocks(tgt, params->buffer, params->fd) == -1) { in PerformCommandMove()
1190 params->fd, (params->version >= 3), ¶ms->isunresumable); in PerformCommandStash()
1232 if (!check_lseek(params->fd, (off64_t) tgt->pos[i * 2] * BLOCKSIZE, SEEK_SET)) { in PerformCommandZero()
1237 if (write_all(params->fd, params->buffer, BLOCKSIZE) == -1) { in PerformCommandZero()
1281 rss.fd = params->fd; in PerformCommandNew()
1286 if (!check_lseek(params->fd, (off64_t) tgt->pos[0] * BLOCKSIZE, SEEK_SET)) { in PerformCommandNew()
1350 ¶ms->bufsize, params->fd); in PerformCommandDiff()
1353 ¶ms->bufsize, params->fd, params->stashbase, NULL); in PerformCommandDiff()
1377 rss.fd = params->fd; in PerformCommandDiff()
1382 if (!check_lseek(params->fd, (off64_t) tgt->pos[0] * BLOCKSIZE, SEEK_SET)) { in PerformCommandDiff()
1440 if (fstat(params->fd, &st) == -1) { in PerformCommandErase()
1468 if (ioctl(params->fd, BLKDISCARD, &blocks) == -1) { in PerformCommandErase()
1603 params.fd = TEMP_FAILURE_RETRY(open(blockdev_filename->data, O_RDWR)); in PerformBlockImageUpdate()
1605 if (params.fd == -1) { in PerformBlockImageUpdate()
1750 if (params.fd != -1) { in PerformBlockImageUpdate()
1751 if (fsync(params.fd) == -1) { in PerformBlockImageUpdate()
1754 close(params.fd); in PerformBlockImageUpdate()
1906 int fd = open(blockdev_filename->data, O_RDWR); in RangeSha1Fn() local
1907 if (fd < 0) { in RangeSha1Fn()
1920 if (!check_lseek(fd, (off64_t)rs->pos[i*2] * BLOCKSIZE, SEEK_SET)) { in RangeSha1Fn()
1927 if (read_all(fd, buffer, BLOCKSIZE) == -1) { in RangeSha1Fn()
1937 close(fd); in RangeSha1Fn()