Lines Matching refs:header
199 struct cow_header_v3 *header; in write_cow_header() local
210 header = cow_malloc(sizeof(*header)); in write_cow_header()
211 if (header == NULL) { in write_cow_header()
216 header->magic = htobe32(COW_MAGIC); in write_cow_header()
217 header->version = htobe32(COW_VERSION); in write_cow_header()
220 if (strlen(backing_file) > sizeof(header->backing_file) - 1) { in write_cow_header()
224 sizeof(header->backing_file) - 1); in write_cow_header()
228 if (absolutize(header->backing_file, sizeof(header->backing_file), in write_cow_header()
232 err = os_file_modtime(header->backing_file, &modtime); in write_cow_header()
235 "request failed, err = %d\n", header->backing_file, in write_cow_header()
240 err = cow_file_size(header->backing_file, size); in write_cow_header()
244 header->backing_file, -err); in write_cow_header()
248 header->mtime = htobe32(modtime); in write_cow_header()
249 header->size = htobe64(*size); in write_cow_header()
250 header->sectorsize = htobe32(sectorsize); in write_cow_header()
251 header->alignment = htobe32(alignment); in write_cow_header()
252 header->cow_format = COW_BITMAP; in write_cow_header()
254 err = cow_write_file(fd, header, sizeof(*header)); in write_cow_header()
255 if (err != sizeof(*header)) { in write_cow_header()
263 cow_free(header); in write_cow_header()
283 union cow_header *header; in read_cow_header() local
288 header = cow_malloc(sizeof(*header)); in read_cow_header()
289 if (header == NULL) { in read_cow_header()
294 n = (*reader)(0, (char *) header, sizeof(*header), arg); in read_cow_header()
295 if (n < offsetof(typeof(header->v1), backing_file)) { in read_cow_header()
300 magic = header->v1.magic; in read_cow_header()
302 version = header->v1.version; in read_cow_header()
304 version = be32toh(header->v1.version); in read_cow_header()
311 if (n < sizeof(header->v1)) { in read_cow_header()
316 *mtime_out = header->v1.mtime; in read_cow_header()
317 *size_out = header->v1.size; in read_cow_header()
318 *sectorsize_out = header->v1.sectorsize; in read_cow_header()
319 *bitmap_offset_out = sizeof(header->v1); in read_cow_header()
321 file = header->v1.backing_file; in read_cow_header()
324 if (n < sizeof(header->v2)) { in read_cow_header()
329 *mtime_out = be32toh(header->v2.mtime); in read_cow_header()
330 *size_out = be64toh(header->v2.size); in read_cow_header()
331 *sectorsize_out = be32toh(header->v2.sectorsize); in read_cow_header()
332 *bitmap_offset_out = sizeof(header->v2); in read_cow_header()
334 file = header->v2.backing_file; in read_cow_header()
337 else if (version == 3 && (*((int*)header->v3.backing_file) != 0)) { in read_cow_header()
338 if (n < sizeof(header->v3)) { in read_cow_header()
343 *mtime_out = be32toh(header->v3.mtime); in read_cow_header()
344 *size_out = be64toh(header->v3.size); in read_cow_header()
345 *sectorsize_out = be32toh(header->v3.sectorsize); in read_cow_header()
346 *align_out = be32toh(header->v3.alignment); in read_cow_header()
351 *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out); in read_cow_header()
352 file = header->v3.backing_file; in read_cow_header()
358 if (n < sizeof(header->v3_b)) { in read_cow_header()
373 *mtime_out = (time32_t) be32toh(header->v3_b.mtime); in read_cow_header()
375 *size_out = be64toh(header->v3_b.size); in read_cow_header()
376 *sectorsize_out = be32toh(header->v3_b.sectorsize); in read_cow_header()
377 *align_out = be32toh(header->v3_b.alignment); in read_cow_header()
382 *bitmap_offset_out = ROUND_UP(sizeof(header->v3_b), *align_out); in read_cow_header()
383 file = header->v3_b.backing_file; in read_cow_header()
398 cow_free(header); in read_cow_header()