| 1 | /* |
| 2 | * cloop.c |
| 3 | * Layered data source for Linux cloop images. |
| 4 | * |
| 5 | * Copyright (c) 2005 Christoph Pfisterer |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person |
| 8 | * obtaining a copy of this software and associated documentation |
| 9 | * files (the "Software"), to deal in the Software without |
| 10 | * restriction, including without limitation the rights to use, copy, |
| 11 | * modify, merge, publish, distribute, sublicense, and/or sell copies |
| 12 | * of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be |
| 16 | * included in all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | * SOFTWARE. |
| 26 | */ |
| 27 | |
| 28 | #include "global.h" |
| 29 | |
| 30 | /* |
| 31 | * image file detection |
| 32 | */ |
| 33 | |
| 34 | void detect_cloop(SECTION *section, int level) |
| 35 | { |
| 36 | unsigned char *buf; |
| 37 | u4 blocksize, blockcount; |
| 38 | char s[256]; |
| 39 | const char *sig_20 = "#!/bin/sh\n#V2.0 Format\nmodprobe cloop"; |
| 40 | |
| 41 | /* check for signature */ |
| 42 | if (get_buffer(section, 0, 256, (void **)&buf) < 256) |
| 43 | return; |
| 44 | if (memcmp(buf, sig_20, strlen(sig_20)) != 0) |
| 45 | return; |
| 46 | |
| 47 | print_line(level, "Linux cloop 2.0 image"); |
| 48 | |
| 49 | blocksize = get_be_long(buf + 128); |
| 50 | blockcount = get_be_long(buf + 132); |
| 51 | format_blocky_size(s, blockcount, blocksize, "blocks", NULL); |
| 52 | print_line(level + 1, "Volume size %s", s); |
| 53 | } |
| 54 | |
| 55 | /* EOF */ |