Lines Matching refs:curlun
260 struct fsg_lun *curlun; member
591 struct fsg_lun *curlun = common->curlun; in do_read() local
618 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_read()
622 if (lba >= curlun->num_sectors) { in do_read()
623 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; in do_read()
626 file_offset = ((loff_t) lba) << curlun->blkbits; in do_read()
642 curlun->file_length - file_offset); in do_read()
655 curlun->sense_data = in do_read()
657 curlun->sense_data_info = in do_read()
658 file_offset >> curlun->blkbits; in do_read()
659 curlun->info_valid = 1; in do_read()
667 nread = kernel_read(curlun->filp, bh->buf, amount, in do_read()
669 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, in do_read()
675 LDBG(curlun, "error in file read: %d\n", (int)nread); in do_read()
678 LDBG(curlun, "partial file read: %d/%u\n", in do_read()
680 nread = round_down(nread, curlun->blksize); in do_read()
696 curlun->sense_data = SS_UNRECOVERED_READ_ERROR; in do_read()
697 curlun->sense_data_info = in do_read()
698 file_offset >> curlun->blkbits; in do_read()
699 curlun->info_valid = 1; in do_read()
722 struct fsg_lun *curlun = common->curlun; in do_write() local
732 if (curlun->ro) { in do_write()
733 curlun->sense_data = SS_WRITE_PROTECTED; in do_write()
736 spin_lock(&curlun->filp->f_lock); in do_write()
737 curlun->filp->f_flags &= ~O_SYNC; /* Default is not to wait */ in do_write()
738 spin_unlock(&curlun->filp->f_lock); in do_write()
759 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_write()
762 if (!curlun->nofua && (common->cmnd[1] & 0x08)) { /* FUA */ in do_write()
763 spin_lock(&curlun->filp->f_lock); in do_write()
764 curlun->filp->f_flags |= O_SYNC; in do_write()
765 spin_unlock(&curlun->filp->f_lock); in do_write()
768 if (lba >= curlun->num_sectors) { in do_write()
769 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; in do_write()
775 file_offset = usb_offset = ((loff_t) lba) << curlun->blkbits; in do_write()
793 if (usb_offset >= curlun->file_length) { in do_write()
795 curlun->sense_data = in do_write()
797 curlun->sense_data_info = in do_write()
798 usb_offset >> curlun->blkbits; in do_write()
799 curlun->info_valid = 1; in do_write()
838 curlun->sense_data = SS_COMMUNICATION_FAILURE; in do_write()
839 curlun->sense_data_info = in do_write()
840 file_offset >> curlun->blkbits; in do_write()
841 curlun->info_valid = 1; in do_write()
846 if (curlun->file_length - file_offset < amount) { in do_write()
847 LERROR(curlun, "write %u @ %llu beyond end %llu\n", in do_write()
849 (unsigned long long)curlun->file_length); in do_write()
850 amount = curlun->file_length - file_offset; in do_write()
860 amount = round_down(amount, curlun->blksize); in do_write()
866 nwritten = kernel_write(curlun->filp, bh->buf, amount, in do_write()
868 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount, in do_write()
874 LDBG(curlun, "error in file write: %d\n", in do_write()
878 LDBG(curlun, "partial file write: %d/%u\n", in do_write()
880 nwritten = round_down(nwritten, curlun->blksize); in do_write()
888 curlun->sense_data = SS_WRITE_ERROR; in do_write()
889 curlun->sense_data_info = in do_write()
890 file_offset >> curlun->blkbits; in do_write()
891 curlun->info_valid = 1; in do_write()
911 struct fsg_lun *curlun = common->curlun; in do_synchronize_cache() local
916 rc = fsg_lun_fsync_sub(curlun); in do_synchronize_cache()
918 curlun->sense_data = SS_WRITE_ERROR; in do_synchronize_cache()
925 static void invalidate_sub(struct fsg_lun *curlun) in invalidate_sub() argument
927 struct file *filp = curlun->filp; in invalidate_sub()
932 VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc); in invalidate_sub()
937 struct fsg_lun *curlun = common->curlun; in do_verify() local
951 if (lba >= curlun->num_sectors) { in do_verify()
952 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; in do_verify()
961 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_verify()
970 amount_left = verification_length << curlun->blkbits; in do_verify()
971 file_offset = ((loff_t) lba) << curlun->blkbits; in do_verify()
974 fsg_lun_fsync_sub(curlun); in do_verify()
978 invalidate_sub(curlun); in do_verify()
992 curlun->file_length - file_offset); in do_verify()
994 curlun->sense_data = in do_verify()
996 curlun->sense_data_info = in do_verify()
997 file_offset >> curlun->blkbits; in do_verify()
998 curlun->info_valid = 1; in do_verify()
1004 nread = kernel_read(curlun->filp, bh->buf, amount, in do_verify()
1006 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, in do_verify()
1013 LDBG(curlun, "error in file verify: %d\n", (int)nread); in do_verify()
1016 LDBG(curlun, "partial file verify: %d/%u\n", in do_verify()
1018 nread = round_down(nread, curlun->blksize); in do_verify()
1021 curlun->sense_data = SS_UNRECOVERED_READ_ERROR; in do_verify()
1022 curlun->sense_data_info = in do_verify()
1023 file_offset >> curlun->blkbits; in do_verify()
1024 curlun->info_valid = 1; in do_verify()
1038 struct fsg_lun *curlun = common->curlun; in do_inquiry() local
1041 if (!curlun) { /* Unsupported LUNs are okay */ in do_inquiry()
1049 buf[0] = curlun->cdrom ? TYPE_ROM : TYPE_DISK; in do_inquiry()
1050 buf[1] = curlun->removable ? 0x80 : 0; in do_inquiry()
1057 if (curlun->inquiry_string[0]) in do_inquiry()
1058 memcpy(buf + 8, curlun->inquiry_string, in do_inquiry()
1059 sizeof(curlun->inquiry_string)); in do_inquiry()
1068 struct fsg_lun *curlun = common->curlun; in do_request_sense() local
1089 if (curlun && curlun->unit_attention_data != SS_NO_SENSE) { in do_request_sense()
1090 curlun->sense_data = curlun->unit_attention_data; in do_request_sense()
1091 curlun->unit_attention_data = SS_NO_SENSE; in do_request_sense()
1095 if (!curlun) { /* Unsupported LUNs are okay */ in do_request_sense()
1101 sd = curlun->sense_data; in do_request_sense()
1102 sdinfo = curlun->sense_data_info; in do_request_sense()
1103 valid = curlun->info_valid << 7; in do_request_sense()
1104 curlun->sense_data = SS_NO_SENSE; in do_request_sense()
1105 curlun->sense_data_info = 0; in do_request_sense()
1106 curlun->info_valid = 0; in do_request_sense()
1121 struct fsg_lun *curlun = common->curlun; in do_read_capacity() local
1129 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_read_capacity()
1133 if (curlun->num_sectors < 0x100000000ULL) in do_read_capacity()
1134 max_lba = curlun->num_sectors - 1; in do_read_capacity()
1138 put_unaligned_be32(curlun->blksize, &buf[4]); /* Block length */ in do_read_capacity()
1144 struct fsg_lun *curlun = common->curlun; in do_read_capacity_16() local
1151 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_read_capacity_16()
1155 put_unaligned_be64(curlun->num_sectors - 1, &buf[0]); in do_read_capacity_16()
1157 put_unaligned_be32(curlun->blksize, &buf[8]); /* Block length */ in do_read_capacity_16()
1166 struct fsg_lun *curlun = common->curlun; in do_read_header() local
1172 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_read_header()
1175 if (lba >= curlun->num_sectors) { in do_read_header()
1176 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; in do_read_header()
1188 struct fsg_lun *curlun = common->curlun; in do_read_toc() local
1199 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_read_toc()
1225 store_cdrom_address(&buf[16], msf, curlun->num_sectors); in do_read_toc()
1250 store_cdrom_address(&buf[7], msf, curlun->num_sectors); in do_read_toc()
1255 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_read_toc()
1262 struct fsg_lun *curlun = common->curlun; in do_mode_sense() local
1272 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_mode_sense()
1278 curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED; in do_mode_sense()
1292 buf[2] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */ in do_mode_sense()
1296 buf[3] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */ in do_mode_sense()
1334 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_mode_sense()
1348 struct fsg_lun *curlun = common->curlun; in do_start_stop() local
1351 if (!curlun) { in do_start_stop()
1353 } else if (!curlun->removable) { in do_start_stop()
1354 curlun->sense_data = SS_INVALID_COMMAND; in do_start_stop()
1358 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_start_stop()
1370 if (!fsg_lun_is_open(curlun)) { in do_start_stop()
1371 curlun->sense_data = SS_MEDIUM_NOT_PRESENT; in do_start_stop()
1378 if (curlun->prevent_medium_removal) { in do_start_stop()
1379 LDBG(curlun, "unload attempt prevented\n"); in do_start_stop()
1380 curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED; in do_start_stop()
1389 fsg_lun_close(curlun); in do_start_stop()
1398 struct fsg_lun *curlun = common->curlun; in do_prevent_allow() local
1401 if (!common->curlun) { in do_prevent_allow()
1403 } else if (!common->curlun->removable) { in do_prevent_allow()
1404 common->curlun->sense_data = SS_INVALID_COMMAND; in do_prevent_allow()
1410 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in do_prevent_allow()
1414 if (curlun->prevent_medium_removal && !prevent) in do_prevent_allow()
1415 fsg_lun_fsync_sub(curlun); in do_prevent_allow()
1416 curlun->prevent_medium_removal = prevent; in do_prevent_allow()
1423 struct fsg_lun *curlun = common->curlun; in do_read_format_capacities() local
1430 put_unaligned_be32(curlun->num_sectors, &buf[0]); in do_read_format_capacities()
1432 put_unaligned_be32(curlun->blksize, &buf[4]);/* Block length */ in do_read_format_capacities()
1439 struct fsg_lun *curlun = common->curlun; in do_mode_select() local
1442 if (curlun) in do_mode_select()
1443 curlun->sense_data = SS_INVALID_COMMAND; in do_mode_select()
1648 struct fsg_lun *curlun = common->curlun; in send_status() local
1661 if (curlun) { in send_status()
1662 sd = curlun->sense_data; in send_status()
1663 sdinfo = curlun->sense_data_info; in send_status()
1714 struct fsg_lun *curlun; in check_command() local
1781 curlun = common->curlun; in check_command()
1782 if (curlun) { in check_command()
1784 curlun->sense_data = SS_NO_SENSE; in check_command()
1785 curlun->sense_data_info = 0; in check_command()
1786 curlun->info_valid = 0; in check_command()
1806 if (curlun && curlun->unit_attention_data != SS_NO_SENSE && in check_command()
1809 curlun->sense_data = curlun->unit_attention_data; in check_command()
1810 curlun->unit_attention_data = SS_NO_SENSE; in check_command()
1818 if (curlun) in check_command()
1819 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; in check_command()
1826 if (curlun && !fsg_lun_is_open(curlun) && needs_medium) { in check_command()
1827 curlun->sense_data = SS_MEDIUM_NOT_PRESENT; in check_command()
1839 if (common->curlun) in check_command_size_in_blocks()
1840 common->data_size_from_cmnd <<= common->curlun->blkbits; in check_command_size_in_blocks()
1978 if (!common->curlun || !common->curlun->cdrom) in do_scsi_command()
1990 if (!common->curlun || !common->curlun->cdrom) in do_scsi_command()
2139 common->curlun->sense_data = SS_INVALID_COMMAND; in do_scsi_command()
2230 common->curlun = common->luns[common->lun]; in received_cbw()
2232 common->curlun = NULL; in received_cbw()
2414 struct fsg_lun *curlun; in handle_exception() local
2476 curlun = common->luns[i]; in handle_exception()
2477 if (!curlun) in handle_exception()
2479 curlun->prevent_medium_removal = 0; in handle_exception()
2480 curlun->sense_data = SS_NO_SENSE; in handle_exception()
2481 curlun->unit_attention_data = SS_NO_SENSE; in handle_exception()
2482 curlun->sense_data_info = 0; in handle_exception()
2483 curlun->info_valid = 0; in handle_exception()
2590 struct fsg_lun *curlun = common->luns[i]; in fsg_main_thread() local
2592 if (curlun && fsg_lun_is_open(curlun)) in fsg_main_thread()
2593 fsg_lun_close(curlun); in fsg_main_thread()
2606 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in ro_show() local
2608 return fsg_show_ro(curlun, buf); in ro_show()
2614 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in nofua_show() local
2616 return fsg_show_nofua(curlun, buf); in nofua_show()
2622 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in file_show() local
2625 return fsg_show_file(curlun, filesem, buf); in file_show()
2631 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in ro_store() local
2634 return fsg_store_ro(curlun, filesem, buf, count); in ro_store()
2640 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in nofua_store() local
2642 return fsg_store_nofua(curlun, buf, count); in nofua_store()
2648 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in file_store() local
2651 return fsg_store_file(curlun, filesem, buf, count); in file_store()
2658 struct fsg_lun *curlun = fsg_lun_from_dev(dev); in forced_eject_store() local
2661 return fsg_store_forced_eject(curlun, filesem, buf, count); in forced_eject_store()