Lines Matching refs:label

28  * This file contains the code relating to label manipulation.
42 #include "label.h"
63 static int vtoc_to_label(struct dk_label *label, struct extvtoc *vtoc,
83 static void dump_label(struct dk_label *label);
87 * This routine checks the given label to see if it is valid.
90 checklabel(label)
91 register struct dk_label *label;
97 if (label->dkl_magic != DKL_MAGIC)
102 if (checksum(label, CK_CHECKSUM) != 0)
108 * This routine checks or calculates the label checksum, depending on
112 checksum(label, mode)
113 struct dk_label *label;
125 sp = (short *)label;
127 * Take the xor of all the half-words in the label.
142 label->dkl_cksum = sum;
149 * in a disk label. The problem is that the string in the label has
219 * to convert an SMI label to an EFI label
265 * This routine constructs and writes a label on the disk. It writes both
268 * the label and partition information it has written on the disk.
274 struct dk_label label;
287 * are on the disk. If so, refuse to label the disk, but only
292 err_print("Cannot label disk when "
298 * If EFI label, then write it out to disk
315 * Fill in a label structure with the geometry information.
317 (void) memset((char *)&label, 0, sizeof (struct dk_label));
320 label.dkl_pcyl = pcyl;
321 label.dkl_ncyl = ncyl;
322 label.dkl_acyl = acyl;
325 label.dkl_bcyl = bcyl;
328 label.dkl_nhead = nhead;
329 label.dkl_nsect = nsect;
330 label.dkl_apc = apc;
331 label.dkl_intrlv = 1;
332 label.dkl_rpm = cur_dtype->dtype_rpm;
339 label.dkl_map[i] = cur_parts->pinfo_map[i];
343 label.dkl_magic = DKL_MAGIC;
348 label.dkl_vtoc = cur_parts->vtoc;
351 * Use the current label
353 bcopy(cur_disk->v_volume, label.dkl_vtoc.v_volume, LEN_DKL_VVOL);
356 * Put asciilabel in; on x86 it's in the vtoc, not the label.
358 (void) snprintf(label.dkl_asciilabel, sizeof (label.dkl_asciilabel),
366 label.dkl_vtoc.v_sectorsz = cur_blksz;
372 (void) checksum(&label, CK_MAKESUM);
374 * Convert the label into a vtoc
376 if (label_to_vtoc(&vtoc, &label) == -1) {
423 * drivers convert the vtoc back to a label, and
454 "backup label.\n");
457 if (bcmp((char *)&label, new_label,
480 * Read the label from the disk.
481 * Do this via the read_extvtoc() library routine, then convert it to a label.
485 read_label(int fd, struct dk_label *label)
497 return (vtoc_to_label(label, &vtoc, &geom, &dkinfo));
639 get_disk_info(int fd, struct efi_info *label, struct disk_info *disk_info)
641 (void) get_disk_capacity(fd, &label->capacity);
644 &label->vendor, &label->product, &label->revision) != 0) {
645 if (get_disk_inquiry_devid(fd, &label->vendor, &label->product,
646 &label->revision) != 0) {
647 if (get_disk_inquiry_uscsi(fd, &label->vendor,
648 &label->product, &label->revision) != 0) {
649 label->vendor = strdup("Unknown");
650 label->product = strdup("Unknown");
651 label->revision = strdup("0001");
652 if (label->vendor == NULL ||
653 label->product == NULL ||
654 label->revision == NULL) {
655 free(label->vendor);
656 free(label->product);
657 free(label->revision);
668 read_efi_label(int fd, struct efi_info *label, struct disk_info *disk_info)
672 /* This could fail if there is no label already */
676 if (vtoc64_to_label(label, vtoc64) != 0) {
681 if (get_disk_info(fd, label, disk_info) != 0) {
689 * We've read a 64-bit label which has no geometry information. Use
694 vtoc64_to_label(struct efi_info *label, struct dk_gpt *vtoc)
699 (void) memset((char *)label, 0, sizeof (struct efi_info));
709 label->e_parts = lmap;
744 * Convert vtoc/geom to label.
747 vtoc_to_label(struct dk_label *label, struct extvtoc *vtoc,
762 (void) memset((char *)label, 0, sizeof (struct dk_label));
780 label->dkl_magic = DKL_MAGIC;
785 label->dkl_rpm = geom->dkg_rpm;
786 label->dkl_pcyl = geom->dkg_pcyl;
787 label->dkl_apc = geom->dkg_apc;
788 label->dkl_intrlv = geom->dkg_intrlv;
789 label->dkl_ncyl = geom->dkg_ncyl;
790 label->dkl_acyl = geom->dkg_acyl;
793 label->dkl_bcyl = geom->dkg_bcyl;
796 label->dkl_nhead = geom->dkg_nhead;
797 label->dkl_nsect = geom->dkg_nsect;
800 label->dkl_obs1 = geom->dkg_obs1;
801 label->dkl_obs2 = geom->dkg_obs2;
802 label->dkl_obs3 = geom->dkg_obs3;
805 label->dkl_write_reinstruct = geom->dkg_write_reinstruct;
806 label->dkl_read_reinstruct = geom->dkg_read_reinstruct;
809 * Copy vtoc structure fields into the disk label dk_vtoc
811 label->dkl_vtoc.v_sanity = vtoc->v_sanity;
812 label->dkl_vtoc.v_nparts = vtoc->v_nparts;
813 label->dkl_vtoc.v_version = vtoc->v_version;
815 (void) memcpy(label->dkl_vtoc.v_volume, vtoc->v_volume,
818 label->dkl_vtoc.v_part[i].p_tag = vtoc->v_part[i].p_tag;
819 label->dkl_vtoc.v_part[i].p_flag = vtoc->v_part[i].p_flag;
820 label->dkl_vtoc.v_timestamp[i] = vtoc->timestamp[i];
824 label->dkl_vtoc.v_reserved[i] = vtoc->v_reserved[i];
826 label->dkl_vtoc.v_bootinfo[0] = vtoc->v_bootinfo[0];
827 label->dkl_vtoc.v_bootinfo[1] = vtoc->v_bootinfo[1];
828 label->dkl_vtoc.v_bootinfo[2] = vtoc->v_bootinfo[2];
830 (void) memcpy(label->dkl_asciilabel, vtoc->v_asciilabel,
844 lmap = label->dkl_map;
847 lmap = label->dkl_vtoc.v_part;
854 nblks = label->dkl_nsect * label->dkl_nhead;
878 (void) checksum(label, CK_MAKESUM);
882 dump_label(label);
890 * Extract a vtoc structure out of a valid label
893 label_to_vtoc(struct extvtoc *vtoc, struct dk_label *label)
911 switch (label->dkl_vtoc.v_version) {
914 * No valid vtoc information in the label.
926 lpart = label->dkl_vtoc.v_part;
935 vtoc->timestamp[i] = label->dkl_vtoc.v_timestamp[i];
937 (void) memcpy(vtoc->v_volume, label->dkl_vtoc.v_volume,
941 vtoc->v_reserved[i] = label->dkl_vtoc.v_reserved[i];
943 vtoc->v_bootinfo[0] = label->dkl_vtoc.v_bootinfo[0];
944 vtoc->v_bootinfo[1] = label->dkl_vtoc.v_bootinfo[1];
945 vtoc->v_bootinfo[2] = label->dkl_vtoc.v_bootinfo[2];
955 * the real disk label?
962 (void) memcpy(vtoc->v_asciilabel, label->dkl_asciilabel,
971 lmap = label->dkl_map;
973 nblks = label->dkl_nsect * label->dkl_nhead;
985 * Output: 1 if disk has an EFI label, 0 otherwise.
994 /* assume the disk has EFI label */
1073 "label error: EFI Labels do not support overlapping partitions\n");
1091 dump_label(label)
1092 struct dk_label *label;
1096 fmt_print("%s\n", label->dkl_asciilabel);
1098 fmt_print("version: %d\n", label->dkl_vtoc.v_version);
1101 if (label->dkl_vtoc.v_volume[i] == 0)
1103 fmt_print("%c", label->dkl_vtoc.v_volume[i]);
1106 fmt_print("v_nparts: %d\n", label->dkl_vtoc.v_nparts);
1107 fmt_print("v_sanity: %lx\n", label->dkl_vtoc.v_sanity);
1110 fmt_print("rpm: %d\n", label->dkl_rpm);
1111 fmt_print("pcyl: %d\n", label->dkl_pcyl);
1112 fmt_print("apc: %d\n", label->dkl_apc);
1113 fmt_print("obs1: %d\n", label->dkl_obs1);
1114 fmt_print("obs2: %d\n", label->dkl_obs2);
1115 fmt_print("intrlv: %d\n", label->dkl_intrlv);
1116 fmt_print("ncyl: %d\n", label->dkl_ncyl);
1117 fmt_print("acyl: %d\n", label->dkl_acyl);
1118 fmt_print("nhead: %d\n", label->dkl_nhead);
1119 fmt_print("nsect: %d\n", label->dkl_nsect);
1120 fmt_print("obs3: %d\n", label->dkl_obs3);
1121 fmt_print("obs4: %d\n", label->dkl_obs4);
1124 fmt_print("rpm: %d\n", label->dkl_rpm);
1125 fmt_print("pcyl: %d\n", label->dkl_pcyl);
1126 fmt_print("apc: %d\n", label->dkl_apc);
1127 fmt_print("intrlv: %d\n", label->dkl_intrlv);
1128 fmt_print("ncyl: %d\n", label->dkl_ncyl);
1129 fmt_print("acyl: %d\n", label->dkl_acyl);
1130 fmt_print("nhead: %d\n", label->dkl_nhead);
1131 fmt_print("nsect: %d\n", label->dkl_nsect);
1132 fmt_print("bcyl: %d\n", label->dkl_bcyl);
1133 fmt_print("skew: %d\n", label->dkl_skew);
1137 fmt_print("magic: %0x\n", label->dkl_magic);
1138 fmt_print("cksum: %0x\n", label->dkl_cksum);
1144 label->dkl_map[i].dkl_cylno,
1145 label->dkl_map[i].dkl_nblk);
1149 label->dkl_vtoc.v_part[i].p_start,
1150 label->dkl_vtoc.v_part[i].p_size);
1156 label->dkl_vtoc.v_part[i].p_tag,
1157 label->dkl_vtoc.v_part[i].p_flag);
1161 fmt_print("read_reinstruct: %d\n", label->dkl_read_reinstruct);
1162 fmt_print("write_reinstruct: %d\n", label->dkl_write_reinstruct);
1166 fmt_print("0x%x ", label->dkl_vtoc.v_bootinfo[i]);
1174 fmt_print("0x%x ", label->dkl_vtoc.v_reserved[i]);
1182 fmt_print("0x%x ", label->dkl_vtoc.v_timestamp[i]);
1187 dump("", label->dkl_pad, LEN_DKL_PAD, HEX_ONLY);