Lines Matching refs:device
103 static int get_disk_fd(ig_device_t *device);
304 if (init_device(&install_data.device, device_path) != BC_SUCCESS) { in handle_install()
324 if (is_bootpar(install_data.device.type) && do_version) in handle_install()
351 cleanup_device(&install_data.device); in handle_install()
373 ig_device_t *device = &data.device; in handle_getinfo() local
391 if (init_device(device, device_path) != BC_SUCCESS) { in handle_getinfo()
397 if (is_bootpar(device->type)) { in handle_getinfo()
403 ret = read_stage2_from_disk(device->part_fd, stage2, device->type); in handle_getinfo()
437 cleanup_device(&data.device); in handle_getinfo()
457 ig_device_t *curr_device = &curr_data.device; in handle_mirror()
458 ig_device_t *attach_device = &attach_data.device; in handle_mirror()
581 ig_device_t *src_device = &source->device; in propagate_bootblock()
582 ig_device_t *dest_device = &target->device; in propagate_bootblock()
636 init_device(ig_device_t *device, char *path) in init_device() argument
642 bzero(device, sizeof (*device)); in init_device()
643 device->part_fd = -1; in init_device()
644 device->disk_fd = -1; in init_device()
645 device->path_p0 = NULL; in init_device()
647 device->path = strdup(path); in init_device()
648 if (device->path == NULL) { in init_device()
653 if (strstr(device->path, "diskette")) { in init_device()
660 if (strstr(device->path, "p0:boot")) in init_device()
661 device->type = IG_DEV_X86BOOTPAR; in init_device()
663 if (get_disk_fd(device) != BC_SUCCESS) in init_device()
667 if (read(device->disk_fd, device->boot_sector, SECTOR_SIZE) in init_device()
674 if (efi_alloc_and_read(device->disk_fd, &vtoc) >= 0) { in init_device()
675 device->type = IG_DEV_EFI; in init_device()
679 if (get_raw_partition_fd(device) != BC_SUCCESS) in init_device()
682 if (is_efi(device->type)) { in init_device()
683 if (fstyp_init(device->part_fd, 0, NULL, &fhdl) != 0) in init_device()
695 if (get_start_sector(device) != BC_SUCCESS) in init_device()
702 cleanup_device(ig_device_t *device) in cleanup_device() argument
704 if (device->path) in cleanup_device()
705 free(device->path); in cleanup_device()
706 if (device->path_p0) in cleanup_device()
707 free(device->path_p0); in cleanup_device()
709 if (device->part_fd != -1) in cleanup_device()
710 (void) close(device->part_fd); in cleanup_device()
711 if (device->disk_fd != -1) in cleanup_device()
712 (void) close(device->disk_fd); in cleanup_device()
714 bzero(device, sizeof (ig_device_t)); in cleanup_device()
715 device->part_fd = -1; in cleanup_device()
716 device->disk_fd = -1; in cleanup_device()
728 get_start_sector(ig_device_t *device) in get_start_sector() argument
738 if (is_efi(device->type)) { in get_start_sector()
741 if (efi_alloc_and_read(device->disk_fd, &vtoc) < 0) in get_start_sector()
744 device->start_sector = vtoc->efi_parts[device->slice].p_start; in get_start_sector()
746 device->slice = 0xff; in get_start_sector()
747 device->partition = 0; in get_start_sector()
753 mboot = (struct mboot *)device->boot_sector; in get_start_sector()
755 if (is_bootpar(device->type)) { in get_start_sector()
760 device->start_sector = secnum; in get_start_sector()
761 device->partition = pno; in get_start_sector()
772 if (ioctl(device->part_fd, DKIOCEXTPARTINFO, &edkpi) < 0) { in get_start_sector()
773 if (ioctl(device->part_fd, DKIOCPARTINFO, &dkpi) < 0) { in get_start_sector()
807 device->start_sector = part->relsect; in get_start_sector()
808 device->partition = i; in get_start_sector()
816 if ((rval = libfdisk_init(&epp, device->path_p0, NULL, FDISK_READ_DISK)) in get_start_sector()
851 device->start_sector = secnum; in get_start_sector()
852 device->partition = pno - 1; in get_start_sector()
881 (void) fprintf(stdout, SOLPAR_INACTIVE, device->partition + 1); in get_start_sector()
888 get_disk_fd(ig_device_t *device) in get_disk_fd() argument
894 assert(device != NULL); in get_disk_fd()
895 assert(device->path != NULL); in get_disk_fd()
897 if (is_bootpar(device->type)) { in get_disk_fd()
898 end = strstr(device->path, "p0:boot"); in get_disk_fd()
905 i = strlen(device->path); in get_disk_fd()
906 save[0] = device->path[i - 2]; in get_disk_fd()
907 save[1] = device->path[i - 1]; in get_disk_fd()
908 device->path[i - 2] = 'p'; in get_disk_fd()
909 device->path[i - 1] = '0'; in get_disk_fd()
913 device->disk_fd = open(device->path, O_RDONLY); in get_disk_fd()
915 device->disk_fd = open(device->path, O_RDWR); in get_disk_fd()
917 device->path_p0 = strdup(device->path); in get_disk_fd()
918 if (device->path_p0 == NULL) { in get_disk_fd()
923 if (is_bootpar(device->type)) { in get_disk_fd()
926 device->path[i - 2] = save[0]; in get_disk_fd()
927 device->path[i - 1] = save[1]; in get_disk_fd()
930 if (device->disk_fd == -1) { in get_disk_fd()
981 ig_device_t *device = &install->device; in write_stage2() local
987 if (is_bootpar(device->type)) { in write_stage2()
993 if (write_out(device->part_fd, stage2->file, SECTOR_SIZE, in write_stage2()
996 write_out(device->part_fd, stage2->file + SECTOR_SIZE, in write_stage2()
1015 if (is_efi(device->type) && stage2->buf_size > STAGE2_MAXSIZE) { in write_stage2()
1020 offset = STAGE2_BLKOFF(device->type) * SECTOR_SIZE; in write_stage2()
1022 if (write_out(device->part_fd, stage2->buf, stage2->buf_size, in write_stage2()
1029 (void) fprintf(stdout, WRITE_STAGE2_DISK, device->partition, in write_stage2()
1030 (stage2->buf_size / SECTOR_SIZE) + 1, STAGE2_BLKOFF(device->type), in write_stage2()
1039 ig_device_t *device = &install->device; in write_stage1() local
1043 if (write_out(device->part_fd, install->stage1_buf, in write_stage1()
1051 (void) fprintf(stdout, WRITE_PBOOT, device->partition, in write_stage1()
1052 device->start_sector); in write_stage1()
1055 if (write_out(device->disk_fd, install->stage1_buf, in write_stage1()
1105 ig_device_t *device = &dest->device; in read_stage2_from_file() local
1119 if (!is_bootpar(device->type)) { in read_stage2_from_file()
1148 if (!(is_bootpar(device->type))) in read_stage2_from_file()
1176 ig_device_t *device = &install->device; in prepare_stage1() local
1181 if (is_bootpar(device->type)) { in prepare_stage1()
1184 if (pread(device->part_fd, bpb_sect, SECTOR_SIZE, 0) in prepare_stage1()
1194 bcopy(device->boot_sector + BOOTSZ, install->stage1_buf + BOOTSZ, in prepare_stage1()
1296 ig_device_t *device = &data->device; in is_update_necessary() local
1297 int dev_fd = device->part_fd; in is_update_necessary()
1300 assert(device->part_fd != -1); in is_update_necessary()
1305 if (read_stage2_from_disk(dev_fd, &stage2_disk, device->type) in is_update_necessary()
1307 BOOT_DEBUG("Unable to read stage2 from %s\n", device->path); in is_update_necessary()
1308 BOOT_DEBUG("No multiboot wrapped stage2 on %s\n", device->path); in is_update_necessary()
1325 "versioned one\n", device->path); in is_update_necessary()
1330 BOOT_DEBUG("Forcing update of %s bootblock\n", device->path); in is_update_necessary()
1349 ig_device_t *device = &install->device; in prepare_stage2() local
1387 if (is_bootpar(device->type)) { in prepare_stage2()
1394 if (read_stage2_blocklist(device->part_fd, blocklist) != 0) { in prepare_stage2()
1401 stage2->first_sector = device->start_sector + blocklist[0]; in prepare_stage2()
1421 START_BLOCK(pos) = blocklist[i] + device->start_sector; in prepare_stage2()
1430 stage2->first_sector = device->start_sector + in prepare_stage2()
1431 STAGE2_BLKOFF(device->type); in prepare_stage2()
1444 = (device->partition << 16) | (device->slice << 8) | 0xff; in prepare_stage2()
1471 get_raw_partition_path(ig_device_t *device) in get_raw_partition_path() argument
1476 if (is_bootpar(device->type)) { in get_raw_partition_path()
1480 mboot = (struct mboot *)device->boot_sector; in get_raw_partition_path()
1483 device->path_p0); in get_raw_partition_path()
1487 raw = strdup(device->path_p0); in get_raw_partition_path()
1498 raw = strdup(device->path); in get_raw_partition_path()
1505 if (!is_efi(device->type) && in get_raw_partition_path()
1511 device->slice = atoi(&raw[len - 1]); in get_raw_partition_path()
1513 if (!is_efi(device->type)) { in get_raw_partition_path()
1522 get_raw_partition_fd(ig_device_t *device) in get_raw_partition_fd() argument
1527 raw = get_raw_partition_path(device); in get_raw_partition_fd()
1532 device->part_fd = open(raw, O_RDONLY); in get_raw_partition_fd()
1534 device->part_fd = open(raw, O_RDWR); in get_raw_partition_fd()
1536 if (device->part_fd < 0 || fstat(device->part_fd, &stat) != 0) { in get_raw_partition_fd()
1544 (void) close(device->part_fd); in get_raw_partition_fd()
1545 device->part_fd = -1; in get_raw_partition_fd()
1564 ig_device_t *device = &install->device; in copy_stage2_to_pcfs() local
1568 (void) strncpy(buf, device->path, sizeof (buf)); in copy_stage2_to_pcfs()
1572 (void) fprintf(stderr, CONVERT_FAIL, device->path); in copy_stage2_to_pcfs()