Lines Matching defs:curlun
394 struct fsg_lun *curlun;
1030 struct fsg_lun *curlun = fsg->curlun;
1051 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1055 if (lba >= curlun->num_sectors) {
1056 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1078 curlun->file_length - file_offset);
1095 curlun->sense_data =
1097 curlun->sense_data_info = file_offset >> 9;
1098 curlun->info_valid = 1;
1106 nread = vfs_read(curlun->filp,
1109 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
1116 LDBG(curlun, "error in file read: %d\n",
1120 LDBG(curlun, "partial file read: %d/%u\n",
1132 curlun->sense_data = SS_UNRECOVERED_READ_ERROR;
1133 curlun->sense_data_info = file_offset >> 9;
1134 curlun->info_valid = 1;
1156 struct fsg_lun *curlun = fsg->curlun;
1167 if (curlun->ro) {
1168 curlun->sense_data = SS_WRITE_PROTECTED;
1171 spin_lock(&curlun->filp->f_lock);
1172 curlun->filp->f_flags &= ~O_SYNC; // Default is not to wait
1173 spin_unlock(&curlun->filp->f_lock);
1187 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1191 if (!curlun->nofua && (fsg->cmnd[1] & 0x08)) {
1192 spin_lock(&curlun->filp->f_lock);
1193 curlun->filp->f_flags |= O_DSYNC;
1194 spin_unlock(&curlun->filp->f_lock);
1197 if (lba >= curlun->num_sectors) {
1198 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1223 amount = min((loff_t) amount, curlun->file_length -
1232 curlun->sense_data =
1234 curlun->sense_data_info = usb_offset >> 9;
1235 curlun->info_valid = 1;
1276 curlun->sense_data = SS_COMMUNICATION_FAILURE;
1277 curlun->sense_data_info = file_offset >> 9;
1278 curlun->info_valid = 1;
1283 if (curlun->file_length - file_offset < amount) {
1284 LERROR(curlun,
1287 (unsigned long long) curlun->file_length);
1288 amount = curlun->file_length - file_offset;
1293 nwritten = vfs_write(curlun->filp,
1296 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount,
1303 LDBG(curlun, "error in file write: %d\n",
1307 LDBG(curlun, "partial file write: %d/%u\n",
1318 curlun->sense_data = SS_WRITE_ERROR;
1319 curlun->sense_data_info = file_offset >> 9;
1320 curlun->info_valid = 1;
1346 struct fsg_lun *curlun = fsg->curlun;
1351 rc = fsg_lun_fsync_sub(curlun);
1353 curlun->sense_data = SS_WRITE_ERROR;
1360 static void invalidate_sub(struct fsg_lun *curlun)
1362 struct file *filp = curlun->filp;
1367 VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc);
1372 struct fsg_lun *curlun = fsg->curlun;
1384 if (lba >= curlun->num_sectors) {
1385 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1392 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1405 fsg_lun_fsync_sub(curlun);
1409 invalidate_sub(curlun);
1424 curlun->file_length - file_offset);
1426 curlun->sense_data =
1428 curlun->sense_data_info = file_offset >> 9;
1429 curlun->info_valid = 1;
1435 nread = vfs_read(curlun->filp,
1438 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
1445 LDBG(curlun, "error in file verify: %d\n",
1449 LDBG(curlun, "partial file verify: %d/%u\n",
1454 curlun->sense_data = SS_UNRECOVERED_READ_ERROR;
1455 curlun->sense_data_info = file_offset >> 9;
1456 curlun->info_valid = 1;
1476 if (!fsg->curlun) { // Unsupported LUNs are okay
1502 struct fsg_lun *curlun = fsg->curlun;
1523 if (!curlun) { // Unsupported LUNs are okay
1529 sd = curlun->sense_data;
1530 sdinfo = curlun->sense_data_info;
1531 valid = curlun->info_valid << 7;
1532 curlun->sense_data = SS_NO_SENSE;
1533 curlun->sense_data_info = 0;
1534 curlun->info_valid = 0;
1550 struct fsg_lun *curlun = fsg->curlun;
1557 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1561 put_unaligned_be32(curlun->num_sectors - 1, &buf[0]);
1570 struct fsg_lun *curlun = fsg->curlun;
1576 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1579 if (lba >= curlun->num_sectors) {
1580 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1593 struct fsg_lun *curlun = fsg->curlun;
1600 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1614 store_cdrom_address(&buf[16], msf, curlun->num_sectors);
1621 struct fsg_lun *curlun = fsg->curlun;
1631 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1637 curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
1649 buf[2] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
1653 buf[3] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
1687 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1702 struct fsg_lun *curlun = fsg->curlun;
1706 curlun->sense_data = SS_INVALID_COMMAND;
1717 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1724 if (curlun->prevent_medium_removal) {
1725 LDBG(curlun, "unload attempt prevented\n");
1726 curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED;
1732 fsg_lun_close(curlun);
1740 if (!fsg_lun_is_open(curlun)) {
1741 curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
1752 struct fsg_lun *curlun = fsg->curlun;
1756 curlun->sense_data = SS_INVALID_COMMAND;
1762 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
1766 if (curlun->prevent_medium_removal && !prevent)
1767 fsg_lun_fsync_sub(curlun);
1768 curlun->prevent_medium_removal = prevent;
1776 struct fsg_lun *curlun = fsg->curlun;
1783 put_unaligned_be32(curlun->num_sectors, &buf[0]);
1793 struct fsg_lun *curlun = fsg->curlun;
1796 curlun->sense_data = SS_INVALID_COMMAND;
1972 (!fsg->curlun || fsg->curlun->sense_data != SS_NO_SENSE)) {
2029 struct fsg_lun *curlun = fsg->curlun;
2043 if (curlun) {
2044 sd = curlun->sense_data;
2045 sdinfo = curlun->sense_data_info;
2121 struct fsg_lun *curlun;
2197 fsg->curlun = curlun = &fsg->luns[fsg->lun];
2199 curlun->sense_data = SS_NO_SENSE;
2200 curlun->sense_data_info = 0;
2201 curlun->info_valid = 0;
2204 fsg->curlun = curlun = NULL;
2218 if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
2221 curlun->sense_data = curlun->unit_attention_data;
2222 curlun->unit_attention_data = SS_NO_SENSE;
2230 if (curlun)
2231 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
2238 if (curlun && !fsg_lun_is_open(curlun) && needs_medium) {
2239 curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
2465 fsg->curlun->sense_data = SS_INVALID_COMMAND;
2793 struct fsg_lun *curlun;
2861 curlun = &fsg->luns[i];
2862 curlun->prevent_medium_removal = 0;
2863 curlun->sense_data = curlun->unit_attention_data =
2865 curlun->sense_data_info = 0;
2866 curlun->info_valid = 0;
3047 struct fsg_lun *curlun;
3055 curlun = &fsg->luns[i];
3056 if (curlun->registered) {
3057 device_remove_file(&curlun->dev, &dev_attr_ro);
3058 device_remove_file(&curlun->dev, &dev_attr_file);
3059 fsg_lun_close(curlun);
3060 device_unregister(&curlun->dev);
3061 curlun->registered = 0;
3231 struct fsg_lun *curlun;
3277 curlun = &fsg->luns[i];
3278 curlun->cdrom = !!mod_data.cdrom;
3279 curlun->ro = mod_data.cdrom || mod_data.ro[i];
3280 curlun->initially_ro = curlun->ro;
3281 curlun->removable = mod_data.removable;
3282 curlun->nofua = mod_data.nofua[i];
3283 curlun->dev.release = lun_release;
3284 curlun->dev.parent = &gadget->dev;
3285 curlun->dev.driver = &fsg_driver.driver;
3286 dev_set_drvdata(&curlun->dev, &fsg->filesem);
3287 dev_set_name(&curlun->dev,"%s-lun%d",
3290 if ((rc = device_register(&curlun->dev)) != 0) {
3294 if ((rc = device_create_file(&curlun->dev,
3296 (rc = device_create_file(&curlun->dev,
3298 (rc = device_create_file(&curlun->dev,
3300 device_unregister(&curlun->dev);
3303 curlun->registered = 1;
3307 if ((rc = fsg_lun_open(curlun,
3414 curlun = &fsg->luns[i];
3415 if (fsg_lun_is_open(curlun)) {
3418 p = d_path(&curlun->filp->f_path,
3423 LINFO(curlun, "ro=%d, nofua=%d, file: %s\n",
3424 curlun->ro, curlun->nofua, (p ? p : "(error)"));