Lines Matching refs:header

200 	struct cow_header_v3 *header;  in write_cow_header()  local
211 header = cow_malloc(sizeof(*header)); in write_cow_header()
212 if (header == NULL) { in write_cow_header()
217 header->magic = htobe32(COW_MAGIC); in write_cow_header()
218 header->version = htobe32(COW_VERSION); in write_cow_header()
221 if (strlen(backing_file) > sizeof(header->backing_file) - 1) { in write_cow_header()
225 sizeof(header->backing_file) - 1); in write_cow_header()
229 if (absolutize(header->backing_file, sizeof(header->backing_file), in write_cow_header()
233 err = os_file_modtime(header->backing_file, &modtime); in write_cow_header()
236 "request failed, err = %d\n", header->backing_file, in write_cow_header()
241 err = cow_file_size(header->backing_file, size); in write_cow_header()
245 header->backing_file, -err); in write_cow_header()
249 header->mtime = htobe32(modtime); in write_cow_header()
250 header->size = htobe64(*size); in write_cow_header()
251 header->sectorsize = htobe32(sectorsize); in write_cow_header()
252 header->alignment = htobe32(alignment); in write_cow_header()
253 header->cow_format = COW_BITMAP; in write_cow_header()
255 err = cow_write_file(fd, header, sizeof(*header)); in write_cow_header()
256 if (err != sizeof(*header)) { in write_cow_header()
264 cow_free(header); in write_cow_header()
284 union cow_header *header; in read_cow_header() local
289 header = cow_malloc(sizeof(*header)); in read_cow_header()
290 if (header == NULL) { in read_cow_header()
295 n = (*reader)(0, (char *) header, sizeof(*header), arg); in read_cow_header()
296 if (n < offsetof(typeof(header->v1), backing_file)) { in read_cow_header()
301 magic = header->v1.magic; in read_cow_header()
303 version = header->v1.version; in read_cow_header()
305 version = be32toh(header->v1.version); in read_cow_header()
312 if (n < sizeof(header->v1)) { in read_cow_header()
317 *mtime_out = header->v1.mtime; in read_cow_header()
318 *size_out = header->v1.size; in read_cow_header()
319 *sectorsize_out = header->v1.sectorsize; in read_cow_header()
320 *bitmap_offset_out = sizeof(header->v1); in read_cow_header()
322 file = header->v1.backing_file; in read_cow_header()
325 if (n < sizeof(header->v2)) { in read_cow_header()
330 *mtime_out = be32toh(header->v2.mtime); in read_cow_header()
331 *size_out = be64toh(header->v2.size); in read_cow_header()
332 *sectorsize_out = be32toh(header->v2.sectorsize); in read_cow_header()
333 *bitmap_offset_out = sizeof(header->v2); in read_cow_header()
335 file = header->v2.backing_file; in read_cow_header()
338 else if (version == 3 && (*((int*)header->v3.backing_file) != 0)) { in read_cow_header()
339 if (n < sizeof(header->v3)) { in read_cow_header()
344 *mtime_out = be32toh(header->v3.mtime); in read_cow_header()
345 *size_out = be64toh(header->v3.size); in read_cow_header()
346 *sectorsize_out = be32toh(header->v3.sectorsize); in read_cow_header()
347 *align_out = be32toh(header->v3.alignment); in read_cow_header()
352 *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out); in read_cow_header()
353 file = header->v3.backing_file; in read_cow_header()
359 if (n < sizeof(header->v3_b)) { in read_cow_header()
374 *mtime_out = (time32_t) be32toh(header->v3_b.mtime); in read_cow_header()
376 *size_out = be64toh(header->v3_b.size); in read_cow_header()
377 *sectorsize_out = be32toh(header->v3_b.sectorsize); in read_cow_header()
378 *align_out = be32toh(header->v3_b.alignment); in read_cow_header()
383 *bitmap_offset_out = ROUND_UP(sizeof(header->v3_b), *align_out); in read_cow_header()
384 file = header->v3_b.backing_file; in read_cow_header()
399 cow_free(header); in read_cow_header()