📄 tape_std.c
字号:
return tape_do_io_free(device, request);}/* * MTBSFM: Backward space over 'count' file marks. * The tape is positioned at the BOT (Begin Of Tape) side of the * last skipped file mark. */inttape_std_mtbsfm(struct tape_device *device, int mt_count){ struct tape_request *request; struct ccw1 *ccw; request = tape_alloc_request(mt_count + 2, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_BSF; /* setup ccws */ ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); ccw = tape_ccw_repeat(ccw, BACKSPACEFILE, mt_count); ccw = tape_ccw_end(ccw, NOP, 0, NULL); /* execute it */ return tape_do_io_free(device, request);}/* * MTBSF: Backward space over 'count' file marks. The tape is positioned at * the EOT (End of Tape) side of the last skipped file mark. */inttape_std_mtbsf(struct tape_device *device, int mt_count){ struct tape_request *request; struct ccw1 *ccw; int rc; request = tape_alloc_request(mt_count + 2, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_BSF; /* setup ccws */ ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); ccw = tape_ccw_repeat(ccw, BACKSPACEFILE, mt_count); ccw = tape_ccw_end(ccw, NOP, 0, NULL); /* execute it */ rc = tape_do_io_free(device, request); if (rc == 0) { rc = tape_mtop(device, MTFSR, 1); if (rc > 0) rc = 0; } return rc;}/* * MTFSFM: Forward space over 'count' file marks. * The tape is positioned at the BOT (Begin Of Tape) side * of the last skipped file mark. */inttape_std_mtfsfm(struct tape_device *device, int mt_count){ struct tape_request *request; struct ccw1 *ccw; int rc; request = tape_alloc_request(mt_count + 2, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_FSF; /* setup ccws */ ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); ccw = tape_ccw_repeat(ccw, FORSPACEFILE, mt_count); ccw = tape_ccw_end(ccw, NOP, 0, NULL); /* execute it */ rc = tape_do_io_free(device, request); if (rc == 0) { rc = tape_mtop(device, MTBSR, 1); if (rc > 0) rc = 0; } return rc;}/* * MTREW: Rewind the tape. */inttape_std_mtrew(struct tape_device *device, int mt_count){ struct tape_request *request; request = tape_alloc_request(3, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_REW; /* setup ccws */ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_cc(request->cpaddr + 1, REWIND, 0, NULL); tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); /* execute it */ return tape_do_io_free(device, request);}/* * MTOFFL: Rewind the tape and put the drive off-line. * Implement 'rewind unload' */inttape_std_mtoffl(struct tape_device *device, int mt_count){ struct tape_request *request; request = tape_alloc_request(3, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_RUN; /* setup ccws */ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_cc(request->cpaddr + 1, REWIND_UNLOAD, 0, NULL); tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); /* execute it */ return tape_do_io_free(device, request);}/* * MTNOP: 'No operation'. */inttape_std_mtnop(struct tape_device *device, int mt_count){ struct tape_request *request; request = tape_alloc_request(2, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_NOP; /* setup ccws */ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_end(request->cpaddr + 1, NOP, 0, NULL); /* execute it */ return tape_do_io_free(device, request);}/* * MTEOM: positions at the end of the portion of the tape already used * for recordind data. MTEOM positions after the last file mark, ready for * appending another file. */inttape_std_mteom(struct tape_device *device, int mt_count){ int rc; /* * Seek from the beginning of tape (rewind). */ if ((rc = tape_mtop(device, MTREW, 1)) < 0) return rc; /* * The logical end of volume is given by two sewuential tapemarks. * Look for this by skipping to the next file (over one tapemark) * and then test for another one (fsr returns 1 if a tapemark was * encountered). */ do { if ((rc = tape_mtop(device, MTFSF, 1)) < 0) return rc; if ((rc = tape_mtop(device, MTFSR, 1)) < 0) return rc; } while (rc == 0); return tape_mtop(device, MTBSR, 1);}/* * MTRETEN: Retension the tape, i.e. forward space to end of tape and rewind. */inttape_std_mtreten(struct tape_device *device, int mt_count){ struct tape_request *request; int rc; request = tape_alloc_request(4, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_FSF; /* setup ccws */ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_cc(request->cpaddr + 1,FORSPACEFILE, 0, NULL); tape_ccw_cc(request->cpaddr + 2, NOP, 0, NULL); tape_ccw_end(request->cpaddr + 3, CCW_CMD_TIC, 0, request->cpaddr); /* execute it, MTRETEN rc gets ignored */ rc = tape_do_io_interruptible(device, request); tape_free_request(request); return tape_mtop(device, MTREW, 1);}/* * MTERASE: erases the tape. */inttape_std_mterase(struct tape_device *device, int mt_count){ struct tape_request *request; request = tape_alloc_request(6, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_DSE; /* setup ccws */ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_cc(request->cpaddr + 1, REWIND, 0, NULL); tape_ccw_cc(request->cpaddr + 2, ERASE_GAP, 0, NULL); tape_ccw_cc(request->cpaddr + 3, DATA_SEC_ERASE, 0, NULL); tape_ccw_cc(request->cpaddr + 4, REWIND, 0, NULL); tape_ccw_end(request->cpaddr + 5, NOP, 0, NULL); /* execute it */ return tape_do_io_free(device, request);}/* * MTUNLOAD: Rewind the tape and unload it. */inttape_std_mtunload(struct tape_device *device, int mt_count){ return tape_mtop(device, MTOFFL, mt_count);}/* * MTCOMPRESSION: used to enable compression. * Sets the IDRC on/off. */inttape_std_mtcompression(struct tape_device *device, int mt_count){ struct tape_request *request; if (mt_count < 0 || mt_count > 1) { DBF_EXCEPTION(6, "xcom parm\n"); if (*device->modeset_byte & 0x08) PRINT_INFO("(%s) Compression is currently on\n", device->cdev->dev.bus_id); else PRINT_INFO("(%s) Compression is currently off\n", device->cdev->dev.bus_id); PRINT_INFO("Use 1 to switch compression on, 0 to " "switch it off\n"); return -EINVAL; } request = tape_alloc_request(2, 0); if (IS_ERR(request)) return PTR_ERR(request); request->op = TO_NOP; /* setup ccws */ *device->modeset_byte = (mt_count == 0) ? 0x00 : 0x08; tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_end(request->cpaddr + 1, NOP, 0, NULL); /* execute it */ return tape_do_io_free(device, request);}/* * Read Block */struct tape_request *tape_std_read_block(struct tape_device *device, size_t count){ struct tape_request *request; /* * We have to alloc 4 ccws in order to be able to transform request * into a read backward request in error case. */ request = tape_alloc_request(4, 0); if (IS_ERR(request)) { DBF_EXCEPTION(6, "xrbl fail"); return request; } request->op = TO_RFO; tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_end_idal(request->cpaddr + 1, READ_FORWARD, device->char_data.idal_buf); DBF_EVENT(6, "xrbl ccwg\n"); return request;}/* * Read Block backward transformation function. */voidtape_std_read_backward(struct tape_device *device, struct tape_request *request){ /* * We have allocated 4 ccws in tape_std_read, so we can now * transform the request to a read backward, followed by a * forward space block. */ request->op = TO_RBA; tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_cc_idal(request->cpaddr + 1, READ_BACKWARD, device->char_data.idal_buf); tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL); tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL); DBF_EVENT(6, "xrop ccwg");}/* * Write Block */struct tape_request *tape_std_write_block(struct tape_device *device, size_t count){ struct tape_request *request; request = tape_alloc_request(2, 0); if (IS_ERR(request)) { DBF_EXCEPTION(6, "xwbl fail\n"); return request; } request->op = TO_WRI; tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); tape_ccw_end_idal(request->cpaddr + 1, WRITE_CMD, device->char_data.idal_buf); DBF_EVENT(6, "xwbl ccwg\n"); return request;}/* * This routine is called by frontend after an ENOSP on write */voidtape_std_process_eov(struct tape_device *device){ /* * End of volume: We have to backspace the last written record, then * we TRY to write a tapemark and then backspace over the written TM */ if (tape_mtop(device, MTBSR, 1) == 0 && tape_mtop(device, MTWEOF, 1) == 0) { tape_mtop(device, MTBSR, 1); }}EXPORT_SYMBOL(tape_std_assign);EXPORT_SYMBOL(tape_std_unassign);EXPORT_SYMBOL(tape_std_display);EXPORT_SYMBOL(tape_std_read_block_id);EXPORT_SYMBOL(tape_std_mtload);EXPORT_SYMBOL(tape_std_mtsetblk);EXPORT_SYMBOL(tape_std_mtreset);EXPORT_SYMBOL(tape_std_mtfsf);EXPORT_SYMBOL(tape_std_mtfsr);EXPORT_SYMBOL(tape_std_mtbsr);EXPORT_SYMBOL(tape_std_mtweof);EXPORT_SYMBOL(tape_std_mtbsfm);EXPORT_SYMBOL(tape_std_mtbsf);EXPORT_SYMBOL(tape_std_mtfsfm);EXPORT_SYMBOL(tape_std_mtrew);EXPORT_SYMBOL(tape_std_mtoffl);EXPORT_SYMBOL(tape_std_mtnop);EXPORT_SYMBOL(tape_std_mteom);EXPORT_SYMBOL(tape_std_mtreten);EXPORT_SYMBOL(tape_std_mterase);EXPORT_SYMBOL(tape_std_mtunload);EXPORT_SYMBOL(tape_std_mtcompression);EXPORT_SYMBOL(tape_std_read_block);EXPORT_SYMBOL(tape_std_read_backward);EXPORT_SYMBOL(tape_std_write_block);EXPORT_SYMBOL(tape_std_process_eov);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -