rsc | 0c98da8 | 2005-07-13 03:48:35 +0000 | [diff] [blame] | 1 | #include <u.h> |
| 2 | #include <libc.h> |
| 3 | #include <bio.h> |
| 4 | #include <diskfs.h> |
| 5 | |
| 6 | void |
| 7 | blockdump(Block *bb, char *desc) |
| 8 | { |
| 9 | uchar *p, *ep; |
| 10 | int i; |
| 11 | Biobuf b; |
| 12 | |
| 13 | Binit(&b, 2, OWRITE); |
| 14 | |
| 15 | Bprint(&b, "%s\n", desc); |
| 16 | |
| 17 | p = bb->data; |
| 18 | ep = bb->data + bb->len; |
| 19 | |
| 20 | while(p < ep){ |
| 21 | for(i=0; i<16; i++){ |
| 22 | if(p+i < ep) |
| 23 | Bprint(&b, "%.2ux ", p[i]); |
| 24 | else |
| 25 | Bprint(&b, " "); |
| 26 | if(i==7) |
| 27 | Bprint(&b, "- "); |
| 28 | } |
| 29 | Bprint(&b, " "); |
| 30 | for(i=0; i<16; i++){ |
| 31 | if(p+i < ep) |
| 32 | Bprint(&b, "%c", p[i] >= 0x20 && p[i] <= 0x7F ? p[i] : '.'); |
| 33 | else |
| 34 | Bprint(&b, " "); |
| 35 | } |
| 36 | p += 16; |
| 37 | Bprint(&b, "\n"); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void |
| 42 | blockput(Block *b) |
| 43 | { |
| 44 | if(b == nil) |
| 45 | return; |
| 46 | if(!b->_close){ |
| 47 | fprint(2, "no blockPut\n"); |
| 48 | abort(); |
| 49 | } |
| 50 | (*b->_close)(b); |
| 51 | } |