sense.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include <disk.h>
  13. #include "scsireq.h"
  14. extern Biobuf bout;
  15. static char* key[16] = {
  16. "no sense",
  17. "recovered error",
  18. "not ready",
  19. "medium error",
  20. "hardware error",
  21. "illegal request",
  22. "unit attention",
  23. "data protect",
  24. "blank check",
  25. "vendor specific",
  26. "copy aborted",
  27. "aborted command",
  28. "equal",
  29. "volume overflow",
  30. "miscompare",
  31. "reserved",
  32. };
  33. /*
  34. * use libdisk to read /sys/lib/scsicodes
  35. */
  36. void
  37. makesense(ScsiReq *rp)
  38. {
  39. char *s;
  40. int i;
  41. Bprint(&bout, "sense data: %s", key[rp->sense[2] & 0x0F]);
  42. if(rp->sense[7] >= 5 && (s = scsierror(rp->sense[0xc], rp->sense[0xd])))
  43. Bprint(&bout, ": %s", s);
  44. Bprint(&bout, "\n\t");
  45. for(i = 0; i < 8+rp->sense[7]; i++)
  46. Bprint(&bout, " %2.2ux", rp->sense[i]);
  47. Bprint(&bout, "\n");
  48. }