07.06.2013 Views

Scsi - Index of

Scsi - Index of

Scsi - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

到北京,每每只有在夜深人静的时候,听着广播,才能忘却一些绝望.于是继续写吧,既然人生的幕布已经拉<br />

开,<br />

就一定要积极的演出;既然脚步已经跨出,风雨坎坷也不能退步;既然我已把希望播在这里,就一定要坚持到<br />

胜利的谢幕.<br />

375 行,us->proto_handler()其实是一个函数指针,知道它指向什么吗?不要说你不知道,早年我们在<br />

storage_probe()中,确切的说,在get_protocol()就赋了值,当时只知道是get protocol,却不知道究竟干<br />

什么用,现在该用上了,别以为写代码的都是傻子,一个指针要是没什么用人家才不会为它赋值呢.当初我们<br />

就讲了,对于U 盘,proto_handler 被赋值为usb_stor_transparent_scsi_command,所以我们来看后<br />

者吧. 后者定义于drivers/usb/storage/protocol.c:<br />

172 void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb,<br />

173 struct us_data *us)<br />

174 {<br />

175 /* send the command to the transport layer */<br />

176 usb_stor_invoke_transport(srb, us);<br />

177<br />

178 if (srb->result == SAM_STAT_GOOD) {<br />

179 /* Fix the READ CAPACITY result if necessary */<br />

180 if (us->flags & US_FL_FIX_CAPACITY)<br />

181 fix_read_capacity(srb);<br />

182 }<br />

183 }<br />

145<br />

首先注意到的是usb_stor_invoke_transport()函数这个函数可不简单.咱们先做好思想准备, 接下<br />

来就去见识一下她的庐山真面目. 她来自drivers/usb/storage/transport.c:<br />

519<br />

/***********************************************************************<br />

520 * Transport routines<br />

521 ****************************************************************<br />

*******/<br />

522<br />

523 /* Invoke the transport and basic error-handling/recovery methods<br />

524 *<br />

525 * This is used by the protocol layers to actually send the message to<br />

526 * the device and receive the response.<br />

527 */<br />

528 void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)<br />

529 {<br />

530 int need_auto_sense;<br />

531 int result;<br />

532<br />

533 /* send the command to the transport layer */<br />

534 srb->resid = 0;<br />

535 result = us->transport(srb, us);<br />

536

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!