Lines Matching refs:len

78 	int (*write_data_chunk)(struct output_file *out, unsigned int len,
80 int (*write_fill_chunk)(struct output_file *out, unsigned int len,
82 int (*write_skip_chunk)(struct output_file *out, int64_t len);
94 int64_t len;
119 int (*write)(void *priv, const void *buf, int len);
146 static int file_pad(struct output_file *out, int64_t len)
151 ret = ftruncate64(outn->fd, len);
159 static int file_write(struct output_file *out, void *data, int len)
164 ret = write(outn->fd, data, len);
168 } else if (ret < len) {
218 static int gz_file_pad(struct output_file *out, int64_t len)
228 if (ret >= len) {
232 ret = gzseek(outgz->gz_fd, len - 1, SEEK_SET);
242 static int gz_file_write(struct output_file *out, void *data, int len)
247 ret = gzwrite(outgz->gz_fd, data, len);
251 } else if (ret < len) {
298 static int callback_file_pad(struct output_file *out, int64_t len)
303 static int callback_file_write(struct output_file *out, void *data, int len)
308 return outc->write(outc->priv, data, len);
326 int read_all(int fd, void *buf, size_t len)
332 while (total < len) {
333 ret = read(fd, ptr, len - total);
374 static int write_sparse_fill_chunk(struct output_file *out, unsigned int len,
383 rnd_up_len = ALIGN(len, out->block_size);
410 static int write_sparse_data_chunk(struct output_file *out, unsigned int len,
418 rnd_up_len = ALIGN(len, out->block_size);
419 zero_len = rnd_up_len - len;
430 ret = out->ops->write(out, data, len);
440 out->crc32 = sparse_crc32(out->crc32, data, len);
484 static int write_normal_data_chunk(struct output_file *out, unsigned int len,
488 unsigned int rnd_up_len = ALIGN(len, out->block_size);
490 ret = out->ops->write(out, data, len);
495 if (rnd_up_len > len) {
496 ret = out->ops->skip(out, rnd_up_len - len);
502 static int write_normal_fill_chunk(struct output_file *out, unsigned int len,
514 while (len) {
515 write_len = min(len, out->block_size);
521 len -= write_len;
527 static int write_normal_skip_chunk(struct output_file *out, int64_t len)
529 return out->ops->skip(out, len);
534 return out->ops->pad(out, out->len);
553 int64_t len, bool sparse, int chunks, bool crc)
557 out->len = len;
591 .total_blks = out->len / out->block_size,
642 void *priv, unsigned int block_size, int64_t len, int gz, int sparse,
658 ret = output_file_init(&outc->out, block_size, len, sparse, chunks, crc);
667 struct output_file *output_file_open_fd(int fd, unsigned int block_size, int64_t len,
681 ret = output_file_init(out, block_size, len, sparse, chunks, crc);
691 int write_data_chunk(struct output_file *out, unsigned int len, void *data)
693 return out->sparse_ops->write_data_chunk(out, len, data);
697 int write_fill_chunk(struct output_file *out, unsigned int len,
700 return out->sparse_ops->write_fill_chunk(out, len, fill_val);
703 int write_fd_chunk(struct output_file *out, unsigned int len,
714 buffer_size = len + aligned_diff;
725 char *data = malloc(len);
733 ret = read_all(fd, data, len);
740 ret = out->sparse_ops->write_data_chunk(out, len, ptr);
752 int write_file_chunk(struct output_file *out, unsigned int len,
762 ret = write_fd_chunk(out, len, file_fd, offset);
769 int write_skip_chunk(struct output_file *out, int64_t len)
771 return out->sparse_ops->write_skip_chunk(out, len);