Lines Matching defs:volhdr
71 struct sgi_boot_block *volhdr;
215 err(EXIT_FAILURE, "Can't read volhdr from `%s'", argv[0]);
233 volhdr = (struct sgi_boot_block *) buf;
238 if (be32toh(volhdr->magic) != SGI_BOOT_BLOCK_MAGIC)
240 "Use -i first.\n", be32toh(volhdr->magic));
284 cmp = strncmp(volhdr->voldir[slot].name, b,
285 sizeof(volhdr->voldir[slot].name));
287 return cmp == 0 && strlen(b) <= sizeof(volhdr->voldir[slot].name);
307 printf("root part: %d\n", be16toh(volhdr->root));
308 printf("swap part: %d\n", be16toh(volhdr->swap));
309 printf("bootfile: %s\n", volhdr->bootfile);
310 /* volhdr->devparams[0..47] */
313 if (volhdr->voldir[i].name[0])
316 volhdr->voldir[i].name,
317 be32toh(volhdr->voldir[i].block),
318 be32toh(volhdr->voldir[i].bytes),
319 (be32toh(volhdr->voldir[i].bytes) + 511) / 512);
322 if (be32toh(volhdr->partitions[i].blocks)) {
324 i, i + 'a', be32toh(volhdr->partitions[i].blocks),
325 be32toh(volhdr->partitions[i].first),
326 be32toh(volhdr->partitions[i].type),
327 be32toh(volhdr->partitions[i].type) > 13 ? "???" :
328 sgi_types[be32toh(volhdr->partitions[i].type)]);
337 volhdr->magic = htobe32(SGI_BOOT_BLOCK_MAGIC);
338 volhdr->root = htobe16(0);
339 volhdr->swap = htobe16(1);
340 strcpy(volhdr->bootfile, "/netbsd");
342 volhdr->dp.dp_skew = 0;
344 volhdr->dp.dp_skew = lbl.d_trackskew;
346 volhdr->dp.dp_gap1 = 1; /* XXX */
347 volhdr->dp.dp_gap2 = 1; /* XXX */
349 volhdr->dp.dp_cyls =
352 volhdr->dp.dp_cyls = htobe16(lbl.d_ncylinders);
354 volhdr->dp.dp_shd0 = 0;
356 volhdr->dp.dp_trks0 = htobe16(SGIVOL_NBTOOL_NTRACKS);
357 volhdr->dp.dp_secs = htobe16(SGIVOL_NBTOOL_NSECS);
358 volhdr->dp.dp_secbytes = htobe16(SGI_BOOT_BLOCK_BLOCKSIZE);
359 volhdr->dp.dp_interleave = htobe16(1);
361 volhdr->dp.dp_trks0 = htobe16(lbl.d_ntracks);
362 volhdr->dp.dp_secs = htobe16(lbl.d_nsectors);
363 volhdr->dp.dp_secbytes = htobe16(lbl.d_secsize);
364 volhdr->dp.dp_interleave = htobe16(lbl.d_interleave);
366 volhdr->dp.dp_nretries = htobe32(22);
368 volhdr->partitions[10].blocks =
371 volhdr->partitions[10].blocks = htobe32(lbl.d_secperunit);
373 volhdr->partitions[10].first = 0;
374 volhdr->partitions[10].type = htobe32(SGI_PTYPE_VOLUME);
375 volhdr->partitions[8].blocks = htobe32(volhdr_size);
376 volhdr->partitions[8].first = 0;
377 volhdr->partitions[8].type = htobe32(SGI_PTYPE_VOLHDR);
379 volhdr->partitions[0].blocks =
382 volhdr->partitions[0].blocks = htobe32(lbl.d_secperunit - volhdr_size);
384 volhdr->partitions[0].first = htobe32(volhdr_size);
385 volhdr->partitions[0].type = htobe32(SGI_PTYPE_BSD);
398 if (strncmp(vfilename, volhdr->voldir[i].name,
399 strlen(volhdr->voldir[i].name)) == 0)
405 lseek(fd, be32toh(volhdr->voldir[i].block) * 512, SEEK_SET);
409 i = be32toh(volhdr->voldir[i].bytes);
439 if (volhdr->voldir[i].name[0] == '\0' && slot < 0)
449 if (be32toh(volhdr->voldir[slot].block) > 0) {
453 volhdr->voldir[slot].name[0] = 0;
454 volhdr->voldir[slot].block = volhdr->voldir[slot].bytes = 0;
470 if (namelen > sizeof(volhdr->voldir[slot].name)) {
473 namelen = sizeof(volhdr->voldir[slot].name);
478 memset(volhdr->voldir[slot].name, 0,
479 sizeof(volhdr->voldir[slot].name));
481 memcpy(volhdr->voldir[slot].name, vfilename, namelen);
483 volhdr->voldir[slot].block = htobe32(block);
484 volhdr->voldir[slot].bytes = htobe32(st.st_size);
521 volhdr->voldir[i].name[0] = '\0';
522 volhdr->voldir[i].block = volhdr->voldir[i].bytes = 0;
529 char dstfile[sizeof(volhdr->voldir[0].name) + 1];
538 if (namelen > sizeof(volhdr->voldir[0].name)) {
541 namelen = sizeof(volhdr->voldir[0].name);
565 memcpy(volhdr->voldir[slot].name, dstfile,
566 sizeof(volhdr->voldir[slot].name));
580 volhdr->partitions[partno].blocks = htobe32(partblocks);
581 volhdr->partitions[partno].first = htobe32(partfirst);
582 volhdr->partitions[partno].type = htobe32(parttype);
608 errx(EXIT_FAILURE, "write volhdr `%s'", fname);
621 if (volhdr->voldir[n].name[0]) {
622 if (first < (be32toh(volhdr->voldir[n].block) +
623 (be32toh(volhdr->voldir[n].bytes) + 511) / 512) &&
624 (first + blocks) > be32toh(volhdr->voldir[n].block)) {
625 first = be32toh(volhdr->voldir[n].block) +
626 (be32toh(volhdr->voldir[n].bytes) + 511) / 512;
629 printf("%s %d %d\n", volhdr->voldir[n].name, volhdr->voldir[n].block, volhdr->voldir[n].bytes);
630 printf("first=%d block=%d last=%d end=%d\n", first, volhdr->voldir[n].block,
631 first + blocks - 1, volhdr->voldir[n].block + (volhdr->voldir[n].bytes + 511) / 512);
647 if (first + blocks >= be32toh(volhdr->partitions[8].blocks))
658 volhdr->checksum = checksum = 0;
662 volhdr->checksum = htobe32(-checksum);