Lines Matching refs:len

72   int (*write_data_chunk)(struct output_file* out, uint64_t len, void* data);
73 int (*write_fill_chunk)(struct output_file* out, uint64_t len, uint32_t fill_val);
74 int (*write_skip_chunk)(struct output_file* out, uint64_t len);
76 int (*write_fd_chunk)(struct output_file* out, uint64_t len, int fd, int64_t offset);
87 int64_t len; member
110 int (*write)(void* priv, const void* buf, size_t len);
134 static int file_pad(struct output_file* out, int64_t len) { in file_pad() argument
138 ret = ftruncate64(outn->fd, len); in file_pad()
146 static int file_write(struct output_file* out, void* data, size_t len) { in file_write() argument
150 while (len > 0) { in file_write()
151 ret = write(outn->fd, data, len); in file_write()
161 len -= ret; in file_write()
205 static int gz_file_pad(struct output_file* out, int64_t len) { in gz_file_pad() argument
214 if (ret >= len) { in gz_file_pad()
218 ret = gzseek(outgz->gz_fd, len - 1, SEEK_SET); in gz_file_pad()
228 static int gz_file_write(struct output_file* out, void* data, size_t len) { in gz_file_write() argument
232 while (len > 0) { in gz_file_write()
233 ret = gzwrite(outgz->gz_fd, data, std::min<unsigned int>(len, (unsigned int)INT_MAX)); in gz_file_write()
238 len -= ret; in gz_file_write()
281 static int callback_file_pad(struct output_file* out __unused, int64_t len __unused) { in callback_file_pad()
285 static int callback_file_write(struct output_file* out, void* data, size_t len) { in callback_file_write() argument
288 return outc->write(outc->priv, data, len); in callback_file_write()
305 int read_all(int fd, void* buf, size_t len) { in read_all() argument
310 while (total < len) { in read_all()
311 ret = read(fd, ptr, len - total); in read_all()
325 static bool write_fd_chunk_range(int fd, int64_t offset, uint64_t len, T callback) { in write_fd_chunk_range() argument
328 while (bytes_written < len) { in write_fd_chunk_range()
329 size_t mmap_size = std::min(static_cast<uint64_t>(kMaxMmapSize), len - bytes_written); in write_fd_chunk_range()
368 static int write_sparse_fill_chunk(struct output_file* out, uint64_t len, uint32_t fill_val) { in write_sparse_fill_chunk() argument
375 rnd_up_len = ALIGN(len, out->block_size); in write_sparse_fill_chunk()
399 static int write_sparse_data_chunk(struct output_file* out, uint64_t len, void* data) { in write_sparse_data_chunk() argument
405 rnd_up_len = ALIGN(len, out->block_size); in write_sparse_data_chunk()
406 zero_len = rnd_up_len - len; in write_sparse_data_chunk()
416 ret = out->ops->write(out, data, len); in write_sparse_data_chunk()
419 uint64_t len = zero_len; in write_sparse_data_chunk() local
421 while (len) { in write_sparse_data_chunk()
422 write_len = std::min(len, (uint64_t)FILL_ZERO_BUFSIZE); in write_sparse_data_chunk()
427 len -= write_len; in write_sparse_data_chunk()
432 out->crc32 = sparse_crc32(out->crc32, data, len); in write_sparse_data_chunk()
434 uint64_t len = zero_len; in write_sparse_data_chunk() local
436 while (len) { in write_sparse_data_chunk()
437 write_len = std::min(len, (uint64_t)FILL_ZERO_BUFSIZE); in write_sparse_data_chunk()
439 len -= write_len; in write_sparse_data_chunk()
450 static int write_sparse_fd_chunk(struct output_file* out, uint64_t len, int fd, int64_t offset) { in write_sparse_fd_chunk() argument
456 rnd_up_len = ALIGN(len, out->block_size); in write_sparse_fd_chunk()
457 zero_len = rnd_up_len - len; in write_sparse_fd_chunk()
467 bool ok = write_fd_chunk_range(fd, offset, len, [&ret, out](char* data, size_t size) -> bool { in write_sparse_fd_chunk()
477 uint64_t len = zero_len; in write_sparse_fd_chunk() local
479 while (len) { in write_sparse_fd_chunk()
480 write_len = std::min(len, (uint64_t)FILL_ZERO_BUFSIZE); in write_sparse_fd_chunk()
485 len -= write_len; in write_sparse_fd_chunk()
489 uint64_t len = zero_len; in write_sparse_fd_chunk() local
491 while (len) { in write_sparse_fd_chunk()
492 write_len = std::min(len, (uint64_t)FILL_ZERO_BUFSIZE); in write_sparse_fd_chunk()
494 len -= write_len; in write_sparse_fd_chunk()
538 static int write_normal_data_chunk(struct output_file* out, uint64_t len, void* data) { in write_normal_data_chunk() argument
540 uint64_t rnd_up_len = ALIGN(len, out->block_size); in write_normal_data_chunk()
542 ret = out->ops->write(out, data, len); in write_normal_data_chunk()
547 if (rnd_up_len > len) { in write_normal_data_chunk()
548 ret = out->ops->skip(out, rnd_up_len - len); in write_normal_data_chunk()
554 static int write_normal_fill_chunk(struct output_file* out, uint64_t len, uint32_t fill_val) { in write_normal_fill_chunk() argument
564 while (len) { in write_normal_fill_chunk()
565 write_len = std::min(len, (uint64_t)FILL_ZERO_BUFSIZE); in write_normal_fill_chunk()
571 len -= write_len; in write_normal_fill_chunk()
577 static int write_normal_fd_chunk(struct output_file* out, uint64_t len, int fd, int64_t offset) { in write_normal_fd_chunk() argument
579 uint64_t rnd_up_len = ALIGN(len, out->block_size); in write_normal_fd_chunk()
581 bool ok = write_fd_chunk_range(fd, offset, len, [&ret, out](char* data, size_t size) -> bool { in write_normal_fd_chunk()
587 if (rnd_up_len > len) { in write_normal_fd_chunk()
588 ret = out->ops->skip(out, rnd_up_len - len); in write_normal_fd_chunk()
594 static int write_normal_skip_chunk(struct output_file* out, uint64_t len) { in write_normal_skip_chunk() argument
595 return out->ops->skip(out, len); in write_normal_skip_chunk()
599 return out->ops->pad(out, out->len); in write_normal_end_chunk()
619 static int output_file_init(struct output_file* out, int block_size, int64_t len, bool sparse, in output_file_init() argument
623 out->len = len; in output_file_init()
659 .total_blks = static_cast<unsigned>(DIV_ROUND_UP(out->len, out->block_size)), in output_file_init()
709 unsigned int block_size, int64_t len, int gz __unused, in output_file_open_callback() argument
725 ret = output_file_init(&outc->out, block_size, len, sparse, chunks, crc); in output_file_open_callback()
734 struct output_file* output_file_open_fd(int fd, unsigned int block_size, int64_t len, int gz, in output_file_open_fd() argument
750 ret = output_file_init(out, block_size, len, sparse, chunks, crc); in output_file_open_fd()
760 int write_data_chunk(struct output_file* out, uint64_t len, void* data) { in write_data_chunk() argument
761 return out->sparse_ops->write_data_chunk(out, len, data); in write_data_chunk()
765 int write_fill_chunk(struct output_file* out, uint64_t len, uint32_t fill_val) { in write_fill_chunk() argument
766 return out->sparse_ops->write_fill_chunk(out, len, fill_val); in write_fill_chunk()
769 int write_fd_chunk(struct output_file* out, uint64_t len, int fd, int64_t offset) { in write_fd_chunk() argument
770 return out->sparse_ops->write_fd_chunk(out, len, fd, offset); in write_fd_chunk()
774 int write_file_chunk(struct output_file* out, uint64_t len, const char* file, int64_t offset) { in write_file_chunk() argument
782 ret = write_fd_chunk(out, len, file_fd, offset); in write_file_chunk()
789 int write_skip_chunk(struct output_file* out, uint64_t len) { in write_skip_chunk() argument
790 return out->sparse_ops->write_skip_chunk(out, len); in write_skip_chunk()