Lines Matching refs:device

101 static int get_disk_fd(ig_device_t *device);
297 if (init_device(&install_data.device, device_path) != BC_SUCCESS) { in handle_install()
317 if (is_bootpar(install_data.device.type) && do_version) in handle_install()
344 cleanup_device(&install_data.device); in handle_install()
366 ig_device_t *device = &data.device; in handle_getinfo() local
384 if (init_device(device, device_path) != BC_SUCCESS) { in handle_getinfo()
390 if (is_bootpar(device->type)) { in handle_getinfo()
396 ret = read_stage2_from_disk(device->part_fd, stage2, device->type); in handle_getinfo()
430 cleanup_device(&data.device); in handle_getinfo()
450 ig_device_t *curr_device = &curr_data.device; in handle_mirror()
451 ig_device_t *attach_device = &attach_data.device; in handle_mirror()
574 ig_device_t *src_device = &source->device; in propagate_bootblock()
575 ig_device_t *dest_device = &target->device; in propagate_bootblock()
629 init_device(ig_device_t *device, char *path) in init_device() argument
635 bzero(device, sizeof (*device)); in init_device()
636 device->part_fd = -1; in init_device()
637 device->disk_fd = -1; in init_device()
638 device->path_p0 = NULL; in init_device()
640 device->path = strdup(path); in init_device()
641 if (device->path == NULL) { in init_device()
646 if (strstr(device->path, "diskette")) { in init_device()
653 if (strstr(device->path, "p0:boot")) in init_device()
654 device->type = IG_DEV_X86BOOTPAR; in init_device()
656 if (get_disk_fd(device) != BC_SUCCESS) in init_device()
660 if (read(device->disk_fd, device->boot_sector, SECTOR_SIZE) in init_device()
667 if (efi_alloc_and_read(device->disk_fd, &vtoc) > 0) { in init_device()
668 device->type = IG_DEV_EFI; in init_device()
672 if (get_raw_partition_fd(device) != BC_SUCCESS) in init_device()
675 if (is_efi(device->type)) { in init_device()
676 if (fstyp_init(device->part_fd, 0, NULL, &fhdl) != 0) in init_device()
688 if (get_start_sector(device) != BC_SUCCESS) in init_device()
695 cleanup_device(ig_device_t *device) in cleanup_device() argument
697 if (device->path) in cleanup_device()
698 free(device->path); in cleanup_device()
699 if (device->path_p0) in cleanup_device()
700 free(device->path_p0); in cleanup_device()
702 if (device->part_fd != -1) in cleanup_device()
703 (void) close(device->part_fd); in cleanup_device()
704 if (device->disk_fd != -1) in cleanup_device()
705 (void) close(device->disk_fd); in cleanup_device()
707 bzero(device, sizeof (ig_device_t)); in cleanup_device()
708 device->part_fd = -1; in cleanup_device()
709 device->disk_fd = -1; in cleanup_device()
721 get_start_sector(ig_device_t *device) in get_start_sector() argument
731 if (is_efi(device->type)) { in get_start_sector()
734 if (efi_alloc_and_read(device->disk_fd, &vtoc) <= 0) in get_start_sector()
737 device->start_sector = vtoc->efi_parts[device->slice].p_start; in get_start_sector()
739 device->slice = 0xff; in get_start_sector()
740 device->partition = 0; in get_start_sector()
746 mboot = (struct mboot *)device->boot_sector; in get_start_sector()
748 if (is_bootpar(device->type)) { in get_start_sector()
753 device->start_sector = secnum; in get_start_sector()
754 device->partition = pno; in get_start_sector()
765 if (ioctl(device->part_fd, DKIOCEXTPARTINFO, &edkpi) < 0) { in get_start_sector()
766 if (ioctl(device->part_fd, DKIOCPARTINFO, &dkpi) < 0) { in get_start_sector()
800 device->start_sector = part->relsect; in get_start_sector()
801 device->partition = i; in get_start_sector()
809 if ((rval = libfdisk_init(&epp, device->path_p0, NULL, FDISK_READ_DISK)) in get_start_sector()
844 device->start_sector = secnum; in get_start_sector()
845 device->partition = pno - 1; in get_start_sector()
874 (void) fprintf(stdout, SOLPAR_INACTIVE, device->partition + 1); in get_start_sector()
881 get_disk_fd(ig_device_t *device) in get_disk_fd() argument
887 assert(device != NULL); in get_disk_fd()
888 assert(device->path != NULL); in get_disk_fd()
890 if (is_bootpar(device->type)) { in get_disk_fd()
891 end = strstr(device->path, "p0:boot"); in get_disk_fd()
898 i = strlen(device->path); in get_disk_fd()
899 save[0] = device->path[i - 2]; in get_disk_fd()
900 save[1] = device->path[i - 1]; in get_disk_fd()
901 device->path[i - 2] = 'p'; in get_disk_fd()
902 device->path[i - 1] = '0'; in get_disk_fd()
906 device->disk_fd = open(device->path, O_RDONLY); in get_disk_fd()
908 device->disk_fd = open(device->path, O_RDWR); in get_disk_fd()
910 device->path_p0 = strdup(device->path); in get_disk_fd()
911 if (device->path_p0 == NULL) { in get_disk_fd()
916 if (is_bootpar(device->type)) { in get_disk_fd()
919 device->path[i - 2] = save[0]; in get_disk_fd()
920 device->path[i - 1] = save[1]; in get_disk_fd()
923 if (device->disk_fd == -1) { in get_disk_fd()
974 ig_device_t *device = &install->device; in write_stage2() local
980 if (is_bootpar(device->type)) { in write_stage2()
986 if (write_out(device->part_fd, stage2->file, SECTOR_SIZE, in write_stage2()
989 write_out(device->part_fd, stage2->file + SECTOR_SIZE, in write_stage2()
1008 if (is_efi(device->type) && stage2->buf_size > STAGE2_MAXSIZE) { in write_stage2()
1013 offset = STAGE2_BLKOFF(device->type) * SECTOR_SIZE; in write_stage2()
1015 if (write_out(device->part_fd, stage2->buf, stage2->buf_size, in write_stage2()
1022 (void) fprintf(stdout, WRITE_STAGE2_DISK, device->partition, in write_stage2()
1023 (stage2->buf_size / SECTOR_SIZE) + 1, STAGE2_BLKOFF(device->type), in write_stage2()
1032 ig_device_t *device = &install->device; in write_stage1() local
1036 if (write_out(device->part_fd, install->stage1_buf, in write_stage1()
1044 (void) fprintf(stdout, WRITE_PBOOT, device->partition, in write_stage1()
1045 device->start_sector); in write_stage1()
1048 if (write_out(device->disk_fd, install->stage1_buf, in write_stage1()
1098 ig_device_t *device = &dest->device; in read_stage2_from_file() local
1112 if (!is_bootpar(device->type)) { in read_stage2_from_file()
1141 if (!(is_bootpar(device->type))) in read_stage2_from_file()
1169 ig_device_t *device = &install->device; in prepare_stage1() local
1174 if (is_bootpar(device->type)) { in prepare_stage1()
1177 if (pread(device->part_fd, bpb_sect, SECTOR_SIZE, 0) in prepare_stage1()
1187 bcopy(device->boot_sector + BOOTSZ, install->stage1_buf + BOOTSZ, in prepare_stage1()
1289 ig_device_t *device = &data->device; in is_update_necessary() local
1290 int dev_fd = device->part_fd; in is_update_necessary()
1293 assert(device->part_fd != -1); in is_update_necessary()
1298 if (read_stage2_from_disk(dev_fd, &stage2_disk, device->type) in is_update_necessary()
1300 BOOT_DEBUG("Unable to read stage2 from %s\n", device->path); in is_update_necessary()
1301 BOOT_DEBUG("No multiboot wrapped stage2 on %s\n", device->path); in is_update_necessary()
1318 "versioned one\n", device->path); in is_update_necessary()
1323 BOOT_DEBUG("Forcing update of %s bootblock\n", device->path); in is_update_necessary()
1342 ig_device_t *device = &install->device; in prepare_stage2() local
1380 if (is_bootpar(device->type)) { in prepare_stage2()
1387 if (read_stage2_blocklist(device->part_fd, blocklist) != 0) { in prepare_stage2()
1394 stage2->first_sector = device->start_sector + blocklist[0]; in prepare_stage2()
1414 START_BLOCK(pos) = blocklist[i] + device->start_sector; in prepare_stage2()
1423 stage2->first_sector = device->start_sector + in prepare_stage2()
1424 STAGE2_BLKOFF(device->type); in prepare_stage2()
1437 = (device->partition << 16) | (device->slice << 8) | 0xff; in prepare_stage2()
1464 get_raw_partition_path(ig_device_t *device) in get_raw_partition_path() argument
1469 if (is_bootpar(device->type)) { in get_raw_partition_path()
1473 mboot = (struct mboot *)device->boot_sector; in get_raw_partition_path()
1476 device->path_p0); in get_raw_partition_path()
1480 raw = strdup(device->path_p0); in get_raw_partition_path()
1491 raw = strdup(device->path); in get_raw_partition_path()
1498 if (!is_efi(device->type) && in get_raw_partition_path()
1504 device->slice = atoi(&raw[len - 1]); in get_raw_partition_path()
1506 if (!is_efi(device->type)) { in get_raw_partition_path()
1515 get_raw_partition_fd(ig_device_t *device) in get_raw_partition_fd() argument
1520 raw = get_raw_partition_path(device); in get_raw_partition_fd()
1525 device->part_fd = open(raw, O_RDONLY); in get_raw_partition_fd()
1527 device->part_fd = open(raw, O_RDWR); in get_raw_partition_fd()
1529 if (device->part_fd < 0 || fstat(device->part_fd, &stat) != 0) { in get_raw_partition_fd()
1537 (void) close(device->part_fd); in get_raw_partition_fd()
1538 device->part_fd = -1; in get_raw_partition_fd()
1557 ig_device_t *device = &install->device; in copy_stage2_to_pcfs() local
1561 (void) strncpy(buf, device->path, sizeof (buf)); in copy_stage2_to_pcfs()
1565 (void) fprintf(stderr, CONVERT_FAIL, device->path); in copy_stage2_to_pcfs()